mirror of https://github.com/sbt/sbt.git
Take explicit artifact name and extension into account (#86)
This commit is contained in:
parent
dcc7d87503
commit
6be594e52e
|
|
@ -1,8 +1,7 @@
|
||||||
package lmcoursier
|
package lmcoursier
|
||||||
|
|
||||||
import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
|
import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
|
||||||
|
import lmcoursier.definitions.{Classifier, Configuration, Dependency, Extension, Info, Module, ModuleName, Organization, Project, Publication, Type}
|
||||||
import lmcoursier.definitions.{Attributes, Classifier, Configuration, Dependency, Info, Module, ModuleName, Organization, Project, Type}
|
|
||||||
import sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties
|
import sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties
|
||||||
import sbt.librarymanagement.{Configuration => _, MavenRepository => _, _}
|
import sbt.librarymanagement.{Configuration => _, MavenRepository => _, _}
|
||||||
|
|
||||||
|
|
@ -76,7 +75,7 @@ object FromSbt {
|
||||||
// FIXME Other `rule` fields are ignored here
|
// FIXME Other `rule` fields are ignored here
|
||||||
(Organization(rule.organization), ModuleName(rule.name))
|
(Organization(rule.organization), ModuleName(rule.name))
|
||||||
}.toSet,
|
}.toSet,
|
||||||
Attributes(Type(""), Classifier("")),
|
Publication("", Type(""), Extension(""), Classifier("")),
|
||||||
optional = false,
|
optional = false,
|
||||||
transitive = module.isTransitive
|
transitive = module.isTransitive
|
||||||
)
|
)
|
||||||
|
|
@ -87,24 +86,28 @@ object FromSbt {
|
||||||
(Configuration(from.value), Configuration(to.value))
|
(Configuration(from.value), Configuration(to.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
val attributes =
|
val publications =
|
||||||
if (module.explicitArtifacts.isEmpty)
|
if (module.explicitArtifacts.isEmpty)
|
||||||
Seq(Attributes(Type(""), Classifier("")))
|
Seq(Publication("", Type(""), Extension(""), Classifier("")))
|
||||||
else
|
else
|
||||||
module.explicitArtifacts.map { a =>
|
module
|
||||||
Attributes(
|
.explicitArtifacts
|
||||||
`type` = Type(a.`type`),
|
.map { a =>
|
||||||
classifier = a.classifier.fold(Classifier(""))(Classifier(_))
|
Publication(
|
||||||
)
|
name = a.name,
|
||||||
}
|
`type` = Type(a.`type`),
|
||||||
|
ext = Extension(a.extension),
|
||||||
|
classifier = a.classifier.fold(Classifier(""))(Classifier(_))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
(from, to) <- allMappings
|
(from, to) <- allMappings
|
||||||
attr <- attributes
|
pub <- publications
|
||||||
} yield {
|
} yield {
|
||||||
val dep0 = dep
|
val dep0 = dep
|
||||||
.withConfiguration(to)
|
.withConfiguration(to)
|
||||||
.withAttributes(attr)
|
.withPublication(pub)
|
||||||
from -> dep0
|
from -> dep0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,26 @@ final class Dependency private (
|
||||||
val version: String,
|
val version: String,
|
||||||
val configuration: Configuration,
|
val configuration: Configuration,
|
||||||
val exclusions: Set[(Organization, ModuleName)],
|
val exclusions: Set[(Organization, ModuleName)],
|
||||||
val attributes: Attributes,
|
val publication: Publication,
|
||||||
val optional: Boolean,
|
val optional: Boolean,
|
||||||
val transitive: Boolean) extends Serializable {
|
val transitive: Boolean) extends Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
def attributes: Attributes =
|
||||||
|
publication.attributes
|
||||||
|
|
||||||
override def equals(o: Any): Boolean = o match {
|
override def equals(o: Any): Boolean = o match {
|
||||||
case x: Dependency => (this.module == x.module) && (this.version == x.version) && (this.configuration == x.configuration) && (this.exclusions == x.exclusions) && (this.attributes == x.attributes) && (this.optional == x.optional) && (this.transitive == x.transitive)
|
case x: Dependency => (this.module == x.module) && (this.version == x.version) && (this.configuration == x.configuration) && (this.exclusions == x.exclusions) && (this.publication == x.publication) && (this.optional == x.optional) && (this.transitive == x.transitive)
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
}
|
||||||
override def hashCode: Int = {
|
override def hashCode: Int = {
|
||||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Dependency".##) + module.##) + version.##) + configuration.##) + exclusions.##) + attributes.##) + optional.##) + transitive.##)
|
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Dependency".##) + module.##) + version.##) + configuration.##) + exclusions.##) + publication.##) + optional.##) + transitive.##)
|
||||||
}
|
}
|
||||||
override def toString: String = {
|
override def toString: String = {
|
||||||
"Dependency(" + module + ", " + version + ", " + configuration + ", " + exclusions + ", " + attributes + ", " + optional + ", " + transitive + ")"
|
"Dependency(" + module + ", " + version + ", " + configuration + ", " + exclusions + ", " + publication + ", " + optional + ", " + transitive + ")"
|
||||||
}
|
}
|
||||||
private[this] def copy(module: Module = module, version: String = version, configuration: Configuration = configuration, exclusions: Set[(Organization, ModuleName)] = exclusions, attributes: Attributes = attributes, optional: Boolean = optional, transitive: Boolean = transitive): Dependency = {
|
private[this] def copy(module: Module = module, version: String = version, configuration: Configuration = configuration, exclusions: Set[(Organization, ModuleName)] = exclusions, publication: Publication = publication, optional: Boolean = optional, transitive: Boolean = transitive): Dependency = {
|
||||||
new Dependency(module, version, configuration, exclusions, attributes, optional, transitive)
|
new Dependency(module, version, configuration, exclusions, publication, optional, transitive)
|
||||||
}
|
}
|
||||||
def withModule(module: Module): Dependency = {
|
def withModule(module: Module): Dependency = {
|
||||||
copy(module = module)
|
copy(module = module)
|
||||||
|
|
@ -40,8 +42,14 @@ final class Dependency private (
|
||||||
def withExclusions(exclusions: Set[(Organization, ModuleName)]): Dependency = {
|
def withExclusions(exclusions: Set[(Organization, ModuleName)]): Dependency = {
|
||||||
copy(exclusions = exclusions)
|
copy(exclusions = exclusions)
|
||||||
}
|
}
|
||||||
def withAttributes(attributes: Attributes): Dependency = {
|
def withAttributes(attributes: Attributes): Dependency =
|
||||||
copy(attributes = attributes)
|
copy(
|
||||||
|
publication = publication
|
||||||
|
.withType(attributes.`type`)
|
||||||
|
.withClassifier(attributes.classifier)
|
||||||
|
)
|
||||||
|
def withPublication(publication: Publication): Dependency = {
|
||||||
|
copy(publication = publication)
|
||||||
}
|
}
|
||||||
def withOptional(optional: Boolean): Dependency = {
|
def withOptional(optional: Boolean): Dependency = {
|
||||||
copy(optional = optional)
|
copy(optional = optional)
|
||||||
|
|
@ -52,5 +60,6 @@ final class Dependency private (
|
||||||
}
|
}
|
||||||
object Dependency {
|
object Dependency {
|
||||||
|
|
||||||
def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], attributes: Attributes, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, attributes, optional, transitive)
|
def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], attributes: Attributes, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, Publication("", attributes.`type`, Extension(""), attributes.classifier), optional, transitive)
|
||||||
|
def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], publication: Publication, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, publication, optional, transitive)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ final class Publication private (
|
||||||
val ext: Extension,
|
val ext: Extension,
|
||||||
val classifier: Classifier) extends Serializable {
|
val classifier: Classifier) extends Serializable {
|
||||||
|
|
||||||
|
def attributes: Attributes =
|
||||||
|
Attributes(`type`, classifier)
|
||||||
|
|
||||||
override def equals(o: Any): Boolean = o match {
|
override def equals(o: Any): Boolean = o match {
|
||||||
case x: Publication => (this.name == x.name) && (this.`type` == x.`type`) && (this.ext == x.ext) && (this.classifier == x.classifier)
|
case x: Publication => (this.name == x.name) && (this.`type` == x.`type`) && (this.ext == x.ext) && (this.classifier == x.classifier)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ object ToCoursier {
|
||||||
case (org, name) =>
|
case (org, name) =>
|
||||||
(coursier.core.Organization(org.value), coursier.core.ModuleName(name.value))
|
(coursier.core.Organization(org.value), coursier.core.ModuleName(name.value))
|
||||||
},
|
},
|
||||||
attributes(dependency.attributes),
|
publication(dependency.publication),
|
||||||
dependency.optional,
|
dependency.optional,
|
||||||
dependency.transitive
|
dependency.transitive
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,6 @@ final class TemporaryInMemoryRepository private(
|
||||||
.fold[Either[String, (Artifact.Source, Project)]](Left("No fallback URL found")) {
|
.fold[Either[String, (Artifact.Source, Project)]](Left("No fallback URL found")) {
|
||||||
case (url, _) =>
|
case (url, _) =>
|
||||||
|
|
||||||
println(s"($module, $version) -> $url")
|
|
||||||
|
|
||||||
val urlStr = url.toExternalForm
|
val urlStr = url.toExternalForm
|
||||||
val idx = urlStr.lastIndexOf('/')
|
val idx = urlStr.lastIndexOf('/')
|
||||||
|
|
||||||
|
|
@ -160,7 +158,6 @@ final class TemporaryInMemoryRepository private(
|
||||||
val (dirUrlStr, fileName) = urlStr.splitAt(idx + 1)
|
val (dirUrlStr, fileName) = urlStr.splitAt(idx + 1)
|
||||||
|
|
||||||
if (TemporaryInMemoryRepository.exists(url, localArtifactsShouldBeCached, cacheOpt)) {
|
if (TemporaryInMemoryRepository.exists(url, localArtifactsShouldBeCached, cacheOpt)) {
|
||||||
println("returning proj")
|
|
||||||
val proj = Project(
|
val proj = Project(
|
||||||
module,
|
module,
|
||||||
version,
|
version,
|
||||||
|
|
@ -194,13 +191,11 @@ final class TemporaryInMemoryRepository private(
|
||||||
project: Project,
|
project: Project,
|
||||||
overrideClassifiers: Option[Seq[Classifier]]
|
overrideClassifiers: Option[Seq[Classifier]]
|
||||||
): Seq[(Publication, Artifact)] = {
|
): Seq[(Publication, Artifact)] = {
|
||||||
println(s"artifacts($dependency)")
|
|
||||||
fallbacks
|
fallbacks
|
||||||
.get(dependency.moduleVersion)
|
.get(dependency.moduleVersion)
|
||||||
.toSeq
|
.toSeq
|
||||||
.map {
|
.map {
|
||||||
case (url, changing) =>
|
case (url, changing) =>
|
||||||
println(s"$url, $changing")
|
|
||||||
val url0 = url.toString
|
val url0 = url.toString
|
||||||
val ext = url0.substring(url0.lastIndexOf('.') + 1)
|
val ext = url0.substring(url0.lastIndexOf('.') + 1)
|
||||||
val pub = Publication(
|
val pub = Publication(
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Adapted from https://github.com/sbt/sbt/tree/57a86e60f6d7c6fd428fb73a6786b62972fdae54/sbt/src/sbt-test/dependency-management/default-artifact
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
resolvers += Resolver.file("buggy", file("repo"))(
|
||||||
|
Patterns(
|
||||||
|
ivyPatterns = Vector("[organization]/[module]/[revision]/ivy.xml"),
|
||||||
|
artifactPatterns = Vector("[organization]/[module]/[revision]/[artifact].[ext]"),
|
||||||
|
isMavenCompatible = false,
|
||||||
|
descriptorOptional = true,
|
||||||
|
skipConsistencyCheck = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
libraryDependencies += "a" % "b" % "1.0.0" % "compile->runtime" artifacts(Artifact("b1", "jar", "jar"))
|
||||||
|
libraryDependencies += "a" % "b" % "1.0.0" % "test->runtime" artifacts(Artifact("b1", "jar", "jar"))
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
addSbtPlugin {
|
||||||
|
|
||||||
|
val name = sys.props.getOrElse(
|
||||||
|
"plugin.name",
|
||||||
|
sys.error("plugin.name Java property not set")
|
||||||
|
)
|
||||||
|
val version = sys.props.getOrElse(
|
||||||
|
"plugin.version",
|
||||||
|
sys.error("plugin.version Java property not set")
|
||||||
|
)
|
||||||
|
|
||||||
|
"io.get-coursier" % name % version
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,14 @@
|
||||||
|
<ivy-module xmlns:e="http://ant.apache.org/ivy/extra" version="2.0">
|
||||||
|
<info organisation="a" module="b" revision="1.0.0" status="release" publication="20160201120702">
|
||||||
|
<description>a</description>
|
||||||
|
</info>
|
||||||
|
<configurations>
|
||||||
|
<conf name="runtime" description="..."/>
|
||||||
|
</configurations>
|
||||||
|
<publications>
|
||||||
|
<artifact name="b1" type="jar" ext="jar" conf="runtime"/>
|
||||||
|
<artifact name="fake" type="jar" ext="jar" conf="runtime"/>
|
||||||
|
</publications>
|
||||||
|
<dependencies>
|
||||||
|
</dependencies>
|
||||||
|
</ivy-module>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Verify that we successfully get the artifacts.
|
||||||
|
# This project depends on a module for which we cannot generate a "default artifact",
|
||||||
|
# because no such artifact exists.
|
||||||
|
|
||||||
|
> update
|
||||||
Loading…
Reference in New Issue