How do I get rid of version numbers and unspecified on Java plugin jars


(graham) #1

Hi

I have a gradle build file. It uses the Java plugin and does not specify a version number for the jars being produced. As a result all my jars get produced as X-unspecified-jar, where X is my project name.

How do I get rid of the “-unspecified” part? I don’t want to manage versioning in my build file, I do it externally.

I simply want to produce X.jar.

thanks graham


(Peter Niederwieser) #2
jar {
    version = null
}

Nevertheless I recommend to set ‘project.version’, as Gradle uses this information in many places. You can set it to an external value (e.g. environment variable or system property).


(graham) #3

Umm that produces X-unspecified.jar as the output jar.


(Peter Niederwieser) #4

Not for me. Actually, unless you set ‘project.version’, you shouldn’t have to do anything to get ‘X.jar’. Which Gradle version? Can you share a self-contained build script that allows to reproduce the problem?


(graham) #5

Is there some potential caching issue here?

gradle -version

------------------------------------------------------------ Gradle 1.4 ------------------------------------------------------------

Gradle build time: Monday, January 28, 2013 3:42:46 AM UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.8.4 compiled on May 22 2012 Ivy: 2.2.0 JVM: 1.7.0_21 (Oracle Corporation 23.21-b01) OS: Mac OS X 10.7.5 x86_64

A self contained build file is a bit hard to come up with here – it’s a large build. The part of my build file that configures my java plugin is as follows

// // Project types //

def javafx_projects = [project(‘preinfoview’), project(‘infoview’)] def ws_client_projects = [project(‘ClassicModelsWS_Client’), project(‘InfoForgeWebService_Client’)] def java_projects = subprojects - ws_client_projects - [project(‘InfoForgeWebService_GF3’)]

// // Project configurations //

configure(java_projects) {

proj ->

apply plugin: ‘java’

sourceSets.main.java.srcDirs = [SRC + proj.name + ‘/src/’]

buildDir = TMP + proj.name

repositories

{

flatDir

{

dirs libBase

dirs EEBase

dirs fxBase1

dirs fxBase2

}

}

uploadArchives

{

repositories

{

flatDir { dir OUTPUT }

}

} }

project(’:cli’) {

dependencies

{

compile project(’:util’)

compile project(’:infoforge-api’)

} }

graham


(Peter Niederwieser) #6

Works fine for me with 1.4 as well. Chances are that something in your build scripts (or third-party plugins) is causing this. You can try to override the whole archive name:

jar {
    archiveName = "X.jar"
}

(graham) #7

I don’t mention version numbers anywhere else in the build scripts.


(Peter Niederwieser) #8

Doesn’t necessarily have to be version number. If overwriting ‘archiveName’ doesn’t work either, your best chance is to shrink the build until you’ve found the cause. Also make sure you don’t have anything in ‘~/.gradle/init.gradle’ and aren’t using a custom Gradle distribution.


(graham) #9

To be more precise that is the only project setup code I have anywhere in the build file.

Are there some gradle caches I could nuke to rule them out?


(Peter Niederwieser) #10

‘.gradle/’ in the root project dir and ‘~/.gradle/caches/’. (You might want to keep the “artifacts-xy” dirs, or external dependencies will be downloaded again.) You can verify Gradle’s default behavior with a build whose ‘build.gradle’ just contains ‘apply plugin: “java”’ (no need for source dirs etc.). Then run ‘gradle build’ and look into ‘builds/lib’.


(graham) #11

The default config makes X.jar files, but somehow the uploadArchive part puts the -unspecified.jar on the end of them


(Peter Niederwieser) #12

So you are talking about the ‘uploadArchives’ task? That wasn’t clear to me.


(graham) #13

The configuration given above does as you say produce files of the form X.jar in the build directory.

But somehow the uploadArchives part of it seems to put the -unspecified stuff on the end of the jars.

I hadn’t previously realized that the first step was producing X.jar files, and that the issue was then in the uploadArchives part.


(Kharla Estomata Rita) #14

HOW CAN I CHANGE MY USER NAME…ALWAYS INSPICIED PLS I NEED YOUR HELP


(Jean-Michel Cazaux) #15

I would be interested in a solution as well…