shemnon avatar shemnon committed 5df3dae

move signJar to use PackagerLib directly
This includes camelCasing some of the params and renaming a few

Comments (0)

Files changed (6)

plugin/src/main/groovy/com/bitbucket/shemnon/javafxplugin/JavaFXPlugin.groovy

                 packaging = 'all'
                 debugKey {
                     alias = 'javafxdebugkey'
-                    keypass = 'JavaFX'
-                    keystore = new File(project.projectDir, 'debug.keystore')
-                    storepass = 'JavaFX'
+                    keyPass = 'JavaFX'
+                    keyStore = new File(project.projectDir, 'debug.keyStore')
+                    storePass = 'JavaFX'
                 }
                 signingMode = 'debug'
             })
                 group: 'Build')
 
         task.conventionMapping.alias     = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.alias }
-        task.conventionMapping.keypass   = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.keypass }
-        task.conventionMapping.keystore  = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.keystore }
-        task.conventionMapping.storepass = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.storepass }
+        task.conventionMapping.keyPass   = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.keyPass }
+        task.conventionMapping.keyStore  = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.keyStore }
+        task.conventionMapping.storePass = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.storePass }
+        task.conventionMapping.storeType = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).debugKey.storeType }
         task.conventionMapping.dname     = {convention, aware -> 'CN=JavaFX Gradle Plugin Default Debug Key, O=JavaFX Debug' }
         task.conventionMapping.validity  = {convention, aware -> ((365.25) * 25 as int) /* 25 years */ }
     }
                 description: "Signs the JavaFX jars the JavaFX way.",
                 group: 'Build')
 
-        task.conventionMapping.antJavaFXJar = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).antJavaFXJar }
-
-        ['alias', 'keypass', 'storepass', 'keystore'].each { prop ->
+        ['alias', 'keyPass', 'storePass', 'storeType'].each { prop ->
             task.conventionMapping[prop]  = {convention, aware ->
                 def jfxc = convention.getPlugin(JavaFXPluginConvention);
                 def props = project.properties
                 return props?."javafx.${mode}Key.$prop" ?: jfxc?."${mode}Key"?."$prop"
             }
         }
-        task.conventionMapping.keystore  = {convention, aware ->
+        task.conventionMapping.keyStore  = {convention, aware ->
             def jfxc = convention.getPlugin(JavaFXPluginConvention);
             def props = project.properties
             def mode = props['javafx.signingMode']  ?: jfxc.signingMode
-            String keyFile = props?."javafx.${mode}Key.keystore"
-            return keyFile == null ? jfxc?."${mode}Key"?.keystore : new File(keyFile)
+            String keyFile = props?."javafx.${mode}Key.keyStore"
+            return keyFile == null ? jfxc?."${mode}Key"?.keyStore : new File(keyFile)
         }
 
-        task.conventionMapping.destdir = {convention, aware -> "$project.libsDir/../signed" as File}
+        task.conventionMapping.outdir = {convention, aware -> "$project.libsDir/../signed" as File}
 
         task.conventionMapping.inputFiles = {convention, aware ->
             FileCollection runtimeClasspath = project.convention.getPlugin(JavaPluginConvention).sourceSets[SourceSet.MAIN_SOURCE_SET_NAME].runtimeClasspath;

plugin/src/main/groovy/com/bitbucket/shemnon/javafxplugin/JavaFXPluginConvention.groovy

 
 class SigningKeyInfo {
     String alias
-    String keypass
-    File keystore
-    String storepass
+    String keyPass
+    File keyStore
+    String storePass
+    String storeType
 
 
     public SigningKeyInfo(Closure configure) {

plugin/src/main/groovy/com/bitbucket/shemnon/javafxplugin/tasks/GenKeyTask.groovy

 
     @TaskAction
     processResources() {
-        if (getKeystore().exists()) return
+        if (getKeyStore().exists()) return
 
         ExecAction aaptExec = new DefaultExecAction()
         aaptExec.workingDir = project.projectDir
 
         def args = []
         args << '-genkeypair'
-        ['alias', 'dname', 'validity', 'keypass', 'keystore', 'storepass'].each {
+        ['alias', 'dname', 'validity', 'keyPass', 'keyStore', 'storePass', 'storeType'].each {
             if (this[it]) {
-                args << "-$it" << this[it] as String
+                args << "-${it.toLowerCase()}" << this[it] as String
             }
         }
 
         // [-keyalg <keyalg>]
         // [-keysize <keysize>]
         // [-sigalg <sigalg>]
-        // [-storetype <storetype>]
         // [-providername <name>]
         // [-providerclass <provider_class_name> [-providerarg <arg>]] ...
         // [-providerpath <pathlist>]
     }
 
     @OutputFile
-    File keystore
+    File keyStore
 
     String alias
     String dname
     Integer validity // conventions don't play nice with primitives
-    String keypass
-    String storepass
+    String keyPass
+    String storePass
+    String storeType
 }

plugin/src/main/groovy/com/bitbucket/shemnon/javafxplugin/tasks/JavaFXSignJarTask.groovy

  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-package com.bitbucket.shemnon.javafxplugin.tasks;
-
+package com.bitbucket.shemnon.javafxplugin.tasks
 
+import com.sun.javafx.tools.packager.PackagerLib
+import com.sun.javafx.tools.packager.SignJarParams;
 import org.gradle.api.file.FileCollection
 import org.gradle.api.internal.ConventionTask
 import org.gradle.api.tasks.InputFiles
     @TaskAction
     processResources() {
 
-        project.mkdir(getDestdir())
-
-        ant.taskdef(name: 'fxSignJar',
-                classname: 'com.sun.javafx.tools.ant.FXSignJarTask',
-                classpath: getAntJavaFXJar().asPath)
+        SignJarParams signJarParams = new SignJarParams();
 
+        getInputFiles() filter { File f -> f.file && f.name.endsWith(".jar") } each { File f ->
+            signJarParams.addResource(f.parentFile, f);
+        }
 
-        ant.fxSignJar(
-                makeAttributes()
-        ) {
-            getInputFiles().filter { it.file && it.name.endsWith(".jar") } each {
-                fileset(file: it)
+        ['alias', 'keyPass', 'keyStore', 'storePass', 'storeType', 'verbose', 'outdir', 'verbose'].each {
+            if (this[it]) {
+                signJarParams[it] = this[it]
             }
         }
+
+        PackagerLib packager = new PackagerLib();
+        packager.signJar(signJarParams)
     }
 
     String alias
-    String keypass
-    File keystore
-    String storepass
-    String storetype
-    String verbose = "true"
-
-    FileCollection antJavaFXJar
+    String keyPass
+    File keyStore
+    String storePass
+    String storeType
+    String verbose = "true" // FIXME hard coded
 
     @OutputDirectory
-    File destdir
+    File outdir
 
     @InputFiles
     FileCollection inputFiles
 
-    private Map makeAttributes() {
-        def result = [:]
-        ['alias', 'keypass', 'keystore', 'storepass', 'storetype', 'verbose', 'destdir', 'verbose'].each {
-            if (this[it]) {
-                result[it] = this[it]
-            }
-        }
-        return result
-    }
 }

samples/FullyExpressed/build.gradle

 
 javafx {
 
-    // you can hand configure these, but I don't
-    //jfxrtJar = file('jfxrt.jar')
-    //antJavaFXJar = file('ant-javafx.jar')
-
     debugKey {
         alias = 'buggyKey'
-        keypass = '123456'
-        keystore = file('veryinsecure.jks')
-        storepass = '123456'
+        keyPass = '123456'
+        keyStore = file('veryinsecure.jks')
+        storePass = '123456'
     }
     // don't get too excited, the release key is overridden by gradle.properties
     releaseKey {
         alias = 'imaginary'
-        keypass = 'bad'
-        keystore = file('nonexistant.jks')
-        storepass = 'bad'
+        keyPass = 'bad'
+        keyStore = file('nonexistant.jks')
+        storePass = 'bad'
     }
     signingMode = 'release'
 

samples/FullyExpressed/gradle.properties

 javafx.releaseKey.alias = selfsigned
-javafx.releaseKey.keypass = password
-javafx.releaseKey.keystore = insecure.jks
-javafx.releaseKey.storepass = password
+javafx.releaseKey.keyPass = password
+javafx.releaseKey.keyStore = insecure.jks
+javafx.releaseKey.storePass = password
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.