Commits

shemnon committed 728914f

move jfxjar to use PackagerLib directly

Comments (0)

Files changed (3)

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

                 description: "Jars up the classes and adds JavaFX specific packaging.",
                 group: 'Build')
 
-        task.conventionMapping.antJavaFXJar = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).antJavaFXJar }
-
         task.conventionMapping.mainClass = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).mainClass }
-        task.conventionMapping.appName = {convention, aware -> convention.getPlugin(JavaFXPluginConvention).appName }
 
+        task.conventionMapping.outputDirectory = {convention, aware ->
+            "$project.libsDir" as File}
         task.conventionMapping.outputFile = {convention, aware ->
-            "$project.libsDir/${project.archivesBaseName}.jar" as File}
+            "${project.archivesBaseName}.jar" as File}
 
         task.conventionMapping.inputFiles = {convention, aware -> convention.getPlugin(JavaPluginConvention).sourceSets.main.output}
-        task.conventionMapping.resources = {convention, aware ->
+        task.conventionMapping.classpath = {convention, aware ->
             FileCollection compileClasspath = project.convention.getPlugin(JavaPluginConvention).sourceSets[SourceSet.MAIN_SOURCE_SET_NAME].compileClasspath;
             Configuration providedCompile = project.configurations[PROVIDED_COMPILE_CONFIGURATION_NAME];
             FileCollection output = compileClasspath - providedCompile;

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

 
     @TaskAction
     processResources() {
-        PackagerLib packager = new PackagerLib();
 
         CreateBSSParams bssParams = new CreateBSSParams();
         getInputFiles().srcDirTrees.each { DirectoryFileTree dirTree ->
         }
         bssParams.setOutdir(getDistsDir())
 
+        PackagerLib packager = new PackagerLib();
         packager.generateBSS(bssParams)
     }
 

plugin/src/main/groovy/com/bitbucket/shemnon/javafxplugin/tasks/JavaFXJarTask.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.CreateJarParams
+import com.sun.javafx.tools.packager.PackagerLib;
 import org.gradle.api.internal.ConventionTask
 import org.gradle.api.tasks.InputFiles
+import org.gradle.api.tasks.OutputDirectory
 import org.gradle.api.tasks.OutputFile
 import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.SourceSetOutput
 import org.gradle.api.file.FileCollection
 
 /**
 
     @TaskAction
     processResources() {
-        ant.taskdef(name: 'fxJar',
-                classname: 'com.sun.javafx.tools.ant.FXJar',
-                classpath: getAntJavaFXJar().asPath)
+        CreateJarParams createJarParams = new CreateJarParams();
 
-        ant.fxJar(destfile: getOutputFile()) {
+        // hardcodes, fix later
+        createJarParams.embedLauncher = true
+        createJarParams.css2bin = false
 
-            getInputFiles().each {
-                if (it.directory) {
-                    fileset(dir: it)
-                } else if (it.file) {
-                    fileset(file: it)
-                }
-            }
-            application(
-                    name: getAppName(),
-                    mainClass: getMainClass()
-                    //FIXME preloader
-                    //FIXME fallback
-            )
-            ant.resources {
-                getResources().filter { it.file } each {
-                    fileset(file: it)
-                }
-            }
-        }
-    }
+        createJarParams.addResource(getInputFiles().getClassesDir(), getInputFiles().getClassesDir())
+        createJarParams.addResource(getInputFiles().getResourcesDir(), getInputFiles().getResourcesDir())
+        //TODO process dirs
+
+        createJarParams.applicationClass = getMainClass()
+        createJarParams.outfile = getOutputFile()
+        createJarParams.outdir = getOutputDirectory()
+
+        createJarParams.classpath = getClasspath().files.collect {it.name}.join ' '
 
-    FileCollection antJavaFXJar
+        // not provided, fix later
+        //createJarParams.arguments
+        //createJarParams.manifestAttrs
+        //createJarParams.fxVersion
+        //createJarParams.fallback
+        //createJarParams.preloader
+
+        PackagerLib packager = new PackagerLib();
+        packager.packageAsJar(createJarParams)
+
+    }
 
-    String appName
     String mainClass
 
     @OutputFile
     File outputFile
 
+    @OutputDirectory
+    File outputDirectory
+
     @InputFiles
-    FileCollection resources
+    FileCollection classpath
 
     @InputFiles
-    FileCollection inputFiles
+    SourceSetOutput inputFiles
 }