mirror of https://github.com/sbt/sbt.git
Better handling of snapshot versioning
This commit is contained in:
parent
d5d84cb336
commit
ab9341ac9b
|
|
@ -9,6 +9,16 @@ import scala.language.higherKinds
|
||||||
import scalaz._
|
import scalaz._
|
||||||
|
|
||||||
object MavenRepository {
|
object MavenRepository {
|
||||||
|
val SnapshotTimestamp = "(.*-)?[0-9]{8}\\.[0-9]{6}-[0-9]+".r
|
||||||
|
|
||||||
|
def isSnapshot(version: String): Boolean =
|
||||||
|
version.endsWith("SNAPSHOT") || SnapshotTimestamp.findFirstIn(version).nonEmpty
|
||||||
|
|
||||||
|
def toBaseVersion(version: String): String = version match {
|
||||||
|
case SnapshotTimestamp(null) => "SNAPSHOT"
|
||||||
|
case SnapshotTimestamp(base) => base + "SNAPSHOT"
|
||||||
|
case _ => version
|
||||||
|
}
|
||||||
|
|
||||||
def ivyLikePath(
|
def ivyLikePath(
|
||||||
org: String,
|
org: String,
|
||||||
|
|
@ -80,7 +90,7 @@ final case class MavenRepository(
|
||||||
module.organization.split('.').toSeq :+ dirModuleName(module, sbtAttrStub)
|
module.organization.split('.').toSeq :+ dirModuleName(module, sbtAttrStub)
|
||||||
|
|
||||||
private def moduleVersionPath(module: Module, version: String): Seq[String] =
|
private def moduleVersionPath(module: Module, version: String): Seq[String] =
|
||||||
modulePath(module) :+ version
|
modulePath(module) :+ toBaseVersion(version)
|
||||||
|
|
||||||
private def urlFor(path: Seq[String]): String =
|
private def urlFor(path: Seq[String]): String =
|
||||||
root0 + path.map(encodeURIComponent).mkString("/")
|
root0 + path.map(encodeURIComponent).mkString("/")
|
||||||
|
|
@ -99,7 +109,7 @@ final case class MavenRepository(
|
||||||
Map.empty,
|
Map.empty,
|
||||||
Map.empty,
|
Map.empty,
|
||||||
Attributes("pom", ""),
|
Attributes("pom", ""),
|
||||||
changing = changing.getOrElse(version.contains("-SNAPSHOT")),
|
changing = changing.getOrElse(isSnapshot(version)),
|
||||||
authentication = authentication
|
authentication = authentication
|
||||||
)
|
)
|
||||||
.withDefaultChecksums
|
.withDefaultChecksums
|
||||||
|
|
@ -253,6 +263,7 @@ final case class MavenRepository(
|
||||||
snapshotVersioning(module, version, fetch).flatMap { snapshotVersioning =>
|
snapshotVersioning(module, version, fetch).flatMap { snapshotVersioning =>
|
||||||
val versioningOption =
|
val versioningOption =
|
||||||
mavenVersioning(snapshotVersioning, "", "jar")
|
mavenVersioning(snapshotVersioning, "", "jar")
|
||||||
|
.orElse(mavenVersioning(snapshotVersioning, "", "pom"))
|
||||||
.orElse(mavenVersioning(snapshotVersioning, "", ""))
|
.orElse(mavenVersioning(snapshotVersioning, "", ""))
|
||||||
|
|
||||||
versioningOption match {
|
versioningOption match {
|
||||||
|
|
@ -267,7 +278,7 @@ final case class MavenRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
val res = 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"))
|
if (eitherProj.isLeft && isSnapshot(version))
|
||||||
F.map(withSnapshotVersioning.run)(eitherProj0 =>
|
F.map(withSnapshotVersioning.run)(eitherProj0 =>
|
||||||
if (eitherProj0.isLeft)
|
if (eitherProj0.isLeft)
|
||||||
eitherProj
|
eitherProj
|
||||||
|
|
@ -332,6 +343,8 @@ final case class MavenRepository(
|
||||||
|
|
||||||
val listFilesUrl = urlFor(moduleVersionPath(module, version)) + "/"
|
val listFilesUrl = urlFor(moduleVersionPath(module, version)) + "/"
|
||||||
|
|
||||||
|
val changing0 = changing.getOrElse(isSnapshot(version))
|
||||||
|
|
||||||
val listFilesArtifact =
|
val listFilesArtifact =
|
||||||
Artifact(
|
Artifact(
|
||||||
listFilesUrl,
|
listFilesUrl,
|
||||||
|
|
@ -340,7 +353,7 @@ final case class MavenRepository(
|
||||||
"metadata" -> projectArtifact0
|
"metadata" -> projectArtifact0
|
||||||
),
|
),
|
||||||
Attributes("", ""),
|
Attributes("", ""),
|
||||||
changing = changing.getOrElse(version.contains("-SNAPSHOT")),
|
changing = changing0,
|
||||||
authentication
|
authentication
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -356,7 +369,7 @@ final case class MavenRepository(
|
||||||
|
|
||||||
for {
|
for {
|
||||||
str <- fetch(requiringDirListingProjectArtifact)
|
str <- fetch(requiringDirListingProjectArtifact)
|
||||||
rawListFilesPageOpt <- EitherT(F.map(fetch(artifactFor(listFilesUrl, changing.getOrElse(version.contains("-SNAPSHOT")))).run) {
|
rawListFilesPageOpt <- EitherT(F.map(fetch(artifactFor(listFilesUrl, changing0)).run) {
|
||||||
e => \/-(e.toOption): String \/ Option[String]
|
e => \/-(e.toOption): String \/ Option[String]
|
||||||
})
|
})
|
||||||
proj0 <- EitherT(F.point[String \/ Project](parseRawPom(str)))
|
proj0 <- EitherT(F.point[String \/ Project](parseRawPom(str)))
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ final case class MavenSource(
|
||||||
|
|
||||||
val path = dependency.module.organization.split('.').toSeq ++ Seq(
|
val path = dependency.module.organization.split('.').toSeq ++ Seq(
|
||||||
MavenRepository.dirModuleName(dependency.module, sbtAttrStub),
|
MavenRepository.dirModuleName(dependency.module, sbtAttrStub),
|
||||||
project.actualVersion,
|
toBaseVersion(project.actualVersion),
|
||||||
s"${dependency.module.name}-${versioning getOrElse project.actualVersion}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
|
s"${dependency.module.name}-${versioning getOrElse project.actualVersion}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
|
||||||
)
|
)
|
||||||
|
|
||||||
val changing0 = changing.getOrElse(project.actualVersion.contains("-SNAPSHOT"))
|
val changing0 = changing.getOrElse(isSnapshot(project.actualVersion))
|
||||||
var artifact =
|
var artifact =
|
||||||
Artifact(
|
Artifact(
|
||||||
root + path.mkString("/"),
|
root + path.mkString("/"),
|
||||||
|
|
@ -149,7 +149,7 @@ final case class MavenSource(
|
||||||
s"${dependency.module.name}-${versioning getOrElse project.actualVersion}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
|
s"${dependency.module.name}-${versioning getOrElse project.actualVersion}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
|
||||||
)
|
)
|
||||||
|
|
||||||
val changing0 = changing.getOrElse(project.actualVersion.contains("-SNAPSHOT"))
|
val changing0 = changing.getOrElse(isSnapshot(project.actualVersion))
|
||||||
|
|
||||||
val extra0 = extra.mapValues(_.artifact(versioningType)).iterator.toMap
|
val extra0 = extra.mapValues(_.artifact(versioningType)).iterator.toMap
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue