Publish several poms with different artifactId

Hi,

I have a regular gradle project which generates several jars and poms. The particularity is that the generated poms can have different artifactId or groupId from the current project. The default jar task is disabled so I can control the generation of the jars.

After the build process, my output folder looks like this: build/libs/artifact-a/artifact-a.jar build/libs/artifact-a/pom.xml build/libs/artifact-b/artifact-b.jar build/libs/artifact-b/pom.xml

I added those extra artifacts in the artifacts{} configuration and added filters for mavenDeployer and mavenInstaller.

Let’s consider that my gradle project is configured with artifactId=‘artifact-a’, after the artifactoryPublish execution, all these files will be uploaded to the same path on Artifactory (groupId/artifact-a/version/…). Indeed I’d like those artifacts to be uploaded in two different folders: groupId/artifact-a/version/… groupId/artifact-b/version/…

I’m not really sure how to tackle this problem, I’m thinking about creating a publish task for each groupId/artifactId, and point to the right pom.xml each time, using the mavenDescriptor variable.

Has anybody tried/achieved something similar?

Thanks, Jérémy

First you mention configuring ‘mavenDeployer’ and ‘mavenInstaller’, but you also mention ‘artifactoryPublish’. Are you publishing using the built-in ‘Upload’ task and the Maven Plugin, or are you using the Artifactory Plugin?

I’m not familiar with the Artifactory Plugin, but you should be able to achieve what you want with the Maven Plugin. The way this is normally done is by having a multiproject build with 2 separate subprojects to produce the different artifacts. This allows you to use the default jar task, and publishing will “just work”.

You should also be able to get it working in a single project by:

  1. Set the ‘baseName’ property appropriately for each artifact task.

  2. Add the separate artifacts to different configurations in the ‘artifacts’ block

artifacts {
    configA artifactA
    configB artifactB
}
  1. Configure the 2 separate ‘Upload’ tasks with the appropriate artifactId:
uploadConfigA {
    repositories {
        mavenDeployer {
            ... other config
            pom.artifactId = 'artifact-a'
        }
    }
}

I realise that publishing with Gradle is not always clear and straightforward. This is why we’re currently working on a brand new publishing infrastructure. It doesn’t yet allow for the publication coordinates to be customised, but I expect that this ability will be in Gradle 1.5. No promises, of course!

I was trying to use the Artifactory Plugin, but now I’m using the maven plugin as you suggested and it works like a charm :slight_smile:

Thank you for the quick answer, and I’m looking forward version 1.5.