Gradle-1.12 rhel 5.4 task type jar with classifier set keeps leaving behind a file named classifier.jar


(Brian Brooks) #1

Thanks for gradle. The build.gradle files are definitely more readable than maven pom.xml and ant build.xml files.

Regrettably, I still have to package maven jars and publish items to maven repos. I’m currently trying to use gradle to automate creation of a jar file needed when doing native compiling elsewhere. My goal is for build.gradle to create a jar named OpenSSL-linux32-0.9.8e.jar and publish it in a private maven repo.

I mostly have the build.gradle script worked out but I’ve run into something that has me stumped: why would the following build.gradle produce a file named linux32.jar in the folder where gradle is run? I’d like to either suppress creation of this jar or at least name is something like OpenSSL-linux32-0.9.8e.jar. I tried setting the name and archivesBaseName but neither seemed to govern the name used for this jar.

apply plugin: 'maven-publish'
  ext {
        myversion= '0.9.8e'
}
  group = 'OpenSSL'
version = myversion
  publishing {
     repositories {
       mavenLocal()
   }
                       publications {
                OpenSSL(MavenPublication) {
                        artifact OpenSSLJar
           artifact OpenSSLinczip
       }
        }
     }
  task OpenSSLJar(type: Jar) {
    ext.openssl = 'OpenSSL-linux32-'+myversion
    classifier 'linux32'
    from('/usr/lib') {
        into openssl+'/lib'
                include 'libssl.a'
        include 'libcrypto.a'
        include 'libssl.so'
        include 'libcrypto.so'
    }
  }
  task OpenSSLinczip(type: Zip) {
    ext.packaging='inczip'
    extension 'inczip'
    from('/usr/include') {
        include 'openssl/**'
    }
}

I’m using gradle on RedHat Linux 5.4. Here is the version info

------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------
Build time:
 2014-04-29 09:24:31 UTC
Build number: none
Revision:
   a831fa866d46cbee94e61a09af15f9dd95987421
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:
        2.2.0
JVM:
        1.7.0_51 (Oracle Corporation 24.51-b03)
OS:
         Linux 2.6.18-164.el5 i386

(Peter Niederwieser) #2

Without applying at least the ‘base’ plugin, you won’t get defaults for a Jar’s/Zip’s ‘destinationDir’ and name-related properties, and you’ll have to configure these properties manually. For example:

task OpenSSLJar(type: Jar) {
    destinationDir = file("archives")
    // alternatively, you can set individual name parts
     // such as 'baseName' and 'classifier'
    archiveName = "OpenSSL-linux32.jar"
     ...
}

(Brian Brooks) #3

Thanks, Peter. As you suggested, applying the base plugin works well for me.

apply plugin: 'base'