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.core.{Configuration, Project, Publication}
|
||||||
import coursier.lmcoursier.SbtCoursierCache
|
import coursier.lmcoursier.SbtCoursierCache
|
||||||
import sbt.{AutoPlugin, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||||
import sbt.Keys.{classpathTypes, clean}
|
import sbt.Keys._
|
||||||
import sbt.librarymanagement.Resolver
|
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||||
|
|
||||||
object SbtCoursierShared extends AutoPlugin {
|
object SbtCoursierShared extends AutoPlugin {
|
||||||
|
|
||||||
|
|
@ -24,6 +24,7 @@ object SbtCoursierShared extends AutoPlugin {
|
||||||
)
|
)
|
||||||
val coursierResolvers = taskKey[Seq[Resolver]]("")
|
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 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._
|
import autoImport._
|
||||||
|
|
@ -37,6 +38,8 @@ object SbtCoursierShared extends AutoPlugin {
|
||||||
coursierKeepPreloaded := false
|
coursierKeepPreloaded := false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots"
|
||||||
|
|
||||||
override def projectSettings = settings(pubSettings = true)
|
override def projectSettings = settings(pubSettings = true)
|
||||||
|
|
||||||
def settings(pubSettings: Boolean) =
|
def settings(pubSettings: Boolean) =
|
||||||
|
|
@ -61,6 +64,37 @@ object SbtCoursierShared extends AutoPlugin {
|
||||||
classpathTypes += "test-jar", // FIXME Should this go in buildSettings?
|
classpathTypes += "test-jar", // FIXME Should this go in buildSettings?
|
||||||
coursierResolvers := RepositoriesTasks.coursierResolversTask.value,
|
coursierResolvers := RepositoriesTasks.coursierResolversTask.value,
|
||||||
coursierRecursiveResolvers := RepositoriesTasks.coursierRecursiveResolversTask.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)
|
if (pubSettings)
|
||||||
IvyXml.generateIvyXmlSettings()
|
IvyXml.generateIvyXmlSettings()
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ object CoursierPlugin extends AutoPlugin {
|
||||||
val coursierTtl = Keys.coursierTtl
|
val coursierTtl = Keys.coursierTtl
|
||||||
val coursierVerbosity = Keys.coursierVerbosity
|
val coursierVerbosity = Keys.coursierVerbosity
|
||||||
val mavenProfiles = Keys.mavenProfiles
|
val mavenProfiles = Keys.mavenProfiles
|
||||||
val coursierSbtResolvers = Keys.coursierSbtResolvers
|
|
||||||
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
||||||
val coursierCredentials = Keys.coursierCredentials
|
val coursierCredentials = Keys.coursierCredentials
|
||||||
val coursierFallbackDependencies = Keys.coursierFallbackDependencies
|
val coursierFallbackDependencies = Keys.coursierFallbackDependencies
|
||||||
|
|
@ -71,8 +70,6 @@ object CoursierPlugin extends AutoPlugin {
|
||||||
}.evaluated
|
}.evaluated
|
||||||
)
|
)
|
||||||
|
|
||||||
private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots"
|
|
||||||
|
|
||||||
// allows to get the actual repo list when sbt starts up
|
// allows to get the actual repo list when sbt starts up
|
||||||
private val hackHack = Seq(
|
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
|
// 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(
|
def coursierSettings(
|
||||||
shadedConfigOpt: Option[(String, Configuration)] = None
|
shadedConfigOpt: Option[(String, Configuration)] = None
|
||||||
): Seq[Setting[_]] = hackHack ++ Seq(
|
): 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,
|
coursierFallbackDependencies := InputsTasks.coursierFallbackDependenciesTask.value,
|
||||||
coursierArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false).value,
|
coursierArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false).value,
|
||||||
coursierSignedArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false, includeSignatures = true).value,
|
coursierSignedArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false, includeSignatures = true).value,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ object Keys {
|
||||||
|
|
||||||
val mavenProfiles = SettingKey[Set[String]]("maven-profiles")
|
val mavenProfiles = SettingKey[Set[String]]("maven-profiles")
|
||||||
|
|
||||||
val coursierSbtResolvers = TaskKey[Seq[Resolver]]("coursier-sbt-resolvers")
|
|
||||||
val coursierUseSbtCredentials = SettingKey[Boolean]("coursier-use-sbt-credentials")
|
val coursierUseSbtCredentials = SettingKey[Boolean]("coursier-use-sbt-credentials")
|
||||||
val coursierCredentials = TaskKey[Map[String, Credentials]]("coursier-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.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||||
|
import sbt.Project.inTask
|
||||||
import sbt.KeyRanks.DTask
|
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
|
import sbt.librarymanagement.DependencyResolution
|
||||||
|
|
||||||
object LmCoursierPlugin extends AutoPlugin {
|
object LmCoursierPlugin extends AutoPlugin {
|
||||||
|
|
@ -24,37 +25,51 @@ object LmCoursierPlugin extends AutoPlugin {
|
||||||
override def requires = SbtCoursierShared
|
override def requires = SbtCoursierShared
|
||||||
|
|
||||||
// putting this in projectSettings like sbt.plugins.IvyPlugin does :|
|
// putting this in projectSettings like sbt.plugins.IvyPlugin does :|
|
||||||
override def projectSettings = Seq[Setting[_]](
|
override def projectSettings: Seq[Setting[_]] =
|
||||||
dependencyResolution := mkDependencyResolution.value,
|
Seq(
|
||||||
coursierConfiguration := mkCoursierConfiguration.value
|
dependencyResolution := mkDependencyResolution.value,
|
||||||
)
|
coursierConfiguration := mkCoursierConfiguration().value
|
||||||
|
) ++
|
||||||
|
inTask(updateSbtClassifiers)(
|
||||||
private def mkCoursierConfiguration: Def.Initialize[Task[CoursierConfiguration]] =
|
Seq(
|
||||||
Def.task {
|
dependencyResolution := mkDependencyResolution.value,
|
||||||
val rs = coursierRecursiveResolvers.value
|
coursierConfiguration := mkCoursierConfiguration(sbtClassifiers = true).value
|
||||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
|
||||||
val excludeDeps = Inputs.exclusions(
|
|
||||||
excludeDependencies.value,
|
|
||||||
scalaVersion.value,
|
|
||||||
scalaBinaryVersion.value,
|
|
||||||
streams.value.log
|
|
||||||
)
|
)
|
||||||
val s = streams.value
|
)
|
||||||
Classpaths.warnResolversConflict(rs, s.log)
|
|
||||||
CoursierConfiguration()
|
|
||||||
.withResolvers(rs.toVector)
|
private def mkCoursierConfiguration(sbtClassifiers: Boolean = false): Def.Initialize[Task[CoursierConfiguration]] =
|
||||||
.withInterProjectDependencies(interProjectDependencies.toVector)
|
Def.taskDyn {
|
||||||
.withExcludeDependencies(
|
val resolversTask =
|
||||||
excludeDeps
|
if (sbtClassifiers)
|
||||||
.toVector
|
coursierSbtResolvers
|
||||||
.sorted
|
else
|
||||||
.map {
|
coursierRecursiveResolvers
|
||||||
case (o, n) =>
|
Def.task {
|
||||||
(o.value, n.value)
|
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]] =
|
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||||
Def.task {
|
Def.task {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue