When I do a publish, Gradle is informing me that it has published my (snapshots) to Artifactory. However, when I go and look at artifactory and the POM, this is all I see:
There are no dependencies listed at all. Thus, when I import the fubar-common jar into another Gradle project, no dependencies are resolved.
I’m at a loss. I even tried removing the commonJar task and using “from components.java” in the publications block with the same result. I also did a “println configurations.runtime.allDependencies” in the publications block and nothing is output. Very weird (since I do have dependencies in this project…)
If you are running the task by invoking “gradle publish”, you might want to try to be more specific, such as “gradle publishCommonPublicationToMavenRepository”
In addition, does the output of generatePomFileForCommonPublication (build/publications/common/pom-default.xml) list all relevant dependencies?
Thank you for your reply. I tried “gradle clean publishCommonPublicationToMavenRepository” command and still the POM does not include dependencies. The output of build/publications/common/pom-default.xml is the same as the one above, i.e.,
For each project this results in 2 jars, one compiled jar (with dependencies defined in the pom) and a sources jar.
“from components.java” results in the compiled jar (with correct pom) The “artifact” block adds another jar to the publication (a publication can span multiple artifacts)
I’m pretty sure the “from components.java” is pretty much mandatory, judging from section 65.2.1 in the user guide, this causes the publication to include the runtime dependencies.
You’re doing a couple of things wrong: - You’re creating 2 publications with the same GAV to publish 2 artifacts. This isn’t allowed. Instead, you should create a single publication and add multiple artifacts to it. - You’re not telling Gradle what the dependencies should be. The common way to do this is to use ‘components.java’ as mentioned by Rolf. I’d suggest checking out the [User Guide Chapter on the maven-publish plugin](http://www.gradle.org/docs/nightly/userguide/publishing_maven.html) to get a better feel for how the new publishing stuff works.
Thank you for your reply. I’ll try out your suggestion with doing a single publication.
A question however, I want to be able to filter the artifact that is created (hence the reason why I have a custom commonJar task that filters out some fubar stuff. I can’t seem to do this if I use components.java since it includes everything. Perhaps again, I’m doing it wrong? Can I filter at the components.java level as well?
This uploads the classes jar and also the sources jar successfully AND creates the POM for me with dependencies. However, the classes jar contains classes that I don’t want included (hence the reason I had a custom commonJar Task:Jar above, to filter out classes I don’t want (fubar)). If I remove the “from components.java” and use “artifact commonJar” derived from the task, then my classes jar is filtered as I expect but when uploaded an empty-without-dependencies POM is created!
So, how do I upload a jar, filtered with excluded classes and either A) use “from components.jar” or B) use artifact commonJar within the publications block!