@@ -50,28 +50,28 @@ tasks.withType(JavaCompile) {
5050}
5151
5252task sourcesJar (type : Jar , dependsOn : classes) {
53- group ' Build'
54- description ' Assembles a jar archive containing the sources.'
53+ group = ' Build'
54+ description = ' Assembles a jar archive containing the sources.'
5555 archiveClassifier = ' sources'
5656 from sourceSets. main. allSource
5757}
5858
5959task javadocJar (type : Jar , dependsOn : javadoc) {
60- group ' Build'
61- description ' Assembles a jar archive containing the JavaDoc output.'
60+ group = ' Build'
61+ description = ' Assembles a jar archive containing the JavaDoc output.'
6262 archiveClassifier = ' javadoc'
6363 from javadoc. destinationDir
6464}
6565
66- ext. signMethod = { jarfile ->
66+ ext. signMethod = { jarfile ->
6767 println " Signing $jarfile "
6868 def SIGNING_SERVICE = ' https://cbi.eclipse.org/jarsigner/sign'
6969 def STDOUT_FORMAT = ' %{size_upload} bytes uploaded, %{size_download} bytes downloaded (%{time_total} s)\\ n'
7070
71- ProcessBuilder curl_pb = new ProcessBuilder (" curl" ,
71+ ProcessBuilder curl_pb = new ProcessBuilder (" curl" ,
7272 " --fail" , " --silent" , " --show-error" , " --output" ,
7373 " ${ jarfile} -signed" , " --form" , " file=@${ jarfile} " ,
74- " --write-out" , STDOUT_FORMAT ,
74+ " --write-out" , STDOUT_FORMAT ,
7575 SIGNING_SERVICE );
7676 println String . join(" " , curl_pb. command());
7777 curl_pb. directory(new File (" ${ project.buildDir} " ));
@@ -82,26 +82,31 @@ ext.signMethod = { jarfile ->
8282 println curl_process. text
8383
8484 if (curl_process. exitValue() != 0 ) {
85- throw new GradleException (" Failed to run curl" );
85+ throw new GradleException (" Failed to run curl" );
8686 }
8787
88- ProcessBuilder mv_pb = new ProcessBuilder (" mv" ,
88+ ProcessBuilder mv_pb = new ProcessBuilder (" mv" ,
8989 " ${ jarfile} -signed" , jarfile)
9090 println String . join(" " , mv_pb. command());
9191 mv_pb. directory(new File (" ${ project.buildDir} " ));
9292 Process mv_process = mv_pb. start()
9393 mv_process. waitFor()
9494
9595 if (curl_process. exitValue() != 0 ) {
96- throw new GradleException (" Failed to run mv" );
96+ throw new GradleException (" Failed to run mv" );
9797 }
9898}
9999
100100task signJar (description : ' Sign JARs with Eclipse Signing Service' , group : ' Build' ){
101- doLast {
102- signMethod(" ${ project.buildDir} /libs/${ project.name} -${ project.version} .jar" )
103- signMethod(" ${ project.buildDir} /libs/${ project.name} -${ project.version} -sources.jar" )
104- signMethod(" ${ project.buildDir} /libs/${ project.name} -${ project.version} -javadoc.jar" )
101+ def projectBase = " ${ project.buildDir} /libs/${ project.name} -${ project.version} "
102+
103+ // Declare inputs/outputs for config-cache friendliness
104+ inputs. property(' projectBase' , projectBase)
105+
106+ doLast {
107+ signMethod(" ${ projectBase} .jar" )
108+ signMethod(" ${ projectBase} -sources.jar" )
109+ signMethod(" ${ projectBase} -javadoc.jar" )
105110 }
106111}
107112signJar. dependsOn jar, sourcesJar, javadocJar
0 commit comments