mirror of https://github.com/sbt/sbt.git
Add sbt-lm-coursier plugin
This commit is contained in:
parent
4cbb9082cc
commit
ecee7fab99
17
build.sbt
17
build.sbt
|
|
@ -40,6 +40,22 @@ lazy val `lm-coursier` = project
|
||||||
contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats
|
contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats
|
||||||
)
|
)
|
||||||
|
|
||||||
|
lazy val `sbt-lm-coursier` = project
|
||||||
|
.in(file("modules/sbt-lm-coursier"))
|
||||||
|
.enablePlugins(ScriptedPlugin)
|
||||||
|
.dependsOn(`lm-coursier`)
|
||||||
|
.settings(
|
||||||
|
plugin,
|
||||||
|
sbtTestDirectory := sbtTestDirectory.in(`sbt-coursier`).value,
|
||||||
|
scriptedDependencies := {
|
||||||
|
scriptedDependencies.value
|
||||||
|
|
||||||
|
// TODO Get those automatically
|
||||||
|
// (but shouldn't scripted itself handle that…?)
|
||||||
|
publishLocal.in(`lm-coursier`).value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
lazy val `sbt-coursier` = project
|
lazy val `sbt-coursier` = project
|
||||||
.in(file("modules/sbt-coursier"))
|
.in(file("modules/sbt-coursier"))
|
||||||
.enablePlugins(ScriptedPlugin)
|
.enablePlugins(ScriptedPlugin)
|
||||||
|
|
@ -104,6 +120,7 @@ lazy val `sbt-coursier-root` = project
|
||||||
.aggregate(
|
.aggregate(
|
||||||
`lm-coursier`,
|
`lm-coursier`,
|
||||||
`sbt-coursier`,
|
`sbt-coursier`,
|
||||||
|
`sbt-lm-coursier`,
|
||||||
`sbt-pgp-coursier`,
|
`sbt-pgp-coursier`,
|
||||||
`sbt-shading`
|
`sbt-shading`
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package coursier.sbtlmcoursier
|
||||||
|
|
||||||
|
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution}
|
||||||
|
import sbt.{AutoPlugin, Classpaths, Def, Task, taskKey}
|
||||||
|
import sbt.KeyRanks.DTask
|
||||||
|
import sbt.Keys.{dependencyResolution, fullResolvers, otherResolvers, streams}
|
||||||
|
import sbt.librarymanagement.DependencyResolution
|
||||||
|
|
||||||
|
object LmCoursierPlugin extends AutoPlugin {
|
||||||
|
|
||||||
|
object autoImport {
|
||||||
|
val coursierConfiguration = taskKey[CoursierConfiguration]("General dependency management (Coursier) settings, such as the resolvers and options to use.").withRank(DTask)
|
||||||
|
}
|
||||||
|
|
||||||
|
import autoImport._
|
||||||
|
|
||||||
|
|
||||||
|
override def trigger = allRequirements
|
||||||
|
|
||||||
|
// requiring IvyPlugin… to override it, and so that it doesn't override us :|
|
||||||
|
override def requires = sbt.plugins.IvyPlugin
|
||||||
|
|
||||||
|
// putting this in projectSettings like sbt.plugins.IvyPlugin does :|
|
||||||
|
override def projectSettings = Seq(
|
||||||
|
dependencyResolution := mkDependencyResolution.value,
|
||||||
|
coursierConfiguration := mkCoursierConfiguration.value
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
private def mkCoursierConfiguration: Def.Initialize[Task[CoursierConfiguration]] =
|
||||||
|
Def.task {
|
||||||
|
val (rs, other) = (fullResolvers.value.toVector, otherResolvers.value.toVector)
|
||||||
|
val s = streams.value
|
||||||
|
Classpaths.warnResolversConflict(rs ++: other, s.log)
|
||||||
|
CoursierConfiguration()
|
||||||
|
.withResolvers(rs)
|
||||||
|
.withOtherResolvers(other)
|
||||||
|
.withLog(s.log)
|
||||||
|
}
|
||||||
|
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||||
|
Def.task {
|
||||||
|
CoursierDependencyResolution(coursierConfiguration.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue