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

**URL:** <https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564>\
**Category:** Old Forum Archive\
**Created:** [May 15, 2013, 10:05am UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564 "2013-05-15T10:05:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![j\_serup](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@j\_serup](https://discuss.gradle.org/u/j_serup)\
**Post date:** [May 15, 2013, 10:05am UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564/1 "2013-05-15T10:05:00Z")

</div>

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:

```gradle
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:

```gradle
<dependency>
   <groupId>com.samples</groupId>
   <artifactId>local-gradle-project</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </dependency>

```

but it fails to resolve with:

```gradle
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:

```gradle
.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?

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [May 15, 2013, 10:11am UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564/2 "2013-05-15T10:11:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![j\_serup](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@j\_serup](https://discuss.gradle.org/u/j_serup)\
**Post date:** [May 15, 2013, 10:40am UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564/3 "2013-05-15T10:40:00Z")

</div>

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

```gradle
apply plugin: 'maven'

```

instead of:

```gradle
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:

```gradle
maven-metadata.xml

```

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

```gradle
maven-metadata-local.xml

```

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

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [May 15, 2013, 10:43am UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564/4 "2013-05-15T10:43:00Z")

</div>

I think you’re hitting this issue: [http://forums.gradle.org/gradle/topics/maven\_publish\_plugin\_publishes\_snapshot\_versions\_to\_mavenlocal\_using\_setunique\_true](http://forums.gradle.org/gradle/topics/maven_publish_plugin_publishes_snapshot_versions_to_mavenlocal_using_setunique_true)

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

---

<div class="post-metadata">

**Author:** ![j\_serup](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@j\_serup](https://discuss.gradle.org/u/j_serup)\
**Post date:** [May 15, 2013, 11:04am UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564/5 "2013-05-15T11:04:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [May 15, 2013, 12:37pm UTC](https://discuss.gradle.org/t/cannot-depend-on-a-project-published-with-maven-publish/6564/6 "2013-05-15T12:37:00Z")

</div>

Until we fix GRADLE-2762, you could use this workaround: [http://forums.gradle.org/gradle/topics/override\_location\_of\_the\_local\_maven\_repo](http://forums.gradle.org/gradle/topics/override_location_of_the_local_maven_repo)
