Using the maven-publish plugin = no dependencies in pom.xml

Did this ever get resolved? I have the same problem in Gradle 1.10?

No. Overworked at my last job, I never had the free time to provide a good example of this. I’m finding a new position, now, with a much shorter commute. So, hopefully, I’ll be able to circle back and prove that Android AAR dependencies are not being included in the POM that gets produced by the ‘maven-publish’ plugin. As a work-around, we ended using “uploadArchives,” from the ‘maven’ plugin, instead.

Hi! to save other people’s time! Today experience same issue, using ‘maven-publish’ plugin, when running our multi project gradle build on my outdated (local) gradle v1.8, and fixed it by simply updating to gradle v1.12 !

(Note: I haven’ tested any intermediary versions)

I experience the same problem with gradle 2.2-rc2

I have a multiproject build: in the “main” gradle file I have:

subprojects{
 apply plugin: 'jacoco'
 apply plugin: 'java'
 apply plugin: 'eclipse'
 apply plugin: 'maven-publish'
   sourceCompatibility = 1.7
 targetCompatibility = 1.7
   publishing {
  publications {
   mavenJava(MavenPublication) {
    from components.java
   }
  }
      repositories {
   maven {
    credentials {
     username 'user'
     password 'password'
    }
    url "http://..../custom${version.contains('SNAPSHOT')?'-snapshot':''}"
   }
  }
 }
}

in the subprojects I have:

dependencies {
    compile 'org.apache.commons:commons-lang3:3.3.2'
    testCompile 'junit:junit:4.11',
            'org.hamcrest:hamcrest-all:1.3'
}

and

apply plugin: 'spring-boot'
  dependencies {
    compile project(':Project1')
 compile "org.webjars:angularjs:1.3.0-rc.4",
   "org.webjars:jquery:2.1.1",
      "org.springframework.boot:spring-boot-starter-web",
      "org.springframework.boot:spring-boot-starter-actuator"
    testCompile "org.springframework.boot:spring-boot-starter-test",
    "com.jayway.restassured:spring-mock-mvc:2.3.4"
 testCompile ("org.jmock:jmock-junit4:2.6.0"){
  exclude group: "junit"
 }
  }

publishing to maven local repo i get two POM files without dependencies

This is also still broken for us in gradle 2.2.

Definitely still a problem, i’ve been dealing with this all day. Any work arounds? I’m getting similar behavior with ‘maven’ plugin as well.

The ‘maven’ plugin should handle this just fine. I’m not aware of any problems there.

Ok, i’ve got a simple git project here https://github.com/NathanielWaggoner/AndroidExamples/tree/master/nodependenciesinpoms that recreates the problem i’m having. It’s the simplest recreation of the issue i can come up with. It might be that i’m just doing something wrong.

It should be ‘install { repositories.mavenInstaller { … } }’, not ‘android { task installArchives(type: Upload) { repositories.mavenInstaller { … } } }’. Check “53.6. Interacting with Maven repositories” in the Gradle User Guide and the self-contained samples in the ‘gradle-all’ download.

I’ll give that a go, thanks!

Something like :

apply plugin: ‘maven’

install {

repositories.mavenInstaller {

pom.version = “0.0.1-SNAPSHOT”

pom.artifactId = “lib2”

pom.groupId = “waggoner.android.examples”

} }

? I get "gradle DSL method not found ‘install()’ when i set it up like that.

Probably this only works together with the ‘java’ plugin, not with the Android plugin. You can try ‘task install(type: Upload) { … }’ (still outside the ‘android {}’ block), but perhaps you have to configure some additional stuff there.

Yea, switching to the java plugin causes the install task to function correctly. Dependencies get populated correctly and such. Is this the place to talk about the android plugin? Or do I need to head elsewhere?

Thanks for your help.

The ‘maven’ plugin can only automatically add dependency entries to the generated POM when used together with the ‘java’ plugin. For Android, I’d follow what’s described under “Library Publication” in the Android Build System Docs (http://tools.android.com/tech-docs/new-build-system/user-guide).

For Android specific questions, you can also try the Android tools list and Stack Overflow.

I’m experiencing the same problem with gradle 2.2 and compile project dependencies declared inside the subproject build.gradle files.

I am having this as well in gradle 2.2.1.

I experienced this problem as well with Gradle 2.2.1

As described by Daz it is indeed because something is invoking the “publications” block. In my case I traced it to a line that accessed ‘project.properties’

passphrase = project.properties.“signing.password”

I did this by dumping the stack and seeing where “publications” was being invoked from:

publishing {

println “CONFIGURING PUBLISHING”

Thread.dumpStack()

Changing the line to

passphrase = project.“signing.password”

Fixed the problem, but depending on the case this may or not be the solution.

Any update on this? I can confirm that this happens to me as well on 2.2.1 with the same project structure as above.

Graeme, I cannot figure out how your solution applies to the posts above. What is this “passphrase” thing?

I do not explicitly access the project properties in my top-level gradle.build although I have a “gradle.properties” alongside it that contains common version numbers used in the dependencies section of both the top-level build file and in the sub-projects ones.

GRADLE-2837 is reported as fixed pointing at your comment but, IMHO, it is far from it.

@Recent Posters. I ran into the same problem, but was able to work around it by putting my publishing.publication section in an afterEvaluate block.

I reported it as a new thread because this thread was about a different base issue.

http://forums.gradle.org/gradle/topics/maven-publish-pom-incorrect-unless-publications-is-in-afterevaluate?rfm=1

I’m developping gradle plugin and my build.gradle is like

apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'java-gradle-plugin'
publishing {
  publications {
    mavenJava(MavenPublication) {
      from components.java
    }
  }
}

when I run gradlew eclipse build publish… I correctly get all the gradleApi dependencies in my eclipse classpath, so they are correctly added in the compile configuration BUT when how can I add them in the generated maven POM ? Basically I’m using some guava classes in my plugin, and I’d like to add them in the generated jar.