Jar signing task is not signing the jar


(Anant Navagale) #1

I want to sign the jar when jar task is executed. My jar task is :

jar{
printTaskName
    manifest {
  def manifestClasspath = ''
  if ( System.properties['_isWar'] == false)
  {
      manifestClasspath = ". " + configurations.runtime.collect { "lib/" + it.getName() }.join(' ')
  }
  attributes 'Copyright': System.properties['_my_copyright'],
   'Build-Number': System.properties['_release_version'],
   'Build-Date': System.properties['_release_date'],
  'Hotfixes-No': '',
  'Class-Path': manifestClasspath,
  'Main-Class': mainClassName
      }
}
  task callSignJar(dependsOn: jar){
apply from: '../signing.gradle'
}
  /////////////////signing.gradle file
apply plugin: 'java'
  def signTheJar ={task signTheJar(type:Exec){
println "Signing jar " + jar.archivePath
  executable 'jarsigner'
args '-keystore', System.properties['signing_keystore']
args '-storepass', System.properties['signing_password']
args jar.archivePath
args System.properties['signing_alias']
args '-verbose'
//commandLine 'java'
//args '-version'
}}

When I run

gradle callSignJar

It signs the jar correctly. But when I run entire build

gradle build

It calls the task but do not signs the jar. Can anyone correct me where I am wrong ?


(Luke Daley) #2

You will need to add:

build.dependsOn “signTheJar”