mirror of https://github.com/sbt/sbt.git
Always try to get artifacts corresponding to packaging
This commit is contained in:
parent
d4cb232e65
commit
bddf67cc17
|
|
@ -64,6 +64,9 @@ final case class Attributes(
|
|||
) {
|
||||
def publication(name: String, ext: String): Publication =
|
||||
Publication(name, `type`, ext, classifier)
|
||||
|
||||
def isEmpty: Boolean =
|
||||
`type`.isEmpty && classifier.isEmpty
|
||||
}
|
||||
|
||||
final case class Project(
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ final case class MavenSource(
|
|||
overrideClassifiers: Option[Seq[String]]
|
||||
): Seq[Artifact] = {
|
||||
|
||||
val packagingTpeMap = project.packagingOpt
|
||||
.filter(_ != Pom.relocatedPackaging)
|
||||
val packagingOpt = project.packagingOpt.filter(_ != Pom.relocatedPackaging)
|
||||
|
||||
val packagingTpeMap = packagingOpt
|
||||
.map { packaging =>
|
||||
(MavenSource.typeDefaultClassifier(packaging), MavenSource.typeExtension(packaging)) -> packaging
|
||||
}
|
||||
|
|
@ -67,7 +68,18 @@ final case class MavenSource(
|
|||
)
|
||||
}
|
||||
|
||||
lazy val defaultPublication = {
|
||||
lazy val defaultPublications = {
|
||||
|
||||
val packagingPublicationOpt = packagingOpt
|
||||
.filter(_ => dependency.attributes.isEmpty)
|
||||
.map { packaging =>
|
||||
Publication(
|
||||
dependency.module.name,
|
||||
packaging,
|
||||
MavenSource.typeExtension(packaging),
|
||||
MavenSource.typeDefaultClassifier(packaging)
|
||||
)
|
||||
}
|
||||
|
||||
val type0 = if (dependency.attributes.`type`.isEmpty) "jar" else dependency.attributes.`type`
|
||||
|
||||
|
|
@ -84,41 +96,41 @@ final case class MavenSource(
|
|||
MavenSource.classifierExtensionDefaultTypeOpt(classifier, ext).getOrElse(ext)
|
||||
)
|
||||
|
||||
Publication(
|
||||
dependency.module.name,
|
||||
tpe,
|
||||
ext,
|
||||
classifier
|
||||
)
|
||||
val pubs = packagingPublicationOpt.toSeq :+
|
||||
Publication(
|
||||
dependency.module.name,
|
||||
tpe,
|
||||
ext,
|
||||
classifier
|
||||
)
|
||||
|
||||
pubs.distinct
|
||||
}
|
||||
|
||||
overrideClassifiers match {
|
||||
case Some(classifiers) =>
|
||||
|
||||
classifiers
|
||||
.map { classifier =>
|
||||
if (classifier == dependency.attributes.classifier)
|
||||
defaultPublication
|
||||
else {
|
||||
val ext = "jar"
|
||||
val tpe = packagingTpeMap.getOrElse(
|
||||
(classifier, ext),
|
||||
MavenSource.classifierExtensionDefaultTypeOpt(classifier, ext).getOrElse(ext)
|
||||
)
|
||||
overrideClassifiers
|
||||
.fold(defaultPublications) { classifiers =>
|
||||
classifiers.flatMap { classifier =>
|
||||
if (classifier == dependency.attributes.classifier)
|
||||
defaultPublications
|
||||
else {
|
||||
val ext = "jar"
|
||||
val tpe = packagingTpeMap.getOrElse(
|
||||
(classifier, ext),
|
||||
MavenSource.classifierExtensionDefaultTypeOpt(classifier, ext).getOrElse(ext)
|
||||
)
|
||||
|
||||
Seq(
|
||||
Publication(
|
||||
dependency.module.name,
|
||||
tpe,
|
||||
ext,
|
||||
classifier
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
.map(artifactWithExtra)
|
||||
|
||||
case None =>
|
||||
Seq(defaultPublication).map(artifactWithExtra)
|
||||
}
|
||||
}
|
||||
}
|
||||
.map(artifactWithExtra)
|
||||
}
|
||||
|
||||
private val types = Map("sha1" -> "SHA-1", "md5" -> "MD5", "asc" -> "sig")
|
||||
|
|
@ -290,14 +302,14 @@ final case class MavenSource(
|
|||
}
|
||||
|
||||
val defaultPublications = artifactsUnknownPublications(dependency, project, overrideClassifiers)
|
||||
.map(makeOptional)
|
||||
|
||||
if (project.publications.isEmpty)
|
||||
defaultPublications
|
||||
else {
|
||||
val listedPublications = artifactsKnownPublications(dependency, project, overrideClassifiers)
|
||||
val listedUrls = listedPublications.map(_.url).toSet
|
||||
val defaultPublications0 = defaultPublications.map(makeOptional)
|
||||
val defaultPublicationsMap = defaultPublications0
|
||||
val defaultPublicationsMap = defaultPublications
|
||||
.map(a => a.url -> a)
|
||||
.toMap
|
||||
val listedPublications0 = listedPublications.map { a =>
|
||||
|
|
@ -305,7 +317,7 @@ final case class MavenSource(
|
|||
.get(a.url)
|
||||
.fold(a)(merge(a, _))
|
||||
}
|
||||
val extraPublications = defaultPublications0
|
||||
val extraPublications = defaultPublications
|
||||
.filter(a => !listedUrls(a.url))
|
||||
|
||||
listedPublications0 ++ extraPublications
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 93eccec4ffd1719586b6f1e1dddefcbea6722e7d
|
||||
Subproject commit 6b2578a25220930e60b505b90e636092757d6397
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
android.arch.core:core:1.0.0-alpha3:compile
|
||||
android.arch.lifecycle:common:1.0.0-alpha3:compile
|
||||
android.arch.lifecycle:extensions:1.0.0-alpha3:compile
|
||||
android.arch.lifecycle:runtime:1.0.0-alpha3:compile
|
||||
com.android.support:support-annotations:25.3.1:compile
|
||||
com.android.support:support-compat:25.3.1:compile
|
||||
com.android.support:support-core-ui:25.3.1:compile
|
||||
com.android.support:support-core-utils:25.3.1:compile
|
||||
com.android.support:support-fragment:25.3.1:compile
|
||||
com.android.support:support-media-compat:25.3.1:compile
|
||||
|
|
@ -822,6 +822,33 @@ abstract class CentralTests extends TestSuite {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
'packagingTpe - {
|
||||
val mod = Module("android.arch.lifecycle", "extensions")
|
||||
val ver = "1.0.0-alpha3"
|
||||
|
||||
val extraRepo = MavenRepository("https://maven.google.com")
|
||||
|
||||
* - resolutionCheck(mod, ver, extraRepos = Seq(extraRepo))
|
||||
|
||||
* - withArtifacts(mod, ver, "*", extraRepos = Seq(extraRepo), transitive = true) { artifacts =>
|
||||
val urls = artifacts.map(_.url).toSet
|
||||
val expectedUrls = Set(
|
||||
"https://maven.google.com/com/android/support/support-fragment/25.3.1/support-fragment-25.3.1.aar",
|
||||
"https://maven.google.com/android/arch/core/core/1.0.0-alpha3/core-1.0.0-alpha3.aar",
|
||||
"https://maven.google.com/android/arch/lifecycle/runtime/1.0.0-alpha3/runtime-1.0.0-alpha3.aar",
|
||||
"https://maven.google.com/android/arch/lifecycle/extensions/1.0.0-alpha3/extensions-1.0.0-alpha3.aar",
|
||||
"https://maven.google.com/com/android/support/support-compat/25.3.1/support-compat-25.3.1.aar",
|
||||
"https://maven.google.com/com/android/support/support-media-compat/25.3.1/support-media-compat-25.3.1.aar",
|
||||
"https://maven.google.com/com/android/support/support-core-ui/25.3.1/support-core-ui-25.3.1.aar",
|
||||
"https://maven.google.com/com/android/support/support-core-utils/25.3.1/support-core-utils-25.3.1.aar",
|
||||
"https://maven.google.com/com/android/support/support-annotations/25.3.1/support-annotations-25.3.1.jar",
|
||||
"https://maven.google.com/android/arch/lifecycle/common/1.0.0-alpha3/common-1.0.0-alpha3.jar"
|
||||
)
|
||||
|
||||
assert(expectedUrls.forall(urls))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue