Commits

shemnon committed 92164fe

move a bunch of stuff in the deploy task into the javafx extension, so that single setup deployments can all be configured just in the extension

Also, code layout on the tasks

Comments (0)

Files changed (8)

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/JavaFXPlugin.groovy

                 description: "Processes the JavaFX jars and generates webstart and native packages.",
                 group: 'Build')
 
-        task.conventionMapping.packaging = {convention, aware -> project.javafx.packaging }
+        [
+                'antJavaFXJar',
+                'appID',
+                'appName',
+                'arguments',
+                'category',
+                'codebase',
+                'copyright',
+                'description',
+                'embedJNLP',
+                'height',
+                'iconInfos',
+                'installSystemWide',
+                'jvmArgs',
+                'licenseType',
+                'mainClass',
+                'menu',
+                'offlineAllowed',
+                'packaging',
+                'shortcut',
+                'systemProperties',
+                'updateMode',
+                'vendor',
+                'verbose',
+                'width',
+        ].each {prop ->
+            task.conventionMapping[prop] = {convention, aware -> project.javafx[prop] }
 
-        task.conventionMapping.antJavaFXJar = {convention, aware ->
-            project.javafx.antJavaFXJar }
-
-        task.conventionMapping.appID = {convention, aware -> project.javafx.appID }
-        task.conventionMapping.appName = {convention, aware -> project.javafx.appName }
-        task.conventionMapping.mainClass = {convention, aware -> project.javafx.mainClass }
+        }
+        // version is special
         task.conventionMapping.version = {convention, aware -> ('unspecified' == project.version) ? '0.0.0' : project.version }
 
 
 
         task.conventionMapping.distsDir = {convention, aware -> project.distsDir }
 
-        task.conventionMapping.jvmArgs = {convention, aware -> project.javafx.jvmArgs }
-        task.conventionMapping.systemProperties = {convention, aware -> project.javafx.systemProperties }
-        task.conventionMapping.arguments = {convention, aware -> project.javafx.arguments}
-
         task.dependsOn(project.tasks.getByName("jfxSignJar"))
         task.dependsOn(project.tasks.getByName("packageClasses"))
 

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/JavaFXPluginExtension.groovy

  */
 package org.bitbucket.shemnon.javafxplugin
 
+import com.sun.javafx.tools.packager.DeployParams
 import org.gradle.util.ConfigureUtil
 import org.gradle.api.file.FileCollection
 
+import java.awt.image.BufferedImage
+
 class JavaFXPluginExtension { //extends BasePluginConvention {
 
     // preliminaries
     SigningKeyInfo debugKey
     SigningKeyInfo releaseKey
 
-    boolean embedLauncher = true
-
     String signingMode
 
+    boolean embedLauncher = true
+
     // app info
     String appID
     String appName
-    String mainClass
 
     String packaging
 
+    // JNLP Packaging
+    int width = 1024
+    int height = 768
+    boolean embedJNLP = false
+    String updateMode = "background"
+    boolean offlineAllowed = true
+    String codebase
+
+    // runtime stuff
+    String mainClass
     List<String> jvmArgs = []
     Map<String, String> systemProperties = [:]
     List<String> arguments = []
 
+    // deploy/info attributes
+    String category
+    String copyright
+    String description
+    String licenseType
+    String vendor
+
+    // deploy/preferences attributes
+    Boolean installSystemWide
+    boolean menu
+    boolean shortcut
+
+    protected List<IconInfo> iconInfos = []
+    protected List<IconInfo> getIconInfos() { return iconInfos}
+    protected void setIconInfo(List<IconInfo> icons) {iconInfos = icons}
+
+
+
     public debugKey(Closure closure) {
         debugKey = new SigningKeyInfo(closure)
     }
         releaseKey = new SigningKeyInfo(closure)
     }
 
+    def icon(Closure closure) {
+        getIconInfos().add(new IconInfo(closure))
+    }
+
+    def icons(Closure closure) {
+        Map m = [:]
+        ConfigureUtil.configure(closure, m)
+        m.each {k, v ->
+            if (v instanceof List) {
+                v.each {
+                    addIcon(k, it)
+                }
+            } else {
+                addIcon(k, v)
+            }
+        }
+    }
 
+    protected void addIcon(String kind, String href) {
+        IconInfo ii = new IconInfo(href)
+        ii.kind = kind
+        getIconInfos().add(ii)
+    }
 }
 
 class SigningKeyInfo {
     //   - load stuff like validity and dname from existing key
     //   - prompt for password if set to null on a read
 }
+
+class IconInfo {
+    String href
+    String kind = 'default'
+    int width = -1
+    int height = -1
+    int depth = -1
+    double scale = 1 // for retina
+    DeployParams.RunMode mode = DeployParams.RunMode.ALL
+    private BufferedImage _image
+    protected file
+
+    public IconInfo(String href) {
+        this.href = href
+    }
+
+    public IconInfo(Closure configure) {
+        ConfigureUtil.configure(configure, this)
+    }
+
+}

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/tasks/GenKeyTask.groovy

  */
 class GenKeyTask extends ConventionTask {
 
+    @OutputFile
+    File keyStore
+
+    String alias
+    String dname
+    Integer validity // conventions don't play nice with primitives
+    String keyPass
+    String storePass
+    String storeType
+
     @TaskAction
     processResources() {
         if (getKeyStore().exists()) return
         exec.assertNormalExitValue()
     }
 
-    @OutputFile
-    File keyStore
-
-    String alias
-    String dname
-    Integer validity // conventions don't play nice with primitives
-    String keyPass
-    String storePass
-    String storeType
 }

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/tasks/JavaFXCSSToBinTask.groovy

 
 class JavaFXCSSToBinTask extends ConventionTask {
 
+    @InputFiles
+    SourceDirectorySet inputFiles
+
+    @OutputDirectory
+    File distsDir
+
     @TaskAction
     processResources() {
 
         packager.generateBSS(bssParams)
     }
 
-    @InputFiles
-    SourceDirectorySet inputFiles
-
-    @OutputDirectory
-    File distsDir
 }

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/tasks/JavaFXDeployTask.groovy

 import net.sf.image4j.codec.bmp.BMPEncoder
 import net.sf.image4j.codec.ico.ICOEncoder
 import org.apache.tools.ant.taskdefs.condition.Os
+import org.bitbucket.shemnon.javafxplugin.IconInfo
 import org.gradle.api.file.FileCollection
 import org.gradle.api.internal.ConventionTask
 import org.gradle.api.tasks.InputDirectory
 
 class JavaFXDeployTask extends ConventionTask {
 
-
     String packaging
 
     FileCollection antJavaFXJar
 
     boolean verbose = false
 
-    String mainClass
     int width = 1024
     int height = 768
     boolean embedJNLP = false
     boolean offlineAllowed = true
     String codebase
 
+    String mainClass
     List<String> jvmArgs = []
     Map<String, String> systemProperties = [:]
     List<String> arguments = []
 
         deployParams.updateMode = getUpdateMode()
         deployParams.offlineAllowed = getOfflineAllowed()
-        for (IconInfo ii : iconInfos) {
+        for (IconInfo ii : getIconInfos()) {
             deployParams.addIcon(ii.href, ii.kind, ii.width, ii.height, ii.depth, ii.mode);
         }
         if (getCodebase() != null) {
             }
         }
 
-        jvmArgs.each { deployParams.addJvmArg(it) }
-        systemProperties.each {k, v -> deployParams.addJvmProperty(k, v)}
-        deployParams.arguments = arguments
+        getJvmArgs().each { deployParams.addJvmArg(it) }
+        getSystemProperties().each {k, v -> deployParams.addJvmProperty(k, v)}
+        deployParams.arguments = getArguments()
 
         File packageResourcesOutput = project.sourceSets['package'].output.resourcesDir
         processIcons(packageResourcesOutput)
     }
 
     def icon(Closure closure) {
-        iconInfos.add(new IconInfo(closure))
+        getIconInfos().add(new IconInfo(closure))
     }
 
     def icons(Closure closure) {
     protected void addIcon(String kind, String href) {
         IconInfo ii = new IconInfo(href)
         ii.kind = kind
-        iconInfos.add(ii)
+        getIconInfos().add(ii)
     }
 
     protected void loadConventialIcons(String kind) {
         def dest = "$project.buildDir/icons/${kind}.iconset"
         project.mkdir(dest)
         boolean createIcon = false
-        for (IconInfo ii : iconInfos) {
+        for (IconInfo ii : getIconInfos()) {
             if (kind == ii.kind) {
-                BufferedImage icon = ii.image
+                BufferedImage icon = getImage(ii)
                 if (icon == null) {
                     logger.error("Icon $ii.href for $ii.kind rejected from MacOSX bundling because $ii.href does not exist or it is not an image.")
                     continue;
 
     protected void processWidnowsBMP(String kind, File destination) {
         boolean processed = false
-        for (IconInfo ii : iconInfos) {
+        for (IconInfo ii : getIconInfos()) {
             if (kind == ii.kind) {
-                BufferedImage icon = ii.image
+                BufferedImage icon = getImage(ii)
                 if (icon == null) {
                     logger.error("Icon $ii.href for $ii.kind rejected from Windows bundling because $ii.href does not exist or it is not an image.")
                     continue;
         Map<Integer, BufferedImage> images = new TreeMap<Integer, BufferedImage>()
         for (IconInfo ii : iconInfos) {
             if (kind == ii.kind) {
-                BufferedImage icon = ii.image
+                BufferedImage icon = getImage(ii)
                 if (icon == null) {
                     logger.error("Icon $ii.href for $ii.kind rejected from Windows bundling because $ii.href does not exist or it is not an image.")
                     continue;
 
     protected void processLinuxIcons(File destination) {
         IconInfo largestIcon
-        for (IconInfo ii : iconInfos) {
+        for (IconInfo ii : getIconInfos()) {
             if ('shortcut' == ii.kind) {
-                BufferedImage icon = ii.image
+                BufferedImage icon = getImage(ii)
                 if (icon == null) {
                     logger.error("Icon $ii.href for $ii.kind rejected from Linux bundling because $ii.href does not exist or it is not an image.")
                     continue;
 
     }
 
-    class IconInfo {
-        String href
-        String kind = 'default'
-        int width = -1
-        int height = -1
-        int depth = -1
-        double scale = 1 // for retina
-        RunMode mode = RunMode.ALL
-        private BufferedImage _image
-        protected file
-
-        public IconInfo(String href) {
-            this.href = href
-        }
-
-        public IconInfo(Closure configure) {
-            ConfigureUtil.configure(configure, this)
-        }
-
-        BufferedImage getImage() {
-            if (_image == null) {
-                file = getProject().file(href)
-                if (!file.file) {
-                    // try to resolve relative to output
-                    file = new File(getResourcesDir(), href)
-                }
-                if (!file.file) return
+    BufferedImage getImage(IconInfo ii) {
+        if (ii._image == null) {
+            ii.file = getProject().file(ii.href)
+            if (!ii.file.file) {
+                // try to resolve relative to output
+                ii.file = new File(getResourcesDir(), ii.href)
+            }
+            if (!ii.file.file) return
 
-                _image = ImageIO.read(file)
+            ii._image = ImageIO.read(ii.file)
 
-                if (href.contains('@2x')) {
-                    width = _image.width / 2
-                    height = _image.height / 2
-                    scale = 2
-                } else {
-                    width = _image.width
-                    height = _image.height
-                    scale = 1
-                }
+            if (ii.href.contains('@2x')) {
+                ii.width = ii._image.width / 2
+                ii.height = ii._image.height / 2
+                ii.scale = 2
+            } else {
+                ii.width = ii._image.width
+                ii.height = ii._image.height
+                ii.scale = 1
             }
-            return _image
         }
+        return ii._image
     }
 }

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/tasks/JavaFXJarTask.groovy

  */
 public class JavaFXJarTask extends ConventionTask {
 
+    String mainClass
+    boolean embedLauncher
+    List<String> arguments
+
+    @InputFiles
+    FileCollection classpath
+
+    @InputFile
+    File jarFile
+
     @TaskAction
     processResources() {
         CreateJarParams createJarParams = new CreateJarParams();
 
     }
 
-    String mainClass
-    boolean embedLauncher
-    List<String> arguments
-
-    @InputFiles
-    FileCollection classpath
-
-    @InputFile
-    File jarFile
 }

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/tasks/JavaFXSignJarTask.groovy

  */
 public class JavaFXSignJarTask extends ConventionTask {
 
+    String alias
+    String keyPass
+    File keyStore
+    String storePass
+    String storeType
+    String verbose = "true" // FIXME hard coded
+
+    @OutputDirectory
+    File outdir
+
+    @InputFiles
+    FileCollection inputFiles
+
+
+
     @TaskAction
     processResources() {
 
         packager.signJar(signJarParams)
     }
 
-    String alias
-    String keyPass
-    File keyStore
-    String storePass
-    String storeType
-    String verbose = "true" // FIXME hard coded
-
-    @OutputDirectory
-    File outdir
-
-    @InputFiles
-    FileCollection inputFiles
-
 }

samples/FullyExpressed/build.gradle

     arguments = ['1AC', '1NC', '2AC', '2NC', '1NR', '1AR', '2NR', '2AR']
 
     embedLauncher = true // caution: class-path not set and is overwritten if set to false
-}
 
-generateDebugKey {
-    dname='ou=them'
-    validity=1
-}
-
-jfxDeploy {
     // applet and webstart stuff
     width = 800
     height = 600
         height = 16
         scale = 1
     }
-}
+}
+
+generateDebugKey {
+    dname='ou=them'
+    validity=1
+}
+
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.