Really filter out optional artifacts by default

This commit is contained in:
Alexandre Archambault 2017-07-15 17:19:09 +02:00
parent 9aebef2535
commit fc0a1ccec7
6 changed files with 53 additions and 13 deletions

View File

@ -1059,6 +1059,7 @@ final case class Resolution(
.toSeq
artifact <- source
.artifacts(dep, proj, overrideClassifiers)
if optional || !artifact.isOptional
} yield dep -> artifact
def dependencyArtifacts: Seq[(Dependency, Artifact)] =

View File

@ -74,7 +74,8 @@ object IvyTests extends TestSuite {
dep = dep,
artifactType = "jar",
extraRepos = Seq(repo),
classifierOpt = None
classifierOpt = None,
optional = true
) {
case Seq(artifact) =>
assert(artifact.url == mainJarUrl)
@ -86,7 +87,8 @@ object IvyTests extends TestSuite {
dep = dep.copy(configuration = "test"),
artifactType = "jar",
extraRepos = Seq(repo),
classifierOpt = None
classifierOpt = None,
optional = true
) {
case Seq(artifact1, artifact2) =>
val urls = Set(

View File

@ -29,7 +29,8 @@ object MavenTests extends TestSuite {
dep = dep,
artifactType = "jar",
extraRepos = Seq(repo),
classifierOpt = None
classifierOpt = None,
optional = true
) {
case Seq(artifact) =>
assert(artifact.url == mainJarUrl)
@ -41,7 +42,8 @@ object MavenTests extends TestSuite {
dep = dep,
artifactType = "src",
extraRepos = Seq(repo),
classifierOpt = Some("sources")
classifierOpt = Some("sources"),
optional = true
) {
case Seq(artifact) =>
assert(artifact.url == sourcesJarUrl)

@ -1 +1 @@
Subproject commit 9a00b31af466454fbf2604e871c273ba9c1c9938
Subproject commit ac3871c925e035157203d6d799a9a2c7c2578d67

View File

@ -0,0 +1,8 @@
io.monix:monix-eval_2.12:2.3.0:compile
io.monix:monix-execution_2.12:2.3.0:compile
io.monix:monix-reactive_2.12:2.3.0:compile
io.monix:monix-types_2.12:2.3.0:compile
io.monix:monix_2.12:2.3.0:compile
org.jctools:jctools-core:2.0.1:compile
org.reactivestreams:reactive-streams:1.0.0:compile
org.scala-lang:scala-library:2.12.2:compile

View File

@ -148,29 +148,32 @@ abstract class CentralTests extends TestSuite {
attributes: Attributes = Attributes(),
extraRepos: Seq[Repository] = Nil,
classifierOpt: Option[String] = None,
transitive: Boolean = false
transitive: Boolean = false,
optional: Boolean = true
)(
f: Seq[Artifact] => T
): Future[T] = {
val dep = Dependency(module, version, transitive = transitive, attributes = attributes)
withArtifacts(dep, artifactType, extraRepos, classifierOpt)(f)
withArtifacts(dep, artifactType, extraRepos, classifierOpt, optional)(f)
}
def withArtifacts[T](
dep: Dependency,
artifactType: String,
extraRepos: Seq[Repository],
classifierOpt: Option[String]
classifierOpt: Option[String],
optional: Boolean
)(
f: Seq[Artifact] => T
): Future[T] =
withArtifacts(Set(dep), artifactType, extraRepos, classifierOpt)(f)
withArtifacts(Set(dep), artifactType, extraRepos, classifierOpt, optional)(f)
def withArtifacts[T](
deps: Set[Dependency],
artifactType: String,
extraRepos: Seq[Repository],
classifierOpt: Option[String]
classifierOpt: Option[String],
optional: Boolean
)(
f: Seq[Artifact] => T
): Future[T] = async {
@ -181,7 +184,7 @@ abstract class CentralTests extends TestSuite {
assert(res.isDone)
val artifacts = classifierOpt
.fold(res.dependencyArtifacts)(c => res.dependencyClassifiersArtifacts(Seq(c)))
.fold(res.dependencyArtifacts(withOptional = optional))(c => res.dependencyClassifiersArtifacts(Seq(c)))
.map(_._2)
.filter {
if (artifactType == "*") _ => true
@ -431,7 +434,8 @@ abstract class CentralTests extends TestSuite {
),
"jar",
extraRepos = Nil,
classifierOpt = None
classifierOpt = None,
optional = true
) {
case Seq() =>
throw new Exception("Expected one JAR")
@ -552,7 +556,7 @@ abstract class CentralTests extends TestSuite {
assert(res.conflicts.isEmpty)
assert(res.isDone)
val dependencyArtifacts = res.dependencyArtifacts
val dependencyArtifacts = res.dependencyArtifacts(withOptional = true)
val zookeeperTestArtifacts = dependencyArtifacts.collect {
case (dep, artifact)
@ -778,6 +782,29 @@ abstract class CentralTests extends TestSuite {
* - resolutionCheck(mod, ver)
}
'optionalArtifacts - {
val mod = Module("io.monix", "monix_2.12")
val ver = "2.3.0"
val mainUrl = "https://repo1.maven.org/maven2/io/monix/monix_2.12/2.3.0/monix_2.12-2.3.0.jar"
* - resolutionCheck(mod, ver)
* - {
if (isActualCentral)
withArtifacts(mod, ver, "jar") { artifacts =>
val mainArtifactOpt = artifacts.find(_.url == mainUrl)
assert(mainArtifactOpt.nonEmpty)
assert(mainArtifactOpt.forall(_.isOptional))
}
}
* - withArtifacts(mod, ver, "jar", optional = false) { artifacts =>
val mainArtifactOpt = artifacts.find(_.url == mainUrl)
assert(mainArtifactOpt.isEmpty)
}
}
}
}