Remove "ivy-like" Maven repository support

Was a workaround for ~/.ivy2/local, before support for Ivy repositories was added
This commit is contained in:
Alexandre Archambault 2015-12-31 16:34:00 +01:00
parent cf269c6895
commit ac23e17c49
4 changed files with 59 additions and 103 deletions

View File

@ -67,12 +67,9 @@ class Helper(
val pool = Executors.newFixedThreadPool(parallel, Strategy.DefaultDaemonThreadFactory)
val central = MavenRepository("https://repo1.maven.org/maven2/")
val ivy2Local = MavenRepository(
new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString,
ivyLike = true
)
val defaultRepositories = Seq(
ivy2Local,
Cache.ivy2Local,
central
)
@ -81,7 +78,7 @@ class Helper(
if (repo0 == "central")
Right(central)
else if (repo0 == "ivy2local")
Right(ivy2Local)
Right(Cache.ivy2Local)
else if (repo0.startsWith("sonatype:"))
Right(
MavenRepository(s"https://oss.sonatype.org/content/repositories/${repo.drop("sonatype:".length)}")
@ -91,12 +88,8 @@ class Helper(
if (repo.startsWith("ivy:")) {
val url = repo.drop("ivy:".length)
(url, IvyRepository(url))
} else if (repo.startsWith("ivy-like:")) {
val url = repo.drop("ivy-like:".length)
(url, MavenRepository(url, ivyLike = true))
} else {
} else
(repo, MavenRepository(repo))
}
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("file:/"))
Right(r)

View File

@ -60,7 +60,6 @@ object MavenRepository {
case class MavenRepository(
root: String,
ivyLike: Boolean = false,
changing: Option[Boolean] = None,
/** Hackish hack for sbt plugins mainly - what this does really sucks */
sbtAttrStub: Boolean = false
@ -70,7 +69,7 @@ case class MavenRepository(
import MavenRepository._
val root0 = if (root.endsWith("/")) root else root + "/"
val source = MavenSource(root0, ivyLike, changing, sbtAttrStub)
val source = MavenSource(root0, changing, sbtAttrStub)
def projectArtifact(
module: Module,
@ -78,27 +77,14 @@ case class MavenRepository(
versioningValue: Option[String]
): Artifact = {
val path = (
if (ivyLike)
ivyLikePath(
module.organization,
dirModuleName(module, sbtAttrStub), // maybe not what we should do here, don't know
module.name,
versioningValue getOrElse version,
"poms",
"",
"pom"
)
else
module.organization.split('.').toSeq ++ Seq(
dirModuleName(module, sbtAttrStub),
version,
s"${module.name}-${versioningValue getOrElse version}.pom"
)
) .map(encodeURIComponent)
val path = module.organization.split('.').toSeq ++ Seq(
dirModuleName(module, sbtAttrStub),
version,
s"${module.name}-${versioningValue getOrElse version}.pom"
)
Artifact(
root0 + path.mkString("/"),
root0 + path.map(encodeURIComponent).mkString("/"),
Map.empty,
Map.empty,
Attributes("pom", ""),
@ -108,57 +94,51 @@ case class MavenRepository(
.withDefaultSignature
}
def versionsArtifact(module: Module): Option[Artifact] =
if (ivyLike) None
else {
val path = (
module.organization.split('.').toSeq ++ Seq(
dirModuleName(module, sbtAttrStub),
"maven-metadata.xml"
)
) .map(encodeURIComponent)
def versionsArtifact(module: Module): Option[Artifact] = {
val artifact =
Artifact(
root0 + path.mkString("/"),
Map.empty,
Map.empty,
Attributes("pom", ""),
changing = true
)
.withDefaultChecksums
.withDefaultSignature
val path = module.organization.split('.').toSeq ++ Seq(
dirModuleName(module, sbtAttrStub),
"maven-metadata.xml"
)
Some(artifact)
}
val artifact =
Artifact(
root0 + path.map(encodeURIComponent).mkString("/"),
Map.empty,
Map.empty,
Attributes("pom", ""),
changing = true
)
.withDefaultChecksums
.withDefaultSignature
Some(artifact)
}
def snapshotVersioningArtifact(
module: Module,
version: String
): Option[Artifact] =
if (ivyLike) None
else {
val path = (
module.organization.split('.').toSeq ++ Seq(
dirModuleName(module, sbtAttrStub),
version,
"maven-metadata.xml"
)
) .map(encodeURIComponent)
): Option[Artifact] = {
val artifact =
Artifact(
root0 + path.mkString("/"),
Map.empty,
Map.empty,
Attributes("pom", ""),
changing = true
)
.withDefaultChecksums
.withDefaultSignature
val path = module.organization.split('.').toSeq ++ Seq(
dirModuleName(module, sbtAttrStub),
version,
"maven-metadata.xml"
)
Some(artifact)
}
val artifact =
Artifact(
root0 + path.map(encodeURIComponent).mkString("/"),
Map.empty,
Map.empty,
Attributes("pom", ""),
changing = true
)
.withDefaultChecksums
.withDefaultSignature
Some(artifact)
}
def versions[F[_]](
module: Module,

View File

@ -4,7 +4,6 @@ import coursier.core._
case class MavenSource(
root: String,
ivyLike: Boolean,
changing: Option[Boolean] = None,
/** See doc on MavenRepository */
sbtAttrStub: Boolean
@ -46,34 +45,18 @@ case class MavenSource(
): Seq[Artifact] = {
def artifactOf(module: Module, publication: Publication) = {
def ivyLikePath0(subDir: String, baseSuffix: String, ext: String) =
ivyLikePath(
module.organization,
MavenRepository.dirModuleName(module, sbtAttrStub),
module.name,
project.version,
subDir,
baseSuffix,
ext
val versioning = project
.snapshotVersioning
.flatMap(versioning =>
mavenVersioning(versioning, publication.classifier, publication.`type`)
)
val path =
if (ivyLike)
ivyLikePath0(publication.`type` + "s", "", publication.ext)
else {
val versioning =
project
.snapshotVersioning
.flatMap(versioning =>
mavenVersioning(versioning, publication.classifier, publication.`type`)
)
module.organization.split('.').toSeq ++ Seq(
MavenRepository.dirModuleName(module, sbtAttrStub),
project.version,
s"${module.name}-${versioning getOrElse project.version}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
)
}
val path = module.organization.split('.').toSeq ++ Seq(
MavenRepository.dirModuleName(module, sbtAttrStub),
project.version,
s"${module.name}-${versioning getOrElse project.version}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}"
)
val changing0 = changing.getOrElse(project.version.contains("-SNAPSHOT"))
var artifact =

View File

@ -378,7 +378,7 @@ object App {
)),
<.td(Seq[Seq[TagMod]](
res.projectCache.get(dep.moduleVersion) match {
case Some((source: MavenSource, proj)) if !source.ivyLike =>
case Some((source: MavenSource, proj)) =>
// FIXME Maven specific, generalize with source.artifacts
val version0 = finalVersionOpt getOrElse dep.version
val relPath =