[GRADLE-1997] Dependencies declared as part of a POM profile marked with activeByDefault are not parsed and resolved Created: 12/Dec/11  Updated: 29/Jul/14  Resolved: 25/Mar/14

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

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


 Description   

It seems to me that gradle does not download per default the transitive dependencies from a maven repo when they are defined in a profile section of a pom. Am I missing a configuration? Or can I somehow define which profile should be taken?
An example is

group: 'com.sun.jersey.jersey-test-framework', name: 'jersey-test-framework-grizzly2', version: '1.10'

which has a default profile section with two dependencies:

<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2-servlet</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>

Both of them I don't see in the dependency tree.



 Comments   
Comment by Gradle Forums [ 12/Dec/11 ]

This sounds like a bug to me: I'll raise an issue in Jira.

Comment by Matteo Barbieri [ 09/Feb/12 ]

Also affects constretto using this pom
https://github.com/constretto/constretto-core/blob/master/pom.xml

Comment by Douglas Borg [ 22/Mar/13 ]

This issue (as manifested with the jersey project) has bit us as well. It seems like Gradle should pay attention to dependencies declared in profiles that have the <activeByDefault>true</activeByDefault> property set.

Comment by rapilabs [ 18/Oct/13 ]

This caught me out as well... I thought it was a bug with JetGradle as I thought there's no way this wonderful tool could have a flaw

Comment by nabedge [ 31/Dec/13 ]

I also need "profile" functionality of maven.

In my case, I use log4jdbc library. http://code.google.com/p/log4jdbc/
This library is only for debug & develop environment, not for integration test or production.
So, I wrote pom.xml for maven like below.


<profiles>
<profile>
<id>ut</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.lazyluke</groupId>
<artifactId>log4jdbc-remix</artifactId>
<version>0.2.7</version>
</dependency>
</dependencies>
</profile>
</profiles>


By this profile config, the log4jdbc-0.2.7.jar will not be include in jar/war package
but I can use log4jdbc on my eclipse.

I home that Gradle support this functionality.

Comment by Sean Griffin [ 05/Mar/14 ]

As mentioned over on http://forums.gradle.org/gradle/topics/gradle_does_not_appear_to_read_properties_defined_in_maven_profiles, this affects not just dependencies but properties, too, and is particularly critical when those properties are necessary to figure out which dependencies to resolve.

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