Cannot depend on a project published with 'maven-publish'

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
      from // 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:


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:


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?

The META-INF thing is a red herring I think. I’m not aware of any part of the Maven protocol that requires the pom in the META-INF dir, or any tooling that uses it.

As for the missing artifact, can you please run with ‘-I’ so we can see where it is trying to find the artifact.

I guess you mean -X (in maven)? It simply point to the repo that I mirror in the settings.xml file. If I use:

apply plugin: 'maven'

instead of:

apply plugin: 'maven-publish'

and build with ‘install’ it works (the installed artifact can be seen from my external maven project).

I have found the following difference. In the artifact installed with ‘maven-publish’ plugin:


In the artifact installed with ‘maven’ plugin (or when installing a plain maven project with mvn) its called:


It does not help to rename it manually.

I have also tried to build a gradle project using the maven-publish plugin WITHOUT specifying pom.withXml and get the same problem

I think you’re hitting this issue:

Is there any way you could try with a non snapshot version to rule this in/out?

If I remove the SNAPSHOT qualifier it works.

The reason why we would like to use the maven-publish plugin is that it makes it possible to avoid installing into .m2. When using the maven plugin and running the ‘uploadArchives’ task artifacts also get installed with a unique timestamp corresponding to the above described problem.

Until we fix GRADLE-2762, you could use this workaround: