Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using archivesBaseName in a gradle project has no effect

Tags:

gradle

groovy

I'm trying to name the artifact that gets built by gradle. Look at this build.gradle:

archivesBaseName='this_is_ignored'
apply plugin: 'groovy'
archivesBaseName='this_is_also_ignored'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.+'
}

I also tried in gradle.properties:

archivesBaseName=`this_is_ignored_too`

In every case ./gradlew build generates a .jar file based on the folder where the project resides (which as I understand it is project.name, I was just hoping to override that with archivesBaseName).

In other words, I want:

~/gradle-helloworld > ./gradlew build

to generate this_is_ignored.jar, but it's generating gradle-helloworld.jar instead.

Any ideas?

like image 924
Joe Avatar asked Sep 23 '13 17:09

Joe


1 Answers

(Turning Peter's comment into a CW answer.)

If you set archivesBaseName before applying the plugin, you'll introduce a dynamic property (which gives a deprecation warning). This dynamic property will then shadow the one introduced by the plugin, which is why the second assignment doesn't have the desired effect either. The solution is to only set the property after applying the plugin.

like image 127
2 revs Avatar answered Nov 13 '22 04:11

2 revs