[GRADLE-3045] Gradle does not consider Maven profiles that are active when a property is not defined Created: 13/Mar/14  Updated: 18/Apr/14  Resolved: 18/Apr/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.0-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Benjamin Muschko
Resolution: Fixed Votes: 0


 Description   

I'm trying to set-up Pax-Exam in gradle:

  • [1]https://github.com/lburgazzoli/lb-axon
  • [2]https://github.com/lburgazzoli/lb-axo...

But the test step fails to start because of the following error:

  • What went wrong:
    Could not resolve all dependencies for configuration ':axon-osgi:testCompile'.
    > Could not resolve org.ops4j.pax.exam:pax-exam-spi:3.4.0.
    Required by:
    com.github.lburgazzoli:axon-osgi:1.0.0.SNAPSHOT > org.ops4j.pax.exam:pax-exam-container-native:3.4.0
    com.github.lburgazzoli:axon-osgi:1.0.0.SNAPSHOT > org.ops4j.pax.exam:pax-exam-junit4:3.4.0
    > Could not parse POM [3]http://repo1.maven.org/maven2/org/ops...
    > Unable to resolve version for dependency 'com.google.guava:guava:jar'

Looking at pax-exam-spi-3.4.0.pom, the version tag is effectively not provided but a very similar project builds without problem with Maven: any hint?
----------------------------------------------------------------------------------------
[1] https://github.com/lburgazzoli/lb-axon
[2] https://github.com/lburgazzoli/lb-axon/blob/master/axon-osgi/build.gradle
[3] http://repo1.maven.org/maven2/org/ops4j/pax/exam/pax-exam-spi/3.4.0/pax-exam-spi-3.4.0.pom



 Comments   
Comment by Gradle Forums [ 13/Mar/14 ]

First step is to figure out how the version is provided. If it builds in Maven, the version has to be provided somehow. Also make sure to try with the latest Gradle version (and perhaps even with latest nightly), because I think there have been some related improvements lately.

Comment by Gradle Forums [ 13/Mar/14 ]

I've tested with gradle 1.10 and with nightly build 1.12-20140124230013 but they still fail in dependency resolution.

Here the Maven dependecy:tree
```
[INFO] +- org.ops4j.pax.exam:pax-exam-container-native:jar:3.4.0:test
[INFO] | +- org.ops4j.pax.exam:pax-exam:jar:3.4.0:test
[INFO] | | - org.ops4j.base:ops4j-base-store:jar:1.4.0:test
[INFO] | | - org.ops4j.base:ops4j-base-io:jar:1.4.0:test
[INFO] | +- org.ops4j.pax.exam:pax-exam-spi:jar:3.4.0:test
[INFO] | | +- org.ops4j.base:ops4j-base-spi:jar:1.4.0:test
[INFO] | | +- com.google.guava:guava:jar:12.0:test
[INFO] | | | - com.google.code.findbugs:jsr305:jar:1.3.9:test
[INFO] | | - org.ops4j.pax.tinybundles:tinybundles:jar:2.0.0:test
[INFO] | | - biz.aQute.bnd:bndlib:jar:2.1.0:test
[INFO] | +- org.ops4j.pax.swissbox:pax-swissbox-core:jar:1.7.0:test
[INFO] | | - org.ops4j.pax.swissbox:pax-swissbox-lifecycle:jar:1.7.0:test
[INFO] | +- org.ops4j.pax.swissbox:pax-swissbox-tracker:jar:1.7.0:test
[INFO] | +- org.ops4j.base:ops4j-base-lang:jar:1.4.0:test
[INFO] | +- org.ops4j.base:ops4j-base-net:jar:1.4.0:test
[INFO] | | - org.ops4j.base:ops4j-base-monitors:jar:1.4.0:test
[INFO] | +- org.ops4j.pax.url:pax-url-link:jar:1.6.0:test
[INFO] | - org.ops4j.pax.url:pax-url-classpath:jar:1.6.0:test
```

And here the gradle one:
```
+--- org.ops4j.pax.exam:pax-exam-container-native:3.4.0

+--- org.ops4j.pax.exam:pax-exam:3.4.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  +--- org.ops4j.base:ops4j-base-store:1.4.0
    +--- org.slf4j:slf4j-api:1.5.11 -> 1.7.5
    --- org.ops4j.base:ops4j-base-io:1.4.0
    +--- org.ops4j.base:ops4j-base-lang:1.4.0
    --- org.ops4j.base:ops4j-base-monitors:1.4.0
  --- org.ops4j.base:ops4j-base-util-property:1.4.0
+--- org.ops4j.pax.exam:pax-exam-spi:3.4.0 FAILED
+--- org.ops4j.pax.swissbox:pax-swissbox-core:1.7.0
  +--- org.ops4j.pax.swissbox:pax-swissbox-lifecycle:1.7.0
  --- org.ops4j.base:ops4j-base-lang:1.4.0
+--- org.ops4j.pax.swissbox:pax-swissbox-tracker:1.7.0
  +--- org.ops4j.pax.swissbox:pax-swissbox-lifecycle:1.7.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  --- org.slf4j:slf4j-api:1.5.11 -> 1.7.5
+--- org.ops4j.base:ops4j-base-lang:1.4.0
+--- org.ops4j.base:ops4j-base-net:1.4.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  --- org.ops4j.base:ops4j-base-monitors:1.4.0
+--- org.ops4j.pax.url:pax-url-link:1.6.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  +--- org.ops4j.base:ops4j-base-util-property:1.4.0
  --- org.ops4j.pax.url:pax-url-commons:1.6.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  +--- org.ops4j.pax.swissbox:pax-swissbox-property:1.7.0
    +--- org.ops4j.base:ops4j-base-lang:1.4.0
    --- org.ops4j.base:ops4j-base-util-property:1.4.0
  --- org.slf4j:slf4j-api:1.5.11 -> 1.7.5
--- org.ops4j.pax.url:pax-url-classpath:1.6.0
+--- org.ops4j.base:ops4j-base-lang:1.4.0
+--- org.ops4j.base:ops4j-base-util-property:1.4.0
+--- org.ops4j.pax.swissbox:pax-swissbox-optional-jcl:1.7.0
--- org.ops4j.pax.url:pax-url-commons:1.6.0
```
Comment by Gradle Forums [ 13/Mar/14 ]

it works with gradle 1.9

```
+--- org.ops4j.pax.exam:pax-exam-container-native:3.4.0

+--- org.ops4j.pax.exam:pax-exam:3.4.0
+--- org.ops4j.pax.exam:pax-exam-spi:3.4.0
+--- org.ops4j.pax.swissbox:pax-swissbox-core:1.7.0
  +--- org.ops4j.pax.swissbox:pax-swissbox-lifecycle:1.7.0
  --- org.ops4j.base:ops4j-base-lang:1.4.0
+--- org.ops4j.pax.swissbox:pax-swissbox-tracker:1.7.0
  +--- org.ops4j.pax.swissbox:pax-swissbox-lifecycle:1.7.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  --- org.slf4j:slf4j-api:1.5.11 -> 1.7.5
+--- org.ops4j.base:ops4j-base-lang:1.4.0
+--- org.ops4j.base:ops4j-base-net:1.4.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  --- org.ops4j.base:ops4j-base-monitors:1.4.0
+--- org.ops4j.pax.url:pax-url-link:1.6.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  +--- org.ops4j.base:ops4j-base-util-property:1.4.0
  --- org.ops4j.pax.url:pax-url-commons:1.6.0
  +--- org.ops4j.base:ops4j-base-lang:1.4.0
  +--- org.ops4j.pax.swissbox:pax-swissbox-property:1.7.0
    +--- org.ops4j.base:ops4j-base-lang:1.4.0
    --- org.ops4j.base:ops4j-base-util-property:1.4.0
  --- org.slf4j:slf4j-api:1.5.11 -> 1.7.5
--- org.ops4j.pax.url:pax-url-classpath:1.6.0
+--- org.ops4j.base:ops4j-base-lang:1.4.0
+--- org.ops4j.base:ops4j-base-util-property:1.4.0
+--- org.ops4j.pax.swissbox:pax-swissbox-optional-jcl:1.7.0
--- org.ops4j.pax.url:pax-url-commons:1.6.0
```
Comment by Gradle Forums [ 13/Mar/14 ]

Same problem on gradle 1.11-rc1, any hint?

Comment by Gradle Forums [ 13/Mar/14 ]

Same result with gradle-1.11:

```
luca@juniper lb-axon]# gradle -version

------------------------------------------------------------
Gradle 1.11
------------------------------------------------------------

Build time: 2014-02-11 11:34:39 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421

Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy: 2.2.0
JVM: 1.7.0_51 (Oracle Corporation 24.51-b03)
OS: Mac OS X 10.9.1 x86_64

[luca@juniper lb-axon]# gradle :axon-osgi:test

  • What went wrong:
    Could not resolve all dependencies for configuration ':axon-osgi:testCompile'.
    > Could not resolve org.ops4j.pax.exam:pax-exam-spi:3.4.0.
    Required by:
    com.github.lburgazzoli:axon-osgi:1.0.0.SNAPSHOT > org.ops4j.pax.exam:pax-exam-junit4:3.4.0
    > Could not parse POM [1]http://repo1.maven.org/maven2/org/ops...
    > Unable to resolve version for dependency 'com.google.guava:guava:jar'
    > Could not parse POM /Users/luca/.m2/repository/org/ops4j/pax/exam/pax-exam-spi/3.4.0/pax-exam-spi-3.4.0.pom
    > Unable to resolve version for dependency 'com.google.guava:guava:jar'

```
----------------------------------------------------------------------------------------
[1] http://repo1.maven.org/maven2/org/ops4j/pax/exam/pax-exam-spi/3.4.0/pax-exam-spi-3.4.0.pom

Comment by Gradle Forums [ 13/Mar/14 ]

Same problem with 1.12 nightly :

```
------------------------------------------------------------
Gradle 1.12-20140307230018+0000
------------------------------------------------------------

Build time: 2014-03-07 23:00:18 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421

Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.7.0_51 (Oracle Corporation 24.51-b03)
OS: Mac OS X 10.9.2 x86_64

  • What went wrong:
    Could not resolve all dependencies for configuration ':axon-osgi:testCompile'.
    > Could not resolve org.ops4j.pax.exam:pax-exam-spi:3.4.0.
    Required by:
    com.github.lburgazzoli:axon-osgi:1.0.0.SNAPSHOT > org.ops4j.pax.exam:pax-exam-junit4:3.4.0
    > Could not parse POM [1]http://repo1.maven.org/maven2/org/ops...
    > Unable to resolve version for dependency 'com.google.guava:guava:jar'
    > java.lang.NullPointerException (no error message)

```

Is there anyone looking at this issue? It was working on 1.9 so it looks like a gradle bug.
----------------------------------------------------------------------------------------
[1] http://repo1.maven.org/maven2/org/ops4j/pax/exam/pax-exam-spi/3.4.0/pax-exam-spi-3.4.0.pom

Comment by Gradle Forums [ 13/Mar/14 ]

The problem is with guava version. It is specified in dependencyManagement of the parent pom under a profile. In Gradle 1.7 it used to fail guava resolution which I could easily fix by excluding guava from pax-exam-junit4 dependency and adding my own. In 1.10+ it fails to resolve pax-exam-spi. Exclusion of guava and even setting transitive to false does not work any more. As an experiment, I've added guava to pax-exam pom in my local Gradle cache. Works like a charm. Is there a better workaround except of deploying modified pax-exam in a local repo?

Comment by Adam Murdoch [ 06/Apr/14 ]

This is due to the 'glassfish3' profile not being used by default in the parent pom: http://repo1.maven.org/maven2/org/ops4j/pax/exam/3.4.0/exam-3.4.0.pom

Generated at Wed Jun 30 12:38:24 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.