Using a single build script to create and publish multiple artifacts to Artifactory

Hello -

I have a project that looks something like this: myProj

|-src/client/java

|-src/shared/java

|-src/server/java

Out of this project, I create 2 distinct jars: myProj-client.jar and myProj-server.jar. The shared source shows up in both client and server jars. Also note that both of these jars also have accompanying javadoc and sources jars.

I would like to use Gradle and the Artifactory plugin to publish these 2 artifacts using the same group and version, but a different module name.

For example: group: ‘com.myproj’ name: ‘mProj-client’ version: ‘1.0’ group: ‘com.myproj’ name: ‘mProj-server’ version: ‘1.0’

I am building these jars using Configurations, for example: task clientJar(type: Jar, dependsOn: compileClientJava) {

baseName = ‘myProj-client’

from sourceSets.client.output

from sourceSets.shared.output }

So, my questions are 2 fold:

  1. Why is it that the artifactory plugin uses “myProj-[version].pom” instead of “myProj-client-[version].pom” when trying to upload? 2. Why am I getting the error: Failed to deploy file: HTTP response code: 409. HTTP response message: Conflict

If there is a wiki or guide to creating this type of setup, I’d be happy to read it. But I’ve had trouble finding documentation on this.

Any and all help is much appreciated.

Lavie

ad 1. Which Gradle version are you using? This was a common problem prior to 1.1 or so. ad 2. My guess is that the error is related to 1.; for example, maybe it’s trying to upload ‘myProj-[version].pom’ twice. Check the stack trace (’-s’), info log (’-i’), and debug log (’-d’) for useful information.

Regarding documentation, the Artifactory plugin is a third-party plugin and docs can be found here: http://wiki.jfrog.org/confluence/display/RTF/Gradle+Artifactory+Plugin

Hi Peter -

Thanks for the response. I’ve read over that JFrog page many times. I’m starting to think that maybe the uploadArchives task is the better approach for my particular problem. Any thoughts on that?

Lavie

I can’t tell because I don’t have enough information. I don’t think your problem is particularly related to the Artifactory plugin. Again, which Gradle version are you using?

I just changed over to version 1.2 (I was on 1.1 at the time I wrote this post).

What other information would help?

I’d give the “native” Gradle solution a try and see whether the ‘myProj-[version].pom’ problem persists. Publishing multiple Maven modules from a single Gradle project is somewhat tricky, but hopefully the Gradle User Guide will show you the way.

Yea, I’ll give that a try. Thanks for your help.

Hi, I have the exact same problem as the original poster with gardle(1.5). Does someone have a solution for publishing to artifactory from a build file that generate multiple jars? Please help.

Thanks, Prantor

The original post was about using the Artifactory plugin.

What exactly are you having problems with. If it’s just generically uploading multiple jars there are many examples of this on the web (mostly within this forum).

My problem is same as the original poster’s question: >>Why is it that the artifactory plugin uses “myProj-[version].pom” instead of “myProj-client-[version].pom” when trying to upload?

The jars in artifactory goes into the wrong folder structure. If your project name is P and you are creating two jar(P and X) from the project. Inside artifactory both P.jar and X.jar will go under the name P(like P/P.jar P/X.jar) instead of being like P/P.jar and X/X.jar.

Thanks, Prantor

You’ll have to ask the authors of the Artifactory plugin.