Commits

shemnon  committed 8a812a6

rework jfxjar and signjar proceess to be nicer with maven

The built in jar is used, jfxJar and jfxSignJar now follow on and do their thing

  • Participants
  • Parent commits 86dce18

Comments (0)

Files changed (4)

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

 
     private configureJavaFXJarTask(Project project) {
         def task = project.task("jfxJar", type: JavaFXJarTask,
-                description: "Jars up the classes and adds JavaFX specific packaging.",
-                group: 'Build')
+                description: "Adds JavaFX specific packaging to the jar.",
+                group: 'Build',
+                dependsOn: 'jar')
+        project.afterEvaluate {
+            project.configurations.archives.artifacts*.builtBy task
+        }
 
         task.conventionMapping.mainClass = {convention, aware -> project.javafx.mainClass }
+        task.conventionMapping.embedLauncher = {convention, aware -> project.javafx.embedLauncher }
+        task.conventionMapping.arguments = {convention, aware -> project.javafx.arguments}
 
-        task.conventionMapping.outputDirectory = {convention, aware ->
-            "$project.libsDir" as File}
-        task.conventionMapping.outputFile = {convention, aware ->
-            "${project.archivesBaseName}.jar" as File}
-
-        task.conventionMapping.inputFiles = {convention, aware -> convention.getPlugin(JavaPluginConvention).sourceSets.main.output}
+        task.conventionMapping.jarFile = {convention, aware ->
+            project.tasks.getByName("jar").archivePath
+        }
         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];
     private configureJavaFXSignJarTask(Project project) {
         def task = project.task("jfxSignJar", type: JavaFXSignJarTask,
                 description: "Signs the JavaFX jars the JavaFX way.",
-                group: 'Build')
+                group: 'Build',
+                dependsOn: 'jfxJar')
+        project.afterEvaluate {
+            project.configurations.archives.artifacts*.builtBy task
+
+        }
 
         ['alias', 'keyPass', 'storePass', 'storeType'].each { prop ->
             task.conventionMapping[prop]  = {convention, aware ->
             return keyFile == null ? jfxc?."${mode}Key"?.keyStore : new File(keyFile)
         }
 
-        task.conventionMapping.outdir = {convention, aware -> "$project.libsDir/../signed" as File}
+        task.conventionMapping.outdir = {convention, aware -> project.libsDir}
 
         task.conventionMapping.inputFiles = {convention, aware ->
             FileCollection runtimeClasspath = project.convention.getPlugin(JavaPluginConvention).sourceSets[SourceSet.MAIN_SOURCE_SET_NAME].runtimeClasspath;
             Configuration providedRuntime = project.configurations[PROVIDED_RUNTIME_CONFIGURATION_NAME];
-            runtimeClasspath  + project.files("$project.libsDir/${project.archivesBaseName}.jar" as File)- providedRuntime
+            project.files(runtimeClasspath - providedRuntime, project.configurations.archives.artifacts.files.collect{it})
         }
 
         task.dependsOn(project.tasks.getByName("jfxJar"))
 
 
         task.conventionMapping.inputFiles = {convention, aware ->
-            project.fileTree("$project.libsDir/../signed").include("*.jar")
+            project.fileTree(project.libsDir).include("*.jar")
         }
         task.conventionMapping.resourcesDir = { convention, aware ->
             def rd = project.sourceSets['package'].output.resourcesDir
         task.dependsOn(project.tasks.getByName("packageClasses"))
 
         project.tasks.getByName("assemble").dependsOn(task)
-        project.tasks.getByName("jar").enabled = false
     }
     
     private void configureRunTask(Project project) {

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

     SigningKeyInfo debugKey
     SigningKeyInfo releaseKey
 
+    boolean embedLauncher = true
+
     String signingMode
 
     // app info

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

 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.InputFile
 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
 
 /**
     processResources() {
         CreateJarParams createJarParams = new CreateJarParams();
 
-        // hardcodes, fix later
-        createJarParams.embedLauncher = true
-        createJarParams.css2bin = false
-
-        createJarParams.addResource(getInputFiles().getClassesDir(), getInputFiles().getClassesDir())
-        createJarParams.addResource(getInputFiles().getResourcesDir(), getInputFiles().getResourcesDir())
-        //TODO process dirs
-
+        createJarParams.addResource(null, getJarFile())
         createJarParams.applicationClass = getMainClass()
-        createJarParams.outfile = getOutputFile()
-        createJarParams.outdir = getOutputDirectory()
-
+        createJarParams.arguments = getArguments()
         createJarParams.classpath = getClasspath().files.collect {it.name}.join ' '
+        createJarParams.css2bin = false
+        createJarParams.embedLauncher = getEmbedLauncher()
+        createJarParams.outdir = getJarFile().parentFile
+        createJarParams.outfile = getJarFile().name
+
 
         // not provided, fix later
-        //createJarParams.arguments
         //createJarParams.manifestAttrs
         //createJarParams.fxVersion
         //createJarParams.fallback
         //createJarParams.preloader
 
+
         PackagerLib packager = new PackagerLib();
         packager.packageAsJar(createJarParams)
 
     }
 
     String mainClass
-
-    @OutputFile
-    File outputFile
-
-    @OutputDirectory
-    File outputDirectory
+    boolean embedLauncher
+    List<String> arguments
 
     @InputFiles
     FileCollection classpath
 
-    @InputFiles
-    SourceSetOutput inputFiles
+    @InputFile
+    File jarFile
 }

File samples/FullyExpressed/build.gradle

 apply from: 'https://repository-javafx-gradle-plugin.forge.cloudbees.com/snapshot/javafx.plugin'
 apply plugin: 'idea'
+apply plugin: 'maven'
 
 repositories {
     mavenCentral()
     jvmArgs = ['-XX:+AggressiveOpts', '-XX:CompileThreshold=1']
     systemProperties = [ 'prism.disableRegionCaching':'true' ]
     arguments = ['1AC', '1NC', '2AC', '2NC', '1NR', '1AR', '2NR', '2AR']
+
+    embedLauncher = true // caution: class-path not set and is overwritten if set to false
 }
 
 generateDebugKey {