mirror of https://github.com/sbt/sbt.git
Rely on allExcludeDependencies when it's there
It excludes sbt itself in meta-builds in particular, see https://github.com/coursier/coursier/issues/1128
This commit is contained in:
parent
6bdd0f985a
commit
16bf1570ad
|
|
@ -5,15 +5,26 @@ import lmcoursier.definitions.{Attributes, Classifier, Configuration, Dependency
|
|||
import lmcoursier.{FallbackDependency, FromSbt, Inputs}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.Def
|
||||
import sbt.{Def, SettingKey}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.{InclExclRule, ModuleID}
|
||||
import sbt.util.Logger
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.language.reflectiveCalls
|
||||
|
||||
object InputsTasks {
|
||||
|
||||
lazy val actualExcludeDependencies =
|
||||
try {
|
||||
sbt.Keys
|
||||
.asInstanceOf[{ def allExcludeDependencies: SettingKey[scala.Seq[InclExclRule]] }]
|
||||
.allExcludeDependencies
|
||||
} catch {
|
||||
case _: NoSuchMethodException =>
|
||||
excludeDependencies
|
||||
}
|
||||
|
||||
private def coursierProject0(
|
||||
projId: ModuleID,
|
||||
dependencies: Seq[ModuleID],
|
||||
|
|
@ -56,7 +67,7 @@ object InputsTasks {
|
|||
coursierProject0(
|
||||
projectID.in(projectRef).get(state),
|
||||
allDependenciesTask.value,
|
||||
excludeDependencies.in(projectRef).get(state),
|
||||
actualExcludeDependencies.in(projectRef).get(state),
|
||||
// should projectID.configurations be used instead?
|
||||
ivyConfigurations.in(projectRef).get(state),
|
||||
scalaVersion.in(projectRef).get(state),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
scalaVersion := "2.11.8"
|
||||
|
||||
organization := "io.get-coursier.test"
|
||||
name := "sbt-coursier-all-exclude-dependencies"
|
||||
version := "0.1.0-SNAPSHOT"
|
||||
|
||||
libraryDependencies += "com.github.alexarchambault" %% "argonaut-shapeless_6.1" % "1.0.0-RC1"
|
||||
|
||||
allExcludeDependencies += sbt.ExclusionRule("com.chuusai", "shapeless_2.11")
|
||||
allExcludeDependencies += "io.argonaut" %% "argonaut"
|
||||
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
sbt.version=1.3.0-M2
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
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 argonautFound = classFound("argonaut.Json")
|
||||
val argonautShapelessFound = classFound("argonaut.derive.MkEncodeJson")
|
||||
|
||||
assert(
|
||||
argonautShapelessFound,
|
||||
"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"))
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ delete output
|
||||
> run
|
||||
$ exists output
|
||||
> publishLocal
|
||||
$ exec java -jar coursier launch io.get-coursier.test:sbt-coursier-all-exclude-dependencies_2.11:0.1.0-SNAPSHOT
|
||||
|
|
@ -3,13 +3,15 @@ package coursier.sbtlmcoursier
|
|||
import lmcoursier.definitions.Authentication
|
||||
import lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||
import coursier.sbtcoursiershared.InputsTasks.credentialsTask
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import coursier.sbtcoursiershared.{InputsTasks, SbtCoursierShared}
|
||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||
import sbt.Project.inTask
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
import scala.language.reflectiveCalls
|
||||
|
||||
object LmCoursierPlugin extends AutoPlugin {
|
||||
|
||||
import SbtCoursierShared.autoImport._
|
||||
|
|
@ -78,7 +80,7 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
val scalaVer = scalaVersion.value
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
val excludeDeps = Inputs.exclusions(
|
||||
excludeDependencies.value,
|
||||
InputsTasks.actualExcludeDependencies.value,
|
||||
scalaVer,
|
||||
scalaBinaryVersion.value,
|
||||
streams.value.log
|
||||
|
|
|
|||
Loading…
Reference in New Issue