mirror of https://github.com/sbt/sbt.git
Add support for excludeDependencies in SBT plugin
This commit is contained in:
parent
3367f49058
commit
573a54cd8b
|
|
@ -259,6 +259,24 @@ object Tasks {
|
|||
FromSbt.moduleVersion(_, sv, sbv)
|
||||
).toMap
|
||||
|
||||
var anyNonSupportedExclusionRule = false
|
||||
val exclusions = excludeDependencies.value.flatMap {
|
||||
rule =>
|
||||
if (
|
||||
rule.artifact != "*" ||
|
||||
rule.configurations.nonEmpty ||
|
||||
rule.crossVersion != sbt.CrossVersion.Disabled
|
||||
) {
|
||||
Console.err.println(s"Warning: unsupported exclusion rule $rule")
|
||||
anyNonSupportedExclusionRule = true
|
||||
Nil
|
||||
} else
|
||||
Seq((rule.organization, rule.name))
|
||||
}.toSet
|
||||
|
||||
if (anyNonSupportedExclusionRule)
|
||||
Console.err.println(s"Only supported exclusion rule fields: organization, name")
|
||||
|
||||
val resolvers =
|
||||
if (sbtClassifiers)
|
||||
coursierSbtResolvers.value
|
||||
|
|
@ -269,7 +287,10 @@ object Tasks {
|
|||
|
||||
|
||||
val startRes = Resolution(
|
||||
currentProject.dependencies.map { case (_, dep) => dep }.toSet,
|
||||
currentProject.dependencies.map {
|
||||
case (_, dep) =>
|
||||
dep.copy(exclusions = dep.exclusions ++ exclusions)
|
||||
}.toSet,
|
||||
filter = Some(dep => !dep.optional),
|
||||
forceVersions = userForceVersions ++ forcedScalaModules(sv) ++ projects.map(_.moduleVersion)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
scalaVersion := "2.11.8"
|
||||
|
||||
libraryDependencies += "com.github.alexarchambault" %% "argonaut-shapeless_6.1" % "1.0.0-RC1"
|
||||
|
||||
excludeDependencies += SbtExclusionRule("com.chuusai", "shapeless_2.11")
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
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,21 @@
|
|||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
import scala.util.Try
|
||||
|
||||
object Main extends App {
|
||||
|
||||
def classFound(clsName: String) = Try(
|
||||
Thread.currentThread()
|
||||
.getContextClassLoader()
|
||||
.loadClass(clsName)
|
||||
).toOption.nonEmpty
|
||||
|
||||
val shapelessFound = classFound("shapeless.HList")
|
||||
val argonautShapelessFound = classFound("argonaut.derive.MkEncodeJson")
|
||||
|
||||
assert(argonautShapelessFound)
|
||||
assert(!shapelessFound)
|
||||
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
$ delete output
|
||||
> run
|
||||
$ exists output
|
||||
Loading…
Reference in New Issue