mirror of https://github.com/sbt/sbt.git
parent
1d8280e8f2
commit
18a9af89f7
|
|
@ -10,13 +10,13 @@ final class Artifact private (
|
|||
val extension: String,
|
||||
val classifier: Option[String],
|
||||
val configurations: Vector[sbt.librarymanagement.ConfigRef],
|
||||
val url: Option[java.net.URI],
|
||||
val url: Option[java.net.URL],
|
||||
val extraAttributes: Map[String, String],
|
||||
val checksum: Option[sbt.librarymanagement.Checksum],
|
||||
val allowInsecureProtocol: Boolean) extends sbt.librarymanagement.ArtifactExtra with Serializable {
|
||||
private[sbt] def validateProtocol(logger: sbt.util.Logger): Boolean = Resolver.validateArtifact(this, logger)
|
||||
private def this(name: String) = this(name, Artifact.DefaultType, Artifact.DefaultExtension, None, Vector.empty, None, Map.empty, None, false)
|
||||
private def this(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[sbt.librarymanagement.ConfigRef], url: Option[java.net.URI], extraAttributes: Map[String, String], checksum: Option[sbt.librarymanagement.Checksum]) = this(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum, false)
|
||||
private def this(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[sbt.librarymanagement.ConfigRef], url: Option[java.net.URL], extraAttributes: Map[String, String], checksum: Option[sbt.librarymanagement.Checksum]) = this(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum, false)
|
||||
|
||||
override def equals(o: Any): Boolean = this.eq(o.asInstanceOf[AnyRef]) || (o match {
|
||||
case x: Artifact => (this.name == x.name) && (this.`type` == x.`type`) && (this.extension == x.extension) && (this.classifier == x.classifier) && (this.configurations == x.configurations) && (this.url == x.url) && (this.extraAttributes == x.extraAttributes) && (this.checksum == x.checksum) && (this.allowInsecureProtocol == x.allowInsecureProtocol)
|
||||
|
|
@ -28,7 +28,7 @@ final class Artifact private (
|
|||
override def toString: String = {
|
||||
"Artifact(" + name + ", " + `type` + ", " + extension + ", " + classifier + ", " + configurations + ", " + url + ", " + extraAttributes + ", " + checksum + ", " + allowInsecureProtocol + ")"
|
||||
}
|
||||
private[this] def copy(name: String = name, `type`: String = `type`, extension: String = extension, classifier: Option[String] = classifier, configurations: Vector[sbt.librarymanagement.ConfigRef] = configurations, url: Option[java.net.URI] = url, extraAttributes: Map[String, String] = extraAttributes, checksum: Option[sbt.librarymanagement.Checksum] = checksum, allowInsecureProtocol: Boolean = allowInsecureProtocol): Artifact = {
|
||||
private[this] def copy(name: String = name, `type`: String = `type`, extension: String = extension, classifier: Option[String] = classifier, configurations: Vector[sbt.librarymanagement.ConfigRef] = configurations, url: Option[java.net.URL] = url, extraAttributes: Map[String, String] = extraAttributes, checksum: Option[sbt.librarymanagement.Checksum] = checksum, allowInsecureProtocol: Boolean = allowInsecureProtocol): Artifact = {
|
||||
new Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum, allowInsecureProtocol)
|
||||
}
|
||||
def withName(name: String): Artifact = {
|
||||
|
|
@ -46,7 +46,7 @@ final class Artifact private (
|
|||
def withConfigurations(configurations: Vector[sbt.librarymanagement.ConfigRef]): Artifact = {
|
||||
copy(configurations = configurations)
|
||||
}
|
||||
def withUrl(url: Option[java.net.URI]): Artifact = {
|
||||
def withUrl(url: Option[java.net.URL]): Artifact = {
|
||||
copy(url = url)
|
||||
}
|
||||
def withExtraAttributes(extraAttributes: Map[String, String]): Artifact = {
|
||||
|
|
@ -62,6 +62,6 @@ final class Artifact private (
|
|||
object Artifact extends sbt.librarymanagement.ArtifactFunctions {
|
||||
|
||||
def apply(name: String): Artifact = new Artifact(name)
|
||||
def apply(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[sbt.librarymanagement.ConfigRef], url: Option[java.net.URI], extraAttributes: Map[String, String], checksum: Option[sbt.librarymanagement.Checksum]): Artifact = new Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum)
|
||||
def apply(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[sbt.librarymanagement.ConfigRef], url: Option[java.net.URI], extraAttributes: Map[String, String], checksum: Option[sbt.librarymanagement.Checksum], allowInsecureProtocol: Boolean): Artifact = new Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum, allowInsecureProtocol)
|
||||
def apply(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[sbt.librarymanagement.ConfigRef], url: Option[java.net.URL], extraAttributes: Map[String, String], checksum: Option[sbt.librarymanagement.Checksum]): Artifact = new Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum)
|
||||
def apply(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[sbt.librarymanagement.ConfigRef], url: Option[java.net.URL], extraAttributes: Map[String, String], checksum: Option[sbt.librarymanagement.Checksum], allowInsecureProtocol: Boolean): Artifact = new Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes, checksum, allowInsecureProtocol)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ implicit lazy val ArtifactFormat: JsonFormat[sbt.librarymanagement.Artifact] = n
|
|||
val extension = unbuilder.readField[String]("extension")
|
||||
val classifier = unbuilder.readField[Option[String]]("classifier")
|
||||
val configurations = unbuilder.readField[Vector[sbt.librarymanagement.ConfigRef]]("configurations")
|
||||
val url = unbuilder.readField[Option[java.net.URI]]("url")
|
||||
val url = unbuilder.readField[Option[java.net.URL]]("url")
|
||||
val extraAttributes = unbuilder.readField[Map[String, String]]("extraAttributes")
|
||||
val checksum = unbuilder.readField[Option[sbt.librarymanagement.Checksum]]("checksum")
|
||||
val allowInsecureProtocol = unbuilder.readField[Boolean]("allowInsecureProtocol")
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@
|
|||
{ "name": "extension", "type": "String", "default": "Artifact.DefaultExtension", "since": "0.0.1" },
|
||||
{ "name": "classifier", "type": "Option[String]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "configurations", "type": "sbt.librarymanagement.ConfigRef*", "default": "Vector.empty", "since": "0.0.1" },
|
||||
{ "name": "url", "type": "Option[java.net.URI]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "url", "type": "Option[java.net.URL]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "extraAttributes", "type": "Map[String, String]", "default": "Map.empty", "since": "0.0.1" },
|
||||
{ "name": "checksum", "type": "Option[sbt.librarymanagement.Checksum]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "allowInsecureProtocol", "type": "Boolean", "default": "false", "since": "1.3.0" }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.net.URL
|
||||
|
||||
private[librarymanagement] abstract class ArtifactExtra {
|
||||
def extraAttributes: Map[String, String]
|
||||
|
|
@ -26,15 +26,15 @@ private[librarymanagement] abstract class ArtifactFunctions {
|
|||
Artifact(name, `type`, extension, None, Vector.empty, None)
|
||||
def apply(name: String, `type`: String, extension: String, classifier: String): Artifact =
|
||||
Artifact(name, `type`, extension, Some(classifier), Vector.empty, None)
|
||||
def apply(name: String, uri: URI): Artifact = Artifact(name, uri, false)
|
||||
def apply(name: String, uri: URI, allowInsecureProtocol: Boolean): Artifact =
|
||||
def apply(name: String, url: URL): Artifact = Artifact(name, url, false)
|
||||
def apply(name: String, url: URL, allowInsecureProtocol: Boolean): Artifact =
|
||||
Artifact(
|
||||
name,
|
||||
extract(uri, DefaultType),
|
||||
extract(uri, DefaultExtension),
|
||||
extract(url, DefaultType),
|
||||
extract(url, DefaultExtension),
|
||||
None,
|
||||
Vector.empty,
|
||||
Some(uri),
|
||||
Some(url),
|
||||
Map.empty,
|
||||
None,
|
||||
allowInsecureProtocol
|
||||
|
|
@ -47,9 +47,8 @@ private[librarymanagement] abstract class ArtifactFunctions {
|
|||
extension: String,
|
||||
classifier: Option[String],
|
||||
configurations: Vector[ConfigRef],
|
||||
uri: Option[URI]
|
||||
): Artifact =
|
||||
Artifact(name, `type`, extension, classifier, configurations, uri, empty, None)
|
||||
url: Option[URL]
|
||||
): Artifact = Artifact(name, `type`, extension, classifier, configurations, url, empty, None)
|
||||
|
||||
val DefaultExtension = "jar"
|
||||
val DefaultType = "jar"
|
||||
|
|
@ -79,7 +78,7 @@ private[librarymanagement] abstract class ArtifactFunctions {
|
|||
assert(DefaultDocTypes contains DocType)
|
||||
assert(DefaultSourceTypes contains SourceType)
|
||||
|
||||
def extract(uri: URI, default: String): String = extract(uri.toString, default)
|
||||
def extract(url: URL, default: String): String = extract(url.toString, default)
|
||||
def extract(name: String, default: String): String = {
|
||||
val i = name.lastIndexOf('.')
|
||||
if (i >= 0)
|
||||
|
|
@ -97,7 +96,7 @@ private[librarymanagement] abstract class ArtifactFunctions {
|
|||
extract(name, DefaultExtension),
|
||||
None,
|
||||
Vector.empty,
|
||||
Some(file.toURI)
|
||||
Some(file.toURI.toURL)
|
||||
)
|
||||
}
|
||||
def artifactName(scalaVersion: ScalaVersion, module: ModuleID, artifact: Artifact): String = {
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
* It is not included in published metadata.
|
||||
*/
|
||||
def from(url: String, allowInsecureProtocol: Boolean): ModuleID =
|
||||
artifacts(Artifact(name, new URI(url), allowInsecureProtocol))
|
||||
artifacts(Artifact(name, new URI(url).toURL, allowInsecureProtocol))
|
||||
|
||||
/** Adds a dependency on the artifact for this module with classifier `c`. */
|
||||
def classifier(c: String): ModuleID = artifacts(Artifact(name, c))
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@ private[sbt] object IvySbt {
|
|||
name,
|
||||
`type`,
|
||||
extension,
|
||||
url.map(_.toURL).orNull,
|
||||
url.orNull,
|
||||
extraMap
|
||||
)
|
||||
copyConfigurations(artifact, (ref: ConfigRef) => { ivyArtifact.addConfiguration(ref.name) })
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ object IvyRetrieve {
|
|||
getConfigurations.toVector map { (c: String) =>
|
||||
ConfigRef(c)
|
||||
},
|
||||
Option(getUrl).map(_.toURI)
|
||||
Option(getUrl)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ object DMSerializationSpec extends BasicTestSuite {
|
|||
}
|
||||
|
||||
test("""Artifact("foo", url("http://example.com/")) should roundtrip""") {
|
||||
roundtrip(Artifact("foo", new URI("http://example.com/")))
|
||||
roundtrip(Artifact("foo", new URI("http://example.com/").toURL))
|
||||
}
|
||||
|
||||
test("""Artifact("foo").extra(("key", "value")) should roundtrip""") {
|
||||
|
|
|
|||
Loading…
Reference in New Issue