Using Gradle 2.x and Maven plugin, how do I find the names of published poms?

plugins

(Jamie Cooper) #1

If I apply the ‘maven’ plugin, I get the ‘uploadArchives’ task, as well as getting a pom generated for my archive(s).

If I don’t do anything special, the pom on disk is ‘build/poms/pom-default.xml’

However, when the archive is uploaded, the pom is uploaded with it… only under a different name. Suppose my project was ‘p’, and the archive result was ‘p-1.0.0-SNAPSHOT.jar’. When that is published, the ‘pom-default.xml’ file is published with the jar as ‘p-1.0.0-SNAPSHOT.pom’.

I also know that you can set the name of the pom to generate, etc., etc.

What I need to be able to do, programmatically in a plugin, is find out which pom(s) got published, and the name(s) of said published items - both local and remote.

Where is this info?


(Jamie Cooper) #2

I cloned all of Gradle and started digging through the source to see if I could answer this myself.

I appears that when uploadArchives is called, it constructs an in-memory list of all the artifacts from the :archives configuration. I’m not sure yet why it creates its own list, unless it has to do with processing includes/excludes (which would make sense).

After it creates the list, it creates a new Artifact for the POM, constructing the name from fields inside the POM, and giving it the “.pom” extension. This new Artifact is added to the end of the artifacts list, and that list is then used to upload everything to the repository.

The question I still have is… can I access this list from a plugin? Or is it a transient that is thrown away once everything is uploaded? It appears to be the latter, so far.

This list would come in quite handy, as it is the ‘final’ list of everything uploaded, with all the data about those objects. Having the list available would mean I could get all that without having to re-implement building the list and the custom artifact, and possibly any include/exclude logic.


(Fredrik Wendt) #3

+1 - my use case is that I’d like to put this information (Group:Artifact:Version) in a file, and pass that file down a Continuous Delivery pipeline. Subsequent (downstream) steps in the pipeline could then use this file as a dependency management, or bill of materials-type of list.