Changing module name with Ivy publishing

(Christian Möller) #1

Prototyping Gradle with our projects I’m facing the following problem concerning the publication of artifacts to our Ivy repository: The default uploadArchives task takes module’s name from the name of the folder the build is executed in - or in Gradle parlance the value from “”. Explicit definition of an archivesBaseName property - like here:

group = 'my-group'
archivesBaseName = 'my-base-name'

does not change that behaviour. Issuing “gradle clean build uploadArchives” within my local workspace’s folder WORKSPACE-DIR produces an ivy.xml containing the following “info” XML element:

<ivy-module version="2.0" xmlns:m="">
        <info organisation="my-group"

First of all this is not intended, I would expect to get the value of “archivesBaseName” property here. The second problem arises if applying some kind of CI server - like Jenkins for instance: Jenkins per default checks out the code to folders called “workspace”; issuing “gradle clean build uploadArchives” there - by hand or by Jenkins - yields this ivy.xml:

<ivy-module version="2.0" xmlns:m="">
        <info organisation="my-group"

This behaviour of the upload task is described here, but I would like to change it - because of the mentioned reasons :slight_smile:

My “uploadArchives” task is configured like that (for debugging purposes I’m using a local ivy repo here):

uploadArchives {
  repositories {
    flatDir {
      name = 'upload'
      dirs 'upload-ivy-repo'


There is not currently any way to publish to an ivy repository using a module name different to the project name. We are working on a new ‘ivy-publish’ plugin which will eventually address this, but for now you need to use the workaround described in GRADLE-2344.

I’m guessing it’s the root project you want to rename, so use the following in your settings.xml = "my-base-name"

To do something similar for a subproject, use:

project(":sub-project-dir").name = "my-subproject-name"

(Christian Möller) #3

Thanks for your help, it works as expected. Well, the comment you pasted more looks like Groovy syntax than XML, so I put it to a file “settings.gradle” instead of “settings.xml” :slight_smile:


Yep that will probably work even better :slight_smile:

(vladimir.ovod) #5

There is not currently any way to publish to an ivy repository using a module name > different to the project name. We are working on a new ‘ivy-publish’ plugin which will

eventually address this, …

Daz, is this already addressed in the ‘ivy-publish’ plugin or the workaround is still valid?

Thank you.


So close! Gradle 1.7 will contain the ability to customise the coordinates of an IvyPublication using the ‘ivy-publish’ plugin. Expect to see ‘gradle-1.7-RC1’ some time next week, or you can use a nightly build.

(vladimir.ovod) #7

Great news! Thank you, Daz.

(blackbeltdev) #8

I have a similar problem. I’m able to set the module name with Gradle 1.7 just fine but I couldn’t figure out a “clean” way to set the artifact name. Basically I want the artifact name to match the archivesBaseName rather than the module name (which I think it is defaulting). The following works but is really ugly. There’s got to be a better way.

Any advice?


archivesBaseName = 'textura-core-security-service-api'
  publishing {
    publications {
        ivy(IvyPublication) {
            module 'security-service-api'
  publishing.publications.ivy.artifacts*.name = archivesBaseName

root project build.gradle:

allprojects {
      group = 'com.textura.core'
      publishing {
        publications {
            ivy(IvyPublication) {
                artifact(sourceJar) {
                    type "source"
                    conf "runtime"

Yields what I want in the end:

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="">
  <info organisation="com.textura.core" module="security-service-api" revision="1.0.0.Final" status="integration" publication="20130819130355"/>
    <conf name="default" visibility="public" extends="runtime"/>
    <conf name="runtime" visibility="public"/>
    <artifact name="textura-core-security-service-api" type="jar" ext="jar" conf="runtime"/>
    <artifact name="textura-core-security-service-api" type="source" ext="jar" conf="runtime" m:classifier="source"/>
    <dependency org="org.slf4j" name="slf4j-api" rev="1.7.5" conf="runtime-&gt;default"/>
    <dependency org="org.apache.commons" name="commons-lang3" rev="3.1" conf="runtime-&gt;default"/>
    <dependency org="" name="guava" rev="14.0.1" conf="runtime-&gt;default"/>
    <dependency org="" name="spring-security-core" rev="3.1.4.RELEASE" conf="runtime-&gt;default"/>