Merge pull request #487 from coursier/topic/tweak-optional-config

Tweak optional pseudo-configuration
This commit is contained in:
Alexandre Archambault 2017-04-06 15:45:29 +02:00 committed by GitHub
commit d629f8f7b9
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