Hello fellows,
I commented in netmikey’s post [http://forums.gradle.org/gradle/topics/gradle_1_9_dependency_resolution_issue_if_artifact_present_in_multiple_scopes_within_the_pom] the other day about Maven dependencies in Gradle 1.9+ not working entirely satisfactory.
See the examples in the other post.
Having further investigated the problem from what I can see my issue boils down to the generated pom.xml not correctly containing the classifier when generating the pom.xml file based on project dependencies. When generating a pom any classifier specified as external module dependencies translates into the pom, for project dependencies it does not.
I dont think it ever has for project dependencies, but Gradle 1.8- made it work anyway. Now with the stricter/correct pom interpretation it does not work.
External dependencies block and pom.xml:
dependencies {
compile 'deptest.B:B:1.0'
testCompile 'deptest.B:B:1.0:test'
}
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>deptest.D</groupId>
<artifactId>C</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>deptest.B</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>deptest.B</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Project dependencies block and pom.xml:
dependencies {
compile project(":A")
testCompile project(path: ":A", configuration: 'testRuntime')
}
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>deptest.B</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>deptest.A</groupId>
<artifactId>A</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>deptest.A</groupId>
<artifactId>A</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
No classifier on the test scope even though it is specified on the test-jar.
In the testRuntime configuration I have placed a test-artifact for test-dependencies used as above. The classifier linked to this artifact however does not translate into the pom which cause the latest entry in pom per artifact priority issue.
Thank you, Stefan