From b1f9cb96d4b2924edacbcab569e1b9f37af6e691 Mon Sep 17 00:00:00 2001 From: Erem Boto Date: Sat, 15 Oct 2016 18:21:12 -0700 Subject: [PATCH] Add support for property absence directives in profile activation --- .../main/scala/coursier/core/Resolution.scala | 18 +++++++++++------- .../scala/coursier/test/ResolutionTests.scala | 6 ++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/shared/src/main/scala/coursier/core/Resolution.scala b/core/shared/src/main/scala/coursier/core/Resolution.scala index 66cf5169b..f45c3bc4a 100644 --- a/core/shared/src/main/scala/coursier/core/Resolution.scala +++ b/core/shared/src/main/scala/coursier/core/Resolution.scala @@ -258,7 +258,7 @@ object Resolution { if (mgmtDep.optional) dep = dep.copy(optional = mgmtDep.optional) } - + (config, dep) } } @@ -448,12 +448,16 @@ object Resolution { activation.properties.nonEmpty && activation.properties.forall { case (name, valueOpt) => - props.get(name).exists { v => - valueOpt.forall { reqValue => - if (reqValue.startsWith("!")) - v != reqValue.drop(1) - else - v == reqValue + if (name.startsWith("!")) { + props.get(name.drop(1)).isEmpty + } else { + props.get(name).exists { v => + valueOpt.forall { reqValue => + if (reqValue.startsWith("!")) + v != reqValue.drop(1) + else + v == reqValue + } } } } diff --git a/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala b/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala index 8e6a89c67..7ed092605 100644 --- a/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala +++ b/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala @@ -155,6 +155,12 @@ object ResolutionTests extends TestSuite { // the property "special" is unset. Because that is the case here, // the "default" build profile should be active and "librairie-standard" // should be provided as a transitive dependency when resolved. + // + // We additionally include the property "!special" -> "true" to + // disambiguate the absence of the "special" property versus + // the presence of the "!special" property (which is probably not valid pom + // anyways) + properties = Seq("!special" -> "true"), profiles = Seq( Profile("default", activation = Profile.Activation(properties = Seq("!special" -> None)), dependencies = Seq( "" -> Dependency(Module("org.escalier", "librairie-standard"), "2.11.6"))))),