mirror of https://github.com/sbt/sbt.git
Take excludeDependencies into account in published things
This commit is contained in:
parent
926613d10d
commit
bf34774e61
|
|
@ -117,6 +117,31 @@ object Tasks {
|
||||||
lazy val sv = scalaVersion.in(projectRef).get(state)
|
lazy val sv = scalaVersion.in(projectRef).get(state)
|
||||||
lazy val sbv = scalaBinaryVersion.in(projectRef).get(state)
|
lazy val sbv = scalaBinaryVersion.in(projectRef).get(state)
|
||||||
|
|
||||||
|
lazy val exclusions = {
|
||||||
|
|
||||||
|
var anyNonSupportedExclusionRule = false
|
||||||
|
|
||||||
|
val res = excludeDependencies
|
||||||
|
.in(projectRef)
|
||||||
|
.get(state)
|
||||||
|
.flatMap { rule =>
|
||||||
|
if (rule.artifact != "*" || rule.configurations.nonEmpty) {
|
||||||
|
state.log.warn(s"Unsupported exclusion rule $rule")
|
||||||
|
anyNonSupportedExclusionRule = true
|
||||||
|
Nil
|
||||||
|
} else
|
||||||
|
Seq(
|
||||||
|
(rule.organization, FromSbt.sbtCrossVersionName(rule.name, rule.crossVersion, sv, sbv))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.toSet
|
||||||
|
|
||||||
|
if (anyNonSupportedExclusionRule)
|
||||||
|
state.log.warn("Only supported exclusion rule fields: organization, name")
|
||||||
|
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
allDependencies <- allDependenciesTask
|
allDependencies <- allDependenciesTask
|
||||||
} yield {
|
} yield {
|
||||||
|
|
@ -125,13 +150,20 @@ object Tasks {
|
||||||
.map { cfg => cfg.name -> cfg.extendsConfigs.map(_.name) }
|
.map { cfg => cfg.name -> cfg.extendsConfigs.map(_.name) }
|
||||||
.toMap
|
.toMap
|
||||||
|
|
||||||
FromSbt.project(
|
val proj = FromSbt.project(
|
||||||
projId,
|
projId,
|
||||||
allDependencies,
|
allDependencies,
|
||||||
configMap,
|
configMap,
|
||||||
sv,
|
sv,
|
||||||
sbv
|
sbv
|
||||||
)
|
)
|
||||||
|
|
||||||
|
proj.copy(
|
||||||
|
dependencies = proj.dependencies.map {
|
||||||
|
case (config, dep) =>
|
||||||
|
(config, dep.copy(exclusions = dep.exclusions ++ exclusions))
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -443,24 +475,6 @@ object Tasks {
|
||||||
FromSbt.moduleVersion(_, sv, sbv)
|
FromSbt.moduleVersion(_, sv, sbv)
|
||||||
).toMap
|
).toMap
|
||||||
|
|
||||||
var anyNonSupportedExclusionRule = false
|
|
||||||
val exclusions = excludeDependencies.value.flatMap {
|
|
||||||
rule =>
|
|
||||||
if (
|
|
||||||
rule.artifact != "*" ||
|
|
||||||
rule.configurations.nonEmpty
|
|
||||||
) {
|
|
||||||
log.warn(s"Unsupported exclusion rule $rule")
|
|
||||||
anyNonSupportedExclusionRule = true
|
|
||||||
Nil
|
|
||||||
} else
|
|
||||||
Seq((rule.organization,
|
|
||||||
FromSbt.sbtCrossVersionName(rule.name, rule.crossVersion, sv, sbv)))
|
|
||||||
}.toSet
|
|
||||||
|
|
||||||
if (anyNonSupportedExclusionRule)
|
|
||||||
log.warn("Only supported exclusion rule fields: organization, name")
|
|
||||||
|
|
||||||
val resolvers =
|
val resolvers =
|
||||||
if (sbtClassifiers)
|
if (sbtClassifiers)
|
||||||
coursierSbtResolvers.value
|
coursierSbtResolvers.value
|
||||||
|
|
@ -479,10 +493,7 @@ object Tasks {
|
||||||
val userEnabledProfiles = mavenProfiles.value
|
val userEnabledProfiles = mavenProfiles.value
|
||||||
|
|
||||||
val startRes = Resolution(
|
val startRes = Resolution(
|
||||||
currentProject.dependencies.map {
|
currentProject.dependencies.map(_._2).toSet,
|
||||||
case (_, dep) =>
|
|
||||||
dep.copy(exclusions = dep.exclusions ++ exclusions)
|
|
||||||
}.toSet,
|
|
||||||
filter = Some(dep => !dep.optional),
|
filter = Some(dep => !dep.optional),
|
||||||
userActivations =
|
userActivations =
|
||||||
if (userEnabledProfiles.isEmpty)
|
if (userEnabledProfiles.isEmpty)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
scalaVersion := "2.11.8"
|
scalaVersion := "2.11.8"
|
||||||
|
|
||||||
|
organization := "io.get-coursier.test"
|
||||||
|
name := "sbt-coursier-exclude-dependencies"
|
||||||
|
version := "0.1.0-SNAPSHOT"
|
||||||
|
|
||||||
coursierCachePolicies := {
|
coursierCachePolicies := {
|
||||||
if (sys.props("os.name").startsWith("Windows"))
|
if (sys.props("os.name").startsWith("Windows"))
|
||||||
coursierCachePolicies.value
|
coursierCachePolicies.value
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -15,9 +15,18 @@ object Main extends App {
|
||||||
val argonautFound = classFound("argonaut.Json")
|
val argonautFound = classFound("argonaut.Json")
|
||||||
val argonautShapelessFound = classFound("argonaut.derive.MkEncodeJson")
|
val argonautShapelessFound = classFound("argonaut.derive.MkEncodeJson")
|
||||||
|
|
||||||
assert(argonautShapelessFound)
|
assert(
|
||||||
assert(!shapelessFound)
|
argonautShapelessFound,
|
||||||
assert(!argonautFound)
|
"Expected to find class from argonaut-shapeless"
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
!shapelessFound,
|
||||||
|
"Expected not to find classes from shapeless"
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
!argonautFound,
|
||||||
|
"Expected not to find classes from argonaut"
|
||||||
|
)
|
||||||
|
|
||||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
$ delete output
|
$ delete output
|
||||||
> run
|
> run
|
||||||
$ exists output
|
$ exists output
|
||||||
|
> publishLocal
|
||||||
|
$ exec java -jar coursier launch io.get-coursier.test:sbt-coursier-exclude-dependencies_2.11:0.1.0-SNAPSHOT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue