mirror of https://github.com/sbt/sbt.git
global-plugins - attempt #2 - success
This commit is contained in:
parent
ef31d8344a
commit
4aed6f6c38
|
|
@ -80,7 +80,9 @@ object IvyRepository {
|
|||
case class IvyRepository(
|
||||
pattern: String,
|
||||
changing: Option[Boolean] = None,
|
||||
properties: Map[String, String] = Map.empty
|
||||
properties: Map[String, String] = Map.empty,
|
||||
withChecksums: Boolean = true,
|
||||
withSignatures: Boolean = true
|
||||
) extends Repository {
|
||||
|
||||
import Repository._
|
||||
|
|
@ -199,15 +201,20 @@ case class IvyRepository(
|
|||
}
|
||||
|
||||
retainedWithUrl.map { case (p, url) =>
|
||||
Artifact(
|
||||
var artifact = Artifact(
|
||||
url,
|
||||
Map.empty,
|
||||
Map.empty,
|
||||
p.attributes,
|
||||
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(
|
||||
variables(module, version, "ivy", "ivy", "xml")
|
||||
)
|
||||
} yield
|
||||
Artifact(
|
||||
} yield {
|
||||
var artifact = Artifact(
|
||||
url,
|
||||
Map.empty,
|
||||
Map.empty,
|
||||
Attributes("ivy", ""),
|
||||
changing = changing.getOrElse(version.contains("-SNAPSHOT"))
|
||||
)
|
||||
.withDefaultChecksums
|
||||
.withDefaultSignature
|
||||
|
||||
if (withChecksums)
|
||||
artifact = artifact.withDefaultChecksums
|
||||
if (withSignatures)
|
||||
artifact = artifact.withDefaultSignature
|
||||
|
||||
artifact
|
||||
}
|
||||
|
||||
for {
|
||||
artifact <- EitherT(F.point(eitherArtifact))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package coursier
|
|||
import java.io.{ File, OutputStreamWriter }
|
||||
|
||||
import coursier.cli.TermDisplay
|
||||
import coursier.ivy.IvyRepository
|
||||
import sbt.{ MavenRepository => _, _ }
|
||||
import sbt.Keys._
|
||||
|
||||
|
|
@ -17,33 +18,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
|
||||
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 {
|
||||
val coursierParallelDownloads = Keys.coursierParallelDownloads
|
||||
val coursierMaxIterations = Keys.coursierMaxIterations
|
||||
|
|
@ -91,22 +65,27 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val verbosity = coursierVerbosity.value
|
||||
|
||||
|
||||
val projects0 = projects :+ (globalPluginsProject -> globalPluginsArtifacts)
|
||||
|
||||
val startRes = Resolution(
|
||||
currentProject.dependencies.map { case (_, dep) => dep }.toSet,
|
||||
filter = Some(dep => !dep.optional),
|
||||
forceVersions = projects0.map { case (proj, _) => proj.moduleVersion }.toMap
|
||||
forceVersions = projects.map { case (proj, _) => proj.moduleVersion }.toMap
|
||||
)
|
||||
|
||||
if (verbosity >= 1) {
|
||||
println("InterProjectRepository")
|
||||
for ((p, _) <- projects0)
|
||||
for ((p, _) <- projects)
|
||||
println(s" ${p.module}:${p.version}")
|
||||
}
|
||||
|
||||
val interProjectRepo = InterProjectRepository(projects0)
|
||||
val repositories = interProjectRepo +: resolvers.flatMap(FromSbt.repository(_, ivyProperties))
|
||||
val globalPluginsRepo = IvyRepository(
|
||||
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(
|
||||
Seq("http://" -> new File(cacheDir, "http"), "https://" -> new File(cacheDir, "https")),
|
||||
|
|
@ -299,7 +278,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
override lazy val projectSettings = Seq(
|
||||
coursierParallelDownloads := 6,
|
||||
coursierMaxIterations := 50,
|
||||
coursierChecksums := Seq(Some("SHA-1"), Some("MD5")),
|
||||
coursierChecksums := Seq(Some("SHA-1"), Some("MD5"), None),
|
||||
coursierCachePolicy := CachePolicy.FetchMissing,
|
||||
coursierVerbosity := 1,
|
||||
coursierResolvers <<= Tasks.coursierResolversTask,
|
||||
|
|
|
|||
Loading…
Reference in New Issue