mirror of https://github.com/sbt/sbt.git
Merge pull request #96 from alexarchambault/topic/better-ivy-local
Better ~/.ivy2/local
This commit is contained in:
commit
be912e8891
|
|
@ -6,6 +6,8 @@ import java.nio.file.{ StandardCopyOption, Files => NioFiles }
|
|||
import java.security.MessageDigest
|
||||
import java.util.concurrent.{ConcurrentHashMap, Executors, ExecutorService}
|
||||
|
||||
import coursier.ivy.IvyRepository
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scalaz._
|
||||
import scalaz.concurrent.{ Task, Strategy }
|
||||
|
|
@ -464,9 +466,11 @@ object Cache {
|
|||
}
|
||||
}
|
||||
|
||||
lazy val ivy2Local = MavenRepository(
|
||||
new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString,
|
||||
ivyLike = true
|
||||
lazy val ivy2Local = IvyRepository(
|
||||
// a bit touchy on Windows... - don't try to get the URI manually like s"file://..."
|
||||
new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString +
|
||||
"[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/" +
|
||||
"[artifact](-[classifier]).[ext]"
|
||||
)
|
||||
|
||||
val defaultConcurrentDownloadCount = 6
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ object Tasks {
|
|||
val interProjectRepo = InterProjectRepository(projects)
|
||||
|
||||
val ivyProperties = Map(
|
||||
"ivy.home" -> s"${sys.props("user.home")}/.ivy2"
|
||||
"ivy.home" -> (new File(sys.props("user.home")).toURI.getPath + "/.ivy2")
|
||||
) ++ sys.props
|
||||
|
||||
val repositories = Seq(globalPluginsRepo, interProjectRepo) ++ resolvers.flatMap(FromSbt.repository(_, ivyProperties))
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Reference in New Issue