I have a gradle project that also contains a pom.xml (since we need to use m2e). When I build this project I need to use the existing pom.xml file instead of the one generated by Gradle. I use the ‘maven-publish’ plugin and configure my publications:
publishing {
publications {
maven(MavenPublication) {
pom.withXml { provider ->
def builder = provider.asString()
builder.length = 0
builder.append(file("pom.xml").text)
}
from components.java // Make sure the classes is also added to the jar file
}
}
...
When I build with ‘gradle clean publishToMavenLocal’ jar and pom.xml files are installed into .m2. I have another plain maven project where I need to depend on the above installed artifact:
<dependency>
<groupId>com.samples</groupId>
<artifactId>local-gradle-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
but it fails to resolve with:
Missing artifact com.samples:local-gradle-project:jar:1.0.0-SNAPSHOT
I have noticed that the META-INF folder is empty in the installed archive:
.m2\repository\com\samples\local-gradle-project\1.0.0-SNAPSHOT\local-gradle-project-1.0.0-20130515.090150-1\META-INF
In a plain maven project this folder contains a ‘maven’ folder with the pom.xml.
Have dependencies for artifacts installed with ‘maven-publish’ been tested/expected to work?