Commits

shemnon committed 32faa3d

move deploy to use PackagerLib directly
This includes changing license to licenseType

Comments (0)

Files changed (1)

plugin/src/main/groovy/com/bitbucket/shemnon/javafxplugin/tasks/JavaFXDeployTask.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.DeployParams
+import com.sun.javafx.tools.packager.PackagerLib
+import com.sun.javafx.tools.packager.bundlers.Bundler;
 import org.gradle.api.tasks.InputFiles
 import org.gradle.api.tasks.TaskAction
 import org.gradle.api.tasks.OutputDirectory
 
     @TaskAction
     processResources() {
-        ant.taskdef(name: 'fxDeploy',
-                classname: 'com.sun.javafx.tools.ant.DeployFXTask',
-                classpath: (getAntJavaFXJar() + project.files(project.sourceSets.'package'.allSource.srcDirs)).asPath)
-
-        ant.fxDeploy(
-                width: getWidth(),
-                height: getHeight(),
-                outDir: getDistsDir(),
-                embedJNLP: getEmbedJNLP(),
-                outFile: getAppName(),
-                nativeBundles: getPackaging(),
-                verbose: getVerbose()
-
-        ) {
-
-            application(
-                    id: getAppID(),
-                    name: getAppName(),
-                    mainClass: getMainClass()
-            )
-            resources {
-                getInputFiles().filter() { it.file } each {
-                    fileset(file: it)
-                }
-
-            }
-            info(
-                title: getAppName(),
-                category: getCategory(),
-                copyright: getCopyright(),
-                description: getDescription(),
-                license: getLicense(),
-                vendor: getVendor()
-            )
-            preferences(
-                createPreferencesAttributes()
-            )
-
-            permissions(elevated: 'true')
+        DeployParams deployParams = new DeployParams();
+
+        deployParams.version = getProject().getVersion() // FIXME make a convention property
+
+        // these deploy params are currently not set
+        //java.lang.String preloader;
+        //java.util.List<com.sun.javafx.tools.packager.Param> params;
+        //java.util.List<com.sun.javafx.tools.packager.HtmlParam> htmlParams;
+        //java.util.List<java.lang.String> arguments;
+        //boolean embedCertificates;
+        //java.lang.String updateMode;
+        //boolean isExtension;
+        //boolean isSwingApp;
+        //boolean includeDT;
+        //java.lang.String placeholder;
+        //java.lang.String appId;
+        //boolean offlineAllowed;
+        //java.util.List<com.sun.javafx.tools.ant.Callback> callbacks;
+        //java.util.List<com.sun.javafx.tools.packager.DeployParams.Template> templates;
+        //java.lang.String jrePlatform;
+        //java.lang.String fxPlatform;
+        //java.util.List<java.lang.String> jvmargs;
+        //java.util.Map<java.lang.String,java.lang.String> properties;
+        //java.lang.String fallbackApp;
+        //java.util.List<com.sun.javafx.tools.packager.DeployParams.Icon> icons;
+
+
+        deployParams.width = getWidth()
+        deployParams.height = getHeight()
+        deployParams.setEmbeddedDimensions(getWidth() as String, getHeight() as String) // FIXME make a convention property
+        deployParams.setOutdir(getDistsDir())
+        deployParams.embedJNLP = getEmbedJNLP()
+        deployParams.outfile = getAppName() //FIXME duplicate with app name
+        switch (getPackaging().toLowerCase()) {
+            case "false":
+            case "none":
+                deployParams.bundleType = Bundler.BundleType.NONE
+                deployParams.targetFormat = null
+                break;
+            case "all":
+            case "true":
+                deployParams.bundleType = Bundler.BundleType.ALL
+                deployParams.targetFormat = null
+                break;
+            case "image":
+                deployParams.bundleType = Bundler.BundleType.IMAGE
+                deployParams.targetFormat = null
+                break;
+            case "installer":
+                deployParams.bundleType = Bundler.BundleType.INSTALLER
+                deployParams.targetFormat = null
+                break;
+            default:
+                // assume the packageing is for a specific type
+                deployParams.bundleType = Bundler.BundleType.INSTALLER
+                deployParams.targetFormat = getPackaging()
+
         }
+
+        deployParams.verbose = getVerbose()
+
+        deployParams.id = getAppID()
+        deployParams.appName = getAppName() // FIXME duplicate with title
+        deployParams.applicationClass = getMainClass()
+
+        getInputFiles() each { File f ->
+            deployParams.addResource(f.parentFile, f);
+        }
+
+        deployParams.title = getAppName()
+        deployParams.category = getCategory()
+        deployParams.copyright = getCopyright()
+        deployParams.description = getDescription()
+        deployParams.licenseType = getLicenseType()
+        deployParams.vendor = getVendor()
+
+        deployParams.systemWide = getInstallSystemWide()
+        deployParams.needMenu = getMenu()
+        deployParams.needShortcut = getShortcut()
+
+        deployParams.allPermissions = true //FIXME hardcoded
+
+        PackagerLib packager = new PackagerLib();
+        packager.generateDeploymentPackages(deployParams)
     }
 
     String packaging
     String category
     String copyright
     String description
-    String license
+    String licenseType
     String vendor
 
     // deploy/preferences attributes
     @OutputDirectory
     File distsDir
 
-    protected Map createPreferencesAttributes() {
-        def res = [:]
-        if (getInstallSystemWide() != null) {
-            res.install = getInstallSystemWide()
-        }
-        if (getMenu() != null) {
-            res.menu = getMenu()
-        }
-        if (getShortcut() != null) {
-            res.shortcut = getShortcut()
-        }
-        return res
-    }
-
 }
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.