global-plugins - attempt #2 - success

This commit is contained in:
Alexandre Archambault 2015-12-30 01:34:38 +01:00
parent ef31d8344a
commit 4aed6f6c38
2 changed files with 34 additions and 42 deletions

View File

@ -80,7 +80,9 @@ object IvyRepository {
case class IvyRepository( case class IvyRepository(
pattern: String, pattern: String,
changing: Option[Boolean] = None, changing: Option[Boolean] = None,
properties: Map[String, String] = Map.empty properties: Map[String, String] = Map.empty,
withChecksums: Boolean = true,
withSignatures: Boolean = true
) extends Repository { ) extends Repository {
import Repository._ import Repository._
@ -199,15 +201,20 @@ case class IvyRepository(
} }
retainedWithUrl.map { case (p, url) => retainedWithUrl.map { case (p, url) =>
Artifact( var artifact = Artifact(
url, url,
Map.empty, Map.empty,
Map.empty, Map.empty,
p.attributes, p.attributes,
changing = changing.getOrElse(project.version.contains("-SNAPSHOT")) // could be more reliable changing = changing.getOrElse(project.version.contains("-SNAPSHOT")) // could be more reliable
) )
.withDefaultChecksums
.withDefaultSignature if (withChecksums)
artifact = artifact.withDefaultChecksums
if (withSignatures)
artifact = artifact.withDefaultSignature
artifact
} }
} }
} }
@ -226,16 +233,22 @@ case class IvyRepository(
url <- substitute( url <- substitute(
variables(module, version, "ivy", "ivy", "xml") variables(module, version, "ivy", "ivy", "xml")
) )
} yield } yield {
Artifact( var artifact = Artifact(
url, url,
Map.empty, Map.empty,
Map.empty, Map.empty,
Attributes("ivy", ""), Attributes("ivy", ""),
changing = changing.getOrElse(version.contains("-SNAPSHOT")) changing = changing.getOrElse(version.contains("-SNAPSHOT"))
) )
.withDefaultChecksums
.withDefaultSignature if (withChecksums)
artifact = artifact.withDefaultChecksums
if (withSignatures)
artifact = artifact.withDefaultSignature
artifact
}
for { for {
artifact <- EitherT(F.point(eitherArtifact)) artifact <- EitherT(F.point(eitherArtifact))

View File

@ -3,6 +3,7 @@ package coursier
import java.io.{ File, OutputStreamWriter } import java.io.{ File, OutputStreamWriter }
import coursier.cli.TermDisplay import coursier.cli.TermDisplay
import coursier.ivy.IvyRepository
import sbt.{ MavenRepository => _, _ } import sbt.{ MavenRepository => _, _ }
import sbt.Keys._ import sbt.Keys._
@ -17,33 +18,6 @@ object CoursierPlugin extends AutoPlugin {
private def errPrintln(s: String): Unit = scala.Console.err.println(s) private def errPrintln(s: String): Unit = scala.Console.err.println(s)
// org.scala-sbt:global-plugins;sbtVersion=0.13;scalaVersion=2.10:0.0
private val globalPluginsProject = Project(
Module("org.scala-sbt", "global-plugins", Map("sbtVersion" -> "0.13", "scalaVersion" -> "2.10")),
"0.0",
Nil,
Map.empty,
None,
Nil,
Map.empty,
Nil,
None,
None,
Nil
)
private val globalPluginsArtifacts = Seq(
"" -> Seq(
Artifact(
new File(sys.props("user.home") + "/.sbt/0.13/plugins/target") .toURI.toString,
Map.empty,
Map.empty,
Attributes(),
changing = true
)
)
)
object autoImport { object autoImport {
val coursierParallelDownloads = Keys.coursierParallelDownloads val coursierParallelDownloads = Keys.coursierParallelDownloads
val coursierMaxIterations = Keys.coursierMaxIterations val coursierMaxIterations = Keys.coursierMaxIterations
@ -91,22 +65,27 @@ object CoursierPlugin extends AutoPlugin {
val verbosity = coursierVerbosity.value val verbosity = coursierVerbosity.value
val projects0 = projects :+ (globalPluginsProject -> globalPluginsArtifacts)
val startRes = Resolution( val startRes = Resolution(
currentProject.dependencies.map { case (_, dep) => dep }.toSet, currentProject.dependencies.map { case (_, dep) => dep }.toSet,
filter = Some(dep => !dep.optional), filter = Some(dep => !dep.optional),
forceVersions = projects0.map { case (proj, _) => proj.moduleVersion }.toMap forceVersions = projects.map { case (proj, _) => proj.moduleVersion }.toMap
) )
if (verbosity >= 1) { if (verbosity >= 1) {
println("InterProjectRepository") println("InterProjectRepository")
for ((p, _) <- projects0) for ((p, _) <- projects)
println(s" ${p.module}:${p.version}") println(s" ${p.module}:${p.version}")
} }
val interProjectRepo = InterProjectRepository(projects0) val globalPluginsRepo = IvyRepository(
val repositories = interProjectRepo +: resolvers.flatMap(FromSbt.repository(_, ivyProperties)) new File(sys.props("user.home") + "/.sbt/0.13/plugins/target/resolution-cache/").toURI.toString +
"[organization]/[module](/scala_[scalaVersion])(/sbt_[sbtVersion])/[revision]/resolved.xml.[ext]",
withChecksums = false,
withSignatures = false
)
val interProjectRepo = InterProjectRepository(projects)
val repositories = Seq(globalPluginsRepo, interProjectRepo) ++ resolvers.flatMap(FromSbt.repository(_, ivyProperties))
val files = Files( val files = Files(
Seq("http://" -> new File(cacheDir, "http"), "https://" -> new File(cacheDir, "https")), Seq("http://" -> new File(cacheDir, "http"), "https://" -> new File(cacheDir, "https")),
@ -299,7 +278,7 @@ object CoursierPlugin extends AutoPlugin {
override lazy val projectSettings = Seq( override lazy val projectSettings = Seq(
coursierParallelDownloads := 6, coursierParallelDownloads := 6,
coursierMaxIterations := 50, coursierMaxIterations := 50,
coursierChecksums := Seq(Some("SHA-1"), Some("MD5")), coursierChecksums := Seq(Some("SHA-1"), Some("MD5"), None),
coursierCachePolicy := CachePolicy.FetchMissing, coursierCachePolicy := CachePolicy.FetchMissing,
coursierVerbosity := 1, coursierVerbosity := 1,
coursierResolvers <<= Tasks.coursierResolversTask, coursierResolvers <<= Tasks.coursierResolversTask,