I have just upgraded my projects to use the maven-publish plugin instead of the maven plugin. Previously (with the maven plugin) I build my projects with:
As a result an artifact and a pom.xml where uploaded to our internal repository. The generated pom.xml file would contain all the dependencies, making it possible for “clients” to get all transitive dependencies when downloading the published artifact.
Now I build with:
gradle clean --refresh-dependencies publish
but the generated pom.xml file does not contain any dependencies only the coordinates for the artifact it self. What has changed in how the generated pom.xml file is published?
Your project POM should get all of the dependencies added to the ‘runtime’ configuration (and by extension the ‘compile’ configuration as well). It’s worth printing out the contents (from inside the publishing block).
The reason for doing this inside the publishing block is that the dependencies must have been added to configuration at the time that the publishing block is evaluated. The ‘publishing’ block is configured late, but any direct access to ‘project.publishing’ can force it’s evaluation.
I am running into the same problem with 1.7-rc-1. My maven publication configuration is identical to the one posted above. My build.gradle (which is for a subproject) looks like this:
I’ve just tested my build script above with both ‘gradle-1.6’ and ‘gradle-1.7-rc-1’. It’s behaving correctly for me in both instances.
Can you confirm that this is indeed a problem, and provide a complete, self-contained example (like the one I presented)? It might also be worth running with --info to see if that gives any hints.
The minimal reproduction recipe I provided above is as self-contained as I can get it. Crucially, if I flatten everything into a single build script (as you did above), the problem disappears. Can you try structuring the build.gradle scripts as I did above?
I’ve split the build scripts out, and now I can replicate the behaviour you’re seeing. I’ll have to investigate further, but this does seem to be a regression in 1.7-rc-1.
I’ll get back once I’ve worked out what’s going on.
I’m using gradle 1.10 and experiencing this same regression from 1.7-rc-1. If we use the ‘maven’ plugin then it generates our poms correctly. However, if we use the ‘maven-publish’ plugin, then it exhibits the bug described in GRADLE-2837.
The problem we’re having is that we’re using the ‘publishToMavenLocal’ functionality of the ‘maven-publish’ plugin so that developers can work on feature branches without pushing those versions to the shared maven repo.
However, when that feature work is complete and we run “gradle clean build publish” it doesn’t include the dependencies properly, in the same way described in this thread.
GRADLE-2837 was fixed in Gradle-1.7-rc-2 (and final). It’s likely you’re seeing a different problem.
Please create a new forum entry describing your problem in detail, including the way your dependencies are being declared and the actual pom file output you’re getting.
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.