mirror of https://github.com/sbt/sbt.git
Fix some updateSbtClassifiers-related stuff
This commit is contained in:
parent
d729586e3a
commit
0289895584
|
|
@ -2,9 +2,9 @@ package coursier.sbtcoursiershared
|
|||
|
||||
import coursier.core.{Configuration, Project, Publication}
|
||||
import coursier.lmcoursier.SbtCoursierCache
|
||||
import sbt.{AutoPlugin, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys.{classpathTypes, clean}
|
||||
import sbt.librarymanagement.Resolver
|
||||
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||
|
||||
object SbtCoursierShared extends AutoPlugin {
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
)
|
||||
val coursierResolvers = taskKey[Seq[Resolver]]("")
|
||||
val coursierRecursiveResolvers = taskKey[Seq[Resolver]]("Resolvers of the current project, plus those of all from its inter-dependency projects")
|
||||
val coursierSbtResolvers = taskKey[Seq[Resolver]]("")
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
|
|
@ -37,6 +38,8 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
coursierKeepPreloaded := false
|
||||
)
|
||||
|
||||
private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots"
|
||||
|
||||
override def projectSettings = settings(pubSettings = true)
|
||||
|
||||
def settings(pubSettings: Boolean) =
|
||||
|
|
@ -61,6 +64,37 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
classpathTypes += "test-jar", // FIXME Should this go in buildSettings?
|
||||
coursierResolvers := RepositoriesTasks.coursierResolversTask.value,
|
||||
coursierRecursiveResolvers := RepositoriesTasks.coursierRecursiveResolversTask.value,
|
||||
coursierSbtResolvers := {
|
||||
|
||||
// TODO Add docker-based integration test for that, see https://github.com/coursier/coursier/issues/632
|
||||
|
||||
val resolvers =
|
||||
sbt.Classpaths.bootRepositories(appConfiguration.value).toSeq.flatten ++ // required because of the hack above it seems
|
||||
externalResolvers.in(updateSbtClassifiers).value
|
||||
|
||||
val pluginIvySnapshotsFound = resolvers.exists {
|
||||
case repo: URLRepository =>
|
||||
repo
|
||||
.patterns
|
||||
.artifactPatterns
|
||||
.headOption
|
||||
.exists(_.startsWith(pluginIvySnapshotsBase))
|
||||
case _ => false
|
||||
}
|
||||
|
||||
val resolvers0 =
|
||||
if (pluginIvySnapshotsFound && !resolvers.contains(Classpaths.sbtPluginReleases))
|
||||
resolvers :+ Classpaths.sbtPluginReleases
|
||||
else
|
||||
resolvers
|
||||
|
||||
if (SbtCoursierShared.autoImport.coursierKeepPreloaded.value)
|
||||
resolvers0
|
||||
else
|
||||
resolvers0.filter { r =>
|
||||
!r.name.startsWith("local-preloaded")
|
||||
}
|
||||
}
|
||||
) ++ {
|
||||
if (pubSettings)
|
||||
IvyXml.generateIvyXmlSettings()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val coursierTtl = Keys.coursierTtl
|
||||
val coursierVerbosity = Keys.coursierVerbosity
|
||||
val mavenProfiles = Keys.mavenProfiles
|
||||
val coursierSbtResolvers = Keys.coursierSbtResolvers
|
||||
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
||||
val coursierCredentials = Keys.coursierCredentials
|
||||
val coursierFallbackDependencies = Keys.coursierFallbackDependencies
|
||||
|
|
@ -71,8 +70,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
}.evaluated
|
||||
)
|
||||
|
||||
private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots"
|
||||
|
||||
// allows to get the actual repo list when sbt starts up
|
||||
private val hackHack = Seq(
|
||||
// TODO Add docker-based non reg test for that, with sbt-assembly 0.14.5 in ~/.sbt/1.0/plugins/plugins.sbt
|
||||
|
|
@ -143,37 +140,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
def coursierSettings(
|
||||
shadedConfigOpt: Option[(String, Configuration)] = None
|
||||
): Seq[Setting[_]] = hackHack ++ Seq(
|
||||
coursierSbtResolvers := {
|
||||
|
||||
// TODO Add docker-based integration test for that, see https://github.com/coursier/coursier/issues/632
|
||||
|
||||
val resolvers =
|
||||
sbt.Classpaths.bootRepositories(appConfiguration.value).toSeq.flatten ++ // required because of the hack above it seems
|
||||
externalResolvers.in(updateSbtClassifiers).value
|
||||
|
||||
val pluginIvySnapshotsFound = resolvers.exists {
|
||||
case repo: URLRepository =>
|
||||
repo
|
||||
.patterns
|
||||
.artifactPatterns
|
||||
.headOption
|
||||
.exists(_.startsWith(pluginIvySnapshotsBase))
|
||||
case _ => false
|
||||
}
|
||||
|
||||
val resolvers0 =
|
||||
if (pluginIvySnapshotsFound && !resolvers.contains(Classpaths.sbtPluginReleases))
|
||||
resolvers :+ Classpaths.sbtPluginReleases
|
||||
else
|
||||
resolvers
|
||||
|
||||
if (SbtCoursierShared.autoImport.coursierKeepPreloaded.value)
|
||||
resolvers0
|
||||
else
|
||||
resolvers0.filter { r =>
|
||||
!r.name.startsWith("local-preloaded")
|
||||
}
|
||||
},
|
||||
coursierFallbackDependencies := InputsTasks.coursierFallbackDependenciesTask.value,
|
||||
coursierArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false).value,
|
||||
coursierSignedArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false, includeSignatures = true).value,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ object Keys {
|
|||
|
||||
val mavenProfiles = SettingKey[Set[String]]("maven-profiles")
|
||||
|
||||
val coursierSbtResolvers = TaskKey[Seq[Resolver]]("coursier-sbt-resolvers")
|
||||
val coursierUseSbtCredentials = SettingKey[Boolean]("coursier-use-sbt-credentials")
|
||||
val coursierCredentials = TaskKey[Map[String, Credentials]]("coursier-credentials")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
val pluginVersion = sys.props.getOrElse(
|
||||
"plugin.version",
|
||||
throw new RuntimeException(
|
||||
"""|The system property 'plugin.version' is not defined.
|
||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
||||
)
|
||||
)
|
||||
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
addSbtPlugin {
|
||||
|
||||
val name = sys.props.getOrElse(
|
||||
"plugin.name",
|
||||
sys.error("plugin.name Java property not set")
|
||||
)
|
||||
val version = sys.props.getOrElse(
|
||||
"plugin.version",
|
||||
sys.error("plugin.version Java property not set")
|
||||
)
|
||||
|
||||
"io.get-coursier" % name % version
|
||||
}
|
||||
|
|
@ -3,8 +3,9 @@ package coursier.sbtlmcoursier
|
|||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||
import sbt.Project.inTask
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{dependencyResolution, excludeDependencies, fullResolvers, otherResolvers, scalaBinaryVersion, scalaVersion, streams}
|
||||
import sbt.Keys.{dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaVersion, streams, updateSbtClassifiers}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
object LmCoursierPlugin extends AutoPlugin {
|
||||
|
|
@ -24,37 +25,51 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
override def requires = SbtCoursierShared
|
||||
|
||||
// putting this in projectSettings like sbt.plugins.IvyPlugin does :|
|
||||
override def projectSettings = Seq[Setting[_]](
|
||||
dependencyResolution := mkDependencyResolution.value,
|
||||
coursierConfiguration := mkCoursierConfiguration.value
|
||||
)
|
||||
|
||||
|
||||
private def mkCoursierConfiguration: Def.Initialize[Task[CoursierConfiguration]] =
|
||||
Def.task {
|
||||
val rs = coursierRecursiveResolvers.value
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
val excludeDeps = Inputs.exclusions(
|
||||
excludeDependencies.value,
|
||||
scalaVersion.value,
|
||||
scalaBinaryVersion.value,
|
||||
streams.value.log
|
||||
override def projectSettings: Seq[Setting[_]] =
|
||||
Seq(
|
||||
dependencyResolution := mkDependencyResolution.value,
|
||||
coursierConfiguration := mkCoursierConfiguration().value
|
||||
) ++
|
||||
inTask(updateSbtClassifiers)(
|
||||
Seq(
|
||||
dependencyResolution := mkDependencyResolution.value,
|
||||
coursierConfiguration := mkCoursierConfiguration(sbtClassifiers = true).value
|
||||
)
|
||||
val s = streams.value
|
||||
Classpaths.warnResolversConflict(rs, s.log)
|
||||
CoursierConfiguration()
|
||||
.withResolvers(rs.toVector)
|
||||
.withInterProjectDependencies(interProjectDependencies.toVector)
|
||||
.withExcludeDependencies(
|
||||
excludeDeps
|
||||
.toVector
|
||||
.sorted
|
||||
.map {
|
||||
case (o, n) =>
|
||||
(o.value, n.value)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
private def mkCoursierConfiguration(sbtClassifiers: Boolean = false): Def.Initialize[Task[CoursierConfiguration]] =
|
||||
Def.taskDyn {
|
||||
val resolversTask =
|
||||
if (sbtClassifiers)
|
||||
coursierSbtResolvers
|
||||
else
|
||||
coursierRecursiveResolvers
|
||||
Def.task {
|
||||
val rs = resolversTask.value
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
val excludeDeps = Inputs.exclusions(
|
||||
excludeDependencies.value,
|
||||
scalaVersion.value,
|
||||
scalaBinaryVersion.value,
|
||||
streams.value.log
|
||||
)
|
||||
.withLog(s.log)
|
||||
val s = streams.value
|
||||
Classpaths.warnResolversConflict(rs, s.log)
|
||||
CoursierConfiguration()
|
||||
.withResolvers(rs.toVector)
|
||||
.withInterProjectDependencies(interProjectDependencies.toVector)
|
||||
.withExcludeDependencies(
|
||||
excludeDeps
|
||||
.toVector
|
||||
.sorted
|
||||
.map {
|
||||
case (o, n) =>
|
||||
(o.value, n.value)
|
||||
}
|
||||
)
|
||||
.withLog(s.log)
|
||||
}
|
||||
}
|
||||
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||
Def.task {
|
||||
|
|
|
|||
Loading…
Reference in New Issue