In a project at our company one team uses a maven project of type pom to group a couple of other dependencies. When using maven, one can use this dependency with
<dependency>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>version</version>
<type>pom</type>
</dependency>
but in gradle, using
compile "group:artifact:version@pom"
does not work. I have to use
compile "group:artifact:version"
But when I define a dependency to another maven project, which does also have a dependency on the pom-type project, things go strange. Configurations.compile does not only contain jars, but also the pom
Example:
pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>gradlepomdependency</groupId>
<artifactId>gradlepomdependency</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>all</artifactId>
<version>1.5.0</version>
<type>pom</type>
</dependency>
</dependencies>
</project>
build.gradle:
apply plugin: 'java'
apply plugin: 'maven-publish'
repositories {
jcenter()
mavenLocal()
}
dependencies {
compile 'gradlepomdependency:gradlepomdependency:0.0.1-SNAPSHOT' // @pom does not work
}
task listDependencies << {
configurations.runtime.each System.out.&println
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
=> gradle listDependencies does list one pom and one jar, it should only contain the jar.
=> The generated maven pom file in generatePomFileForMavenJavaPublication does not define pom. The dependency will most probably not work when used from maven.