shemnon avatar shemnon committed abba0a6

use fxsampler in packaged app

Comments (0)

Files changed (2)

+apply plugin: 'idea'
 apply plugin: 'java'
 apply plugin: 'maven'
 apply plugin: 'application'
 
 apply from: 'mavenPublish.gradle'
+apply from: 'javafx.plugin'
 
 group = 'org.controlsfx'
 version = '8.0.3-SNAPSHOT'
 targetCompatibility = '1.8'
 
 configurations {
-    samples.extendsFrom mainRuntime
+    samples {extendsFrom mainRuntime}
     jdk
 }
 
 }
 
 dependencies {
-    runtime "fxsampler:fxsampler:1.0.0-SNAPSHOT"
-    compile "fxsampler:fxsampler:1.0.0-SNAPSHOT"
+    samplesCompile "fxsampler:fxsampler:1.0.0-SNAPSHOT"
+    
     try {
         jdk files(jfxrtJar)
     } catch (MissingPropertyException pne) {
-        jdk files("${System.properties['java.home']}/lib/jfxrt.jar")
-        jdk files("${System.properties['java.home']}/lib/ext/jfxrt.jar")
+        // javafx plugin will provide in this case
     }
 }
 
     exclude '**/oxygen/svg/*'
 }
 
-task jarSamples (type: Jar) {
+task samplesJar (type: Jar) {
     classifier='samples'
     from sourceSets.samples.output
-    manifest {
-        attributes(
-            'Manifest-Version': '1.0',
-            "Main-Class": "org.controlsfx.HelloControlsFX",
-            "Class-Path": "controlsfx-${version}.jar"
-        )
-    }
+//    manifest {
+//        attributes(
+//            'Manifest-Version': '1.0',
+//        )
+//    }
 }
 
 task sourceJar(type: Jar) {
 artifacts {
     archives sourceJar
     archives javadocJar
-    archives jarSamples
+    archives samplesJar
 }
 
-task listJars << {
-    configurations.compile.each { File file -> println file.name }
+// enumerate the samples at build time
+task enumerateSamples() {
+    doLast {
+        def samplesList = []
+        sourceSets.samples.java.visit {
+            // could be improved:  we could load the class and check the hierarchy
+            if (!it.directory && it.file.text.contains(' extends SampleBase ') && it.path.contains("samples")) {
+                samplesList += it.path
+            }
+        }
+        File outputFile = new File(sourceSets.samples.output.resourcesDir, 'fxsampler/samples/samples.txt')
+        outputFile.parentFile.mkdirs()
+        outputFile.text = samplesList.join('\n')
+    }
+}
+processSamplesResources.dependsOn(enumerateSamples)
+gradle.taskGraph.whenReady {
+    enumerateSamples.enabled = gradle.taskGraph.hasTask(":jfxDeploy") 
 }
 
 
+jfxJar {
+    classpath = files(
+        (project.sourceSets.samples.compileClasspath .files
+            - project.configurations['providedCompile'].files.findAll {it.file}) 
+        + jar.archivePath            
+    )
+}
+
+javafx {
+    try {
+        jfxrtJar = ext.jfxrtJar
+    } catch (MissingPropertyException pne) {
+        // ignore
+    }
+    
+    sourceSet = 'samples'
+
+    appID 'HelloControlsFX'
+    appName 'Hello ControlsFX'
+    mainClass 'fxsampler.FXSampler'
+
+    javaRuntime = '<NO RUNTIME>' // for now don't bundle a VM
+
+    // deplpy/info attributes
+    category = 'JavaFX Demos'
+    copyright = 'Copyright (c) 2013 Jonathan Giles and others'
+    description = 'This is a sample of all of the ControlsFX controls'
+    licenseType = '3 clause BSD'
+    vendor = 'FX Experience'
+}

mavenPublish.gradle

 apply plugin: 'signing'
 
 configurations {
-    samples.extendsFrom mainRuntime
+    samples { extendsFrom mainRuntime}
     jdk
     maven { extendsFrom archives }
     published { extendsFrom archives, signatures}
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.