mirror of https://github.com/sbt/sbt.git
Keep version actually used to fetch metadata, to get artifacts
In case the one given by the metadata is wrong
This commit is contained in:
parent
3ffba8b974
commit
2ddfe5f3b2
|
|
@ -146,6 +146,12 @@ lazy val core = crossProject
|
|||
import com.typesafe.tools.mima.core.ProblemFilters._
|
||||
|
||||
Seq(
|
||||
// Since 1.0.0-M13
|
||||
// Extra `actualVersion` field in `Project`
|
||||
ProblemFilters.exclude[MissingTypesProblem]("coursier.core.Project$"),
|
||||
ProblemFilters.exclude[MissingMethodProblem]("coursier.core.Project.apply"),
|
||||
ProblemFilters.exclude[MissingMethodProblem]("coursier.core.Project.copy"),
|
||||
ProblemFilters.exclude[MissingMethodProblem]("coursier.core.Project.this"),
|
||||
// Since 1.0.0-M12
|
||||
// Extra `authentication` field
|
||||
ProblemFilters.exclude[MissingMethodProblem]("coursier.core.Artifact.apply"),
|
||||
|
|
|
|||
|
|
@ -81,6 +81,11 @@ final case class Project(
|
|||
profiles: Seq[Profile],
|
||||
versions: Option[Versions],
|
||||
snapshotVersioning: Option[SnapshotVersioning],
|
||||
/**
|
||||
* Optional exact version used to get this project metadata.
|
||||
* May not match `version` for projects having a wrong version in their metadata.
|
||||
*/
|
||||
actualVersionOpt: Option[String],
|
||||
|
||||
// Ivy-specific
|
||||
// First String is configuration
|
||||
|
|
@ -94,6 +99,13 @@ final case class Project(
|
|||
/** All configurations that each configuration extends, including the ones it extends transitively */
|
||||
lazy val allConfigurations: Map[String, Set[String]] =
|
||||
Orders.allConfigurations(configurations)
|
||||
|
||||
/**
|
||||
* Version used to get this project metadata if available, else the version from metadata.
|
||||
* May not match `version` for projects having a wrong version in their metadata, if the actual version was kept
|
||||
* around.
|
||||
*/
|
||||
def actualVersion: String = actualVersionOpt.getOrElse(version)
|
||||
}
|
||||
|
||||
/** Extra project info, not used during resolution */
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ object IvyXml {
|
|||
Nil,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
if (publicationsOpt.isEmpty)
|
||||
// no publications node -> default JAR artifact
|
||||
Seq("*" -> Publication(module.name, "jar", "jar", ""))
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ case class MavenRepository(
|
|||
}
|
||||
}
|
||||
|
||||
F.bind(findVersioning(module, version, None, fetch).run) { eitherProj =>
|
||||
val res = F.bind(findVersioning(module, version, None, fetch).run) { eitherProj =>
|
||||
if (eitherProj.isLeft && version.contains("-SNAPSHOT"))
|
||||
F.map(withSnapshotVersioning.run)(eitherProj0 =>
|
||||
if (eitherProj0.isLeft)
|
||||
|
|
@ -233,6 +233,9 @@ case class MavenRepository(
|
|||
else
|
||||
F.point(eitherProj)
|
||||
}
|
||||
|
||||
// keep exact version used to get metadata, in case the one inside the metadata is wrong
|
||||
F.map(res)(_.map(proj => proj.copy(actualVersionOpt = Some(version))))
|
||||
}
|
||||
|
||||
def findVersioning[F[_]](
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ case class MavenSource(
|
|||
|
||||
val path = dependency.module.organization.split('.').toSeq ++ Seq(
|
||||
MavenRepository.dirModuleName(dependency.module, sbtAttrStub),
|
||||
project.version,
|
||||
s"${dependency.module.name}-${versioning getOrElse project.version}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
|
||||
project.actualVersion,
|
||||
s"${dependency.module.name}-${versioning getOrElse project.actualVersion}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
|
||||
)
|
||||
|
||||
val changing0 = changing.getOrElse(project.version.contains("-SNAPSHOT"))
|
||||
val changing0 = changing.getOrElse(project.actualVersion.contains("-SNAPSHOT"))
|
||||
var artifact =
|
||||
Artifact(
|
||||
root + path.mkString("/"),
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ object Pom {
|
|||
profiles,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Nil,
|
||||
Info(
|
||||
description,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ case class FallbackDependenciesRepository(
|
|||
Nil,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Nil,
|
||||
Info.empty
|
||||
)
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ object FromSbt {
|
|||
Nil,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Nil,
|
||||
Info.empty
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
org.apache.ws.commons:XmlSchema:1.1:compile
|
||||
stax:stax-api:1.0:compile
|
||||
|
|
@ -72,7 +72,7 @@ object CentralTests extends TestSuite {
|
|||
.get(dep.moduleVersion)
|
||||
.map { case (_, proj) => proj }
|
||||
val dep0 = dep.copy(
|
||||
version = projOpt.fold(dep.version)(_.version)
|
||||
version = projOpt.fold(dep.version)(_.actualVersion)
|
||||
)
|
||||
(dep0.module.organization, dep0.module.nameWithAttributes, dep0.version, dep0.configuration)
|
||||
}
|
||||
|
|
@ -89,13 +89,13 @@ object CentralTests extends TestSuite {
|
|||
assert(result == expected)
|
||||
}
|
||||
|
||||
def ensureArtifactHasExtension(module: Module, version: String, extension: String): Future[Unit] = async {
|
||||
def withArtifact[T](module: Module, version: String)(f: Artifact => T): Future[T] = async {
|
||||
val dep = Dependency(module, version, transitive = false)
|
||||
val res = await(resolve(Set(dep)))
|
||||
|
||||
res.artifacts match {
|
||||
case Seq(artifact) =>
|
||||
assert(artifact.url.endsWith("." + extension))
|
||||
f(artifact)
|
||||
case other =>
|
||||
throw new Exception(
|
||||
s"Unexpected artifact list size: ${other.size}\n" +
|
||||
|
|
@ -104,6 +104,11 @@ object CentralTests extends TestSuite {
|
|||
}
|
||||
}
|
||||
|
||||
def ensureArtifactHasExtension(module: Module, version: String, extension: String): Future[Unit] =
|
||||
withArtifact(module, version) { artifact =>
|
||||
assert(artifact.url.endsWith("." + extension))
|
||||
}
|
||||
|
||||
val tests = TestSuite {
|
||||
|
||||
'logback - {
|
||||
|
|
@ -232,6 +237,18 @@ object CentralTests extends TestSuite {
|
|||
)
|
||||
}
|
||||
|
||||
'versionFromDependency - {
|
||||
val mod = Module("org.apache.ws.commons", "XmlSchema")
|
||||
val version = "1.1"
|
||||
val expectedArtifactUrl = "https://repo1.maven.org/maven2/org/apache/ws/commons/XmlSchema/1.1/XmlSchema-1.1.jar"
|
||||
|
||||
* - resolutionCheck(mod, version)
|
||||
|
||||
* - withArtifact(mod, version) { artifact =>
|
||||
assert(artifact.url == expectedArtifactUrl)
|
||||
}
|
||||
}
|
||||
|
||||
'mavenScopes - {
|
||||
def check(config: String) = resolutionCheck(
|
||||
Module("com.android.tools", "sdklib"),
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ package object test {
|
|||
profiles,
|
||||
versions,
|
||||
snapshotVersioning,
|
||||
None,
|
||||
publications,
|
||||
Info.empty
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue