Tweak optional pseudo-configuration

Have it ~extends "default" rather than "compile", so that depending on both "default" and "optional" can be simplified to just "optional" ("default" being pulled by it now, thanks to this change). That allows to address the scala-compiler jar appearing twice on the classpath sometimes.
This commit is contained in:
Alexandre Archambault 2017-04-06 00:14:33 +02:00
parent 6c1b8ea7a4
commit 2420fa8a69
3 changed files with 38 additions and 3 deletions

View File

@ -351,7 +351,7 @@ object Resolution {
private val mavenScopes = {
val base = Map[String, Set[String]](
"compile" -> Set("compile"),
"optional" -> Set("compile", "optional"),
"optional" -> Set("compile", "optional", "runtime"),
"provided" -> Set(),
"runtime" -> Set("compile", "runtime"),
"test" -> Set()

View File

@ -330,7 +330,7 @@ final case class MavenRepository(
val proj = Pom.addOptionalDependenciesInConfig(
proj0.copy(configurations = defaultConfigurations),
Set("", "compile"),
Set("", "default"),
"optional"
)

View File

@ -135,8 +135,17 @@ object CentralTests extends TestSuite {
extraRepo: Option[Repository]
)(
f: Seq[Artifact] => T
): Future[T] =
withArtifacts(Set(dep), artifactType, extraRepo)(f)
def withArtifacts[T](
deps: Set[Dependency],
artifactType: String,
extraRepo: Option[Repository]
)(
f: Seq[Artifact] => T
): Future[T] = async {
val res = await(resolve(Set(dep), extraRepo = extraRepo))
val res = await(resolve(deps, extraRepo = extraRepo))
assert(res.errors.isEmpty)
assert(res.conflicts.isEmpty)
@ -348,6 +357,32 @@ object CentralTests extends TestSuite {
'runtime - check("runtime")
}
'optionalScope - {
def intransitiveCompiler(config: String) =
Dependency(
Module("org.scala-lang", "scala-compiler"), "2.11.8",
configuration = config,
transitive = false
)
withArtifacts(
Set(
intransitiveCompiler("default"),
intransitiveCompiler("optional")
),
"jar",
None
) {
case Seq() =>
throw new Exception("Expected one JAR")
case Seq(jar) =>
() // ok
case other =>
throw new Exception(s"Got too many JARs (${other.mkString})")
}
}
'packaging - {
'aar - {
// random aar-based module found on Central