mirror of https://github.com/sbt/sbt.git
Start to move some coursier specific keys to sbt-coursier-shared plugin
This commit is contained in:
parent
16574d8fc8
commit
0225bc5ce7
12
build.sbt
12
build.sbt
|
|
@ -40,6 +40,14 @@ lazy val `lm-coursier` = project
|
|||
contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats
|
||||
)
|
||||
|
||||
lazy val `sbt-coursier-shared` = project
|
||||
.in(file("modules/sbt-coursier-shared"))
|
||||
.enablePlugins(ScriptedPlugin)
|
||||
.dependsOn(`lm-coursier`)
|
||||
.settings(
|
||||
plugin
|
||||
)
|
||||
|
||||
lazy val `sbt-lm-coursier` = project
|
||||
.in(file("modules/sbt-lm-coursier"))
|
||||
.enablePlugins(ScriptedPlugin)
|
||||
|
|
@ -59,7 +67,7 @@ lazy val `sbt-lm-coursier` = project
|
|||
lazy val `sbt-coursier` = project
|
||||
.in(file("modules/sbt-coursier"))
|
||||
.enablePlugins(ScriptedPlugin)
|
||||
.dependsOn(`lm-coursier`)
|
||||
.dependsOn(`sbt-coursier-shared`)
|
||||
.settings(
|
||||
plugin,
|
||||
libraryDependencies += "com.lihaoyi" %% "utest" % "0.6.4" % Test,
|
||||
|
|
@ -71,6 +79,7 @@ lazy val `sbt-coursier` = project
|
|||
// TODO Get dependency projects automatically
|
||||
// (but shouldn't scripted itself handle that…?)
|
||||
publishLocal.in(`lm-coursier`).value
|
||||
publishLocal.in(`sbt-coursier-shared`).value
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -120,6 +129,7 @@ lazy val `sbt-coursier-root` = project
|
|||
.aggregate(
|
||||
`lm-coursier`,
|
||||
`sbt-coursier`,
|
||||
`sbt-coursier-shared`,
|
||||
`sbt-lm-coursier`,
|
||||
`sbt-pgp-coursier`,
|
||||
`sbt-shading`
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
|
||||
object InputsTasks {
|
||||
|
||||
def coursierProjectTask: Def.Initialize[sbt.Task[Project]] =
|
||||
Def.taskDyn {
|
||||
|
||||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val allDependenciesTask = allDependencies.in(projectRef).get(state)
|
||||
|
||||
Def.task {
|
||||
Inputs.coursierProject(
|
||||
projectID.in(projectRef).get(state),
|
||||
allDependenciesTask.value,
|
||||
excludeDependencies.in(projectRef).get(state),
|
||||
// should projectID.configurations be used instead?
|
||||
ivyConfigurations.in(projectRef).get(state),
|
||||
scalaVersion.in(projectRef).get(state),
|
||||
scalaBinaryVersion.in(projectRef).get(state),
|
||||
state.log
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def coursierInterProjectDependenciesTask: Def.Initialize[sbt.Task[Seq[Project]]] =
|
||||
Def.taskDyn {
|
||||
|
||||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val projects = Structure.allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val t = coursierProject.forAllProjects(state, projects).map(_.values.toVector)
|
||||
|
||||
Def.task(t.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.core.Project
|
||||
import sbt.{AutoPlugin, TaskKey}
|
||||
|
||||
object SbtCoursierShared extends AutoPlugin {
|
||||
|
||||
override def trigger = allRequirements
|
||||
|
||||
override def requires = sbt.plugins.JvmPlugin
|
||||
|
||||
object autoImport {
|
||||
val coursierProject = TaskKey[Project]("coursier-project")
|
||||
val coursierInterProjectDependencies = TaskKey[Seq[Project]]("coursier-inter-project-dependencies", "Projects the current project depends on, possibly transitively")
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
|
||||
override def projectSettings = Seq(
|
||||
coursierProject := InputsTasks.coursierProjectTask.value,
|
||||
coursierInterProjectDependencies := InputsTasks.coursierInterProjectDependenciesTask.value
|
||||
)
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package coursier.sbtcoursier
|
||||
package coursier.sbtcoursiershared
|
||||
|
||||
import sbt._
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ import coursier.{Artifact, FileError}
|
|||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursier.Structure._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.librarymanagement.{Artifact => _, Configuration => _, _}
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.io.OutputStreamWriter
|
|||
import coursier.{Cache, CachePolicy, TermDisplay}
|
||||
import coursier.core.{Configuration, ResolutionProcess}
|
||||
import coursier.lmcoursier.SbtCoursierCache
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import sbt.librarymanagement.{Configuration => _, Resolver => _, _}
|
||||
import sbt.{Cache => _, Configuration => _, _}
|
||||
import sbt.Keys._
|
||||
|
|
@ -13,7 +14,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
|
||||
override def trigger = allRequirements
|
||||
|
||||
override def requires = sbt.plugins.JvmPlugin
|
||||
override def requires = SbtCoursierShared
|
||||
|
||||
object autoImport {
|
||||
val coursierParallelDownloads = Keys.coursierParallelDownloads
|
||||
|
|
@ -33,9 +34,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val coursierCredentials = Keys.coursierCredentials
|
||||
val coursierFallbackDependencies = Keys.coursierFallbackDependencies
|
||||
val coursierCache = Keys.coursierCache
|
||||
val coursierProject = Keys.coursierProject
|
||||
val coursierConfigGraphs = Keys.coursierConfigGraphs
|
||||
val coursierInterProjectDependencies = Keys.coursierInterProjectDependencies
|
||||
val coursierPublications = Keys.coursierPublications
|
||||
val coursierSbtClassifiersModule = Keys.coursierSbtClassifiersModule
|
||||
|
||||
|
|
@ -64,6 +63,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
}
|
||||
|
||||
import autoImport._
|
||||
import SbtCoursierShared.autoImport._
|
||||
|
||||
lazy val treeSettings = Seq(
|
||||
coursierDependencyTree := DisplayTasks.coursierDependencyTreeTask(
|
||||
|
|
@ -227,9 +227,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
sbtClassifiers = true,
|
||||
ignoreArtifactErrors = true
|
||||
).value,
|
||||
coursierProject := InputsTasks.coursierProjectTask.value,
|
||||
coursierConfigGraphs := InputsTasks.ivyGraphsTask.value,
|
||||
coursierInterProjectDependencies := InputsTasks.coursierInterProjectDependenciesTask.value,
|
||||
coursierPublications := ArtifactsTasks.coursierPublicationsTask(packageConfigs: _*).value,
|
||||
coursierSbtClassifiersModule := classifiersModule.in(updateSbtClassifiers).value,
|
||||
coursierConfigurations := InputsTasks.coursierConfigurationsTask(None).value,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package coursier.sbtcoursier
|
|||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.util.Print.Colors
|
||||
import coursier.util.{Parse, Print}
|
||||
import sbt.Def
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import coursier.ProjectCache
|
|||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursier.Structure._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.librarymanagement.{Configuration => _, _}
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
|
|
@ -19,7 +20,7 @@ object InputsTasks {
|
|||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val projects = Structure.allRecursiveInterDependencies(state, projectRef)
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val allDependenciesTask = allDependencies
|
||||
.forAllProjects(state, projectRef +: projects)
|
||||
|
|
@ -36,41 +37,6 @@ object InputsTasks {
|
|||
}
|
||||
}
|
||||
|
||||
def coursierProjectTask: Def.Initialize[sbt.Task[Project]] =
|
||||
Def.taskDyn {
|
||||
|
||||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val allDependenciesTask = allDependencies.in(projectRef).get(state)
|
||||
|
||||
Def.task {
|
||||
Inputs.coursierProject(
|
||||
projectID.in(projectRef).get(state),
|
||||
allDependenciesTask.value,
|
||||
excludeDependencies.in(projectRef).get(state),
|
||||
// should projectID.configurations be used instead?
|
||||
ivyConfigurations.in(projectRef).get(state),
|
||||
scalaVersion.in(projectRef).get(state),
|
||||
scalaBinaryVersion.in(projectRef).get(state),
|
||||
state.log
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def coursierInterProjectDependenciesTask: Def.Initialize[sbt.Task[Seq[Project]]] =
|
||||
Def.taskDyn {
|
||||
|
||||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val projects = Structure.allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val t = coursierProject.forAllProjects(state, projects).map(_.values.toVector)
|
||||
|
||||
Def.task(t.value)
|
||||
}
|
||||
|
||||
def coursierConfigurationsTask(
|
||||
shadedConfig: Option[(String, Configuration)]
|
||||
): Def.Initialize[sbt.Task[Map[Configuration, Set[Configuration]]]] =
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ object Keys {
|
|||
|
||||
val coursierFallbackDependencies = TaskKey[Seq[(Module, String, URL, Boolean)]]("coursier-fallback-dependencies")
|
||||
|
||||
val coursierProject = TaskKey[Project]("coursier-project")
|
||||
val coursierConfigGraphs = TaskKey[Seq[Set[Configuration]]]("coursier-config-graphs")
|
||||
val coursierInterProjectDependencies = TaskKey[Seq[Project]]("coursier-inter-project-dependencies", "Projects the current project depends on, possibly transitively")
|
||||
val coursierPublications = TaskKey[Seq[(Configuration, Publication)]]("coursier-publications")
|
||||
|
||||
val coursierSbtClassifiersModule = TaskKey[GetClassifiersModule]("coursier-sbt-classifiers-module")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package coursier.sbtcoursier
|
|||
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursier.Structure._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.{Classpaths, Def}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.Resolver
|
||||
|
|
@ -60,7 +60,7 @@ object RepositoriesTasks {
|
|||
val state = sbt.Keys.state.value
|
||||
val projectRef = sbt.Keys.thisProjectRef.value
|
||||
|
||||
val projects = Structure.allRecursiveInterDependencies(state, projectRef)
|
||||
val projects = allRecursiveInterDependencies(state, projectRef)
|
||||
|
||||
val t = coursierResolvers
|
||||
.forAllProjects(state, projectRef +: projects)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import coursier.ivy.IvyRepository
|
|||
import coursier.lmcoursier._
|
||||
import coursier.maven.MavenRepository
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package coursier.sbtcoursier
|
|||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.UpdateReport
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import java.io.File
|
|||
import coursier.core.{Configuration, Type}
|
||||
import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
|
||||
import coursier.sbtcoursier.{CoursierPlugin, InputsTasks, Keys}
|
||||
import sbt.librarymanagement._
|
||||
import sbt.Keys._
|
||||
import sbt.{AutoPlugin, Compile, SettingKey, TaskKey, inConfig}
|
||||
|
||||
|
|
@ -13,7 +12,7 @@ object ShadingPlugin extends AutoPlugin {
|
|||
|
||||
override def trigger = noTrigger
|
||||
|
||||
override def requires = sbt.plugins.IvyPlugin
|
||||
override def requires = CoursierPlugin
|
||||
|
||||
private val baseSbtConfiguration = Compile
|
||||
val Shading = sbt.Configuration.of(
|
||||
|
|
@ -73,6 +72,7 @@ object ShadingPlugin extends AutoPlugin {
|
|||
)
|
||||
|
||||
import coursier.sbtcoursier.CoursierPlugin.autoImport._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
|
||||
override lazy val buildSettings = super.buildSettings ++ Seq(
|
||||
shadeNamespaces := Set()
|
||||
|
|
|
|||
Loading…
Reference in New Issue