summaryrefslogtreecommitdiff
path: root/java/src/IceGridGUI/javafx.gradle
blob: 02ff58f7685f5078a4aa7d21df6d64e9ea8b064c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import groovy.xml.NamespaceBuilder

assert project.plugins.findPlugin(JavaPlugin):
        "The Java plugin must be applied before using javafx7.gradle."

assert project.plugins.findPlugin(ApplicationPlugin):
        "The Application plugin must be applied before using javafx7.gradle."

def javafxJar = searchFile([{System.env['JFXRT_HOME']}, {System.env['JAVA_HOME']}, {System.properties['java.home']}],
                    ['jfxrt.jar', 'lib/jfxrt.jar', 'lib/ext/jfxrt.jar', 'jre/lib/jfxrt.jar', 'jre/lib/ext/jfxrt.jar'])

def antJavafxJar = searchFile([{System.env['JFXRT_HOME']}, {System.env['JAVA_HOME']}, {System.properties['java.home']}],
                    ['ant-javafx.jar', 'lib/ant-javafx.jar', '../lib/ant-javafx.jar'])

if (!javafxJar) {
    throw new GradleException("Unable to locate JavaFX jar (jfxrt.jar), JAVA_HOME may need to be set.")
}

if (!antJavafxJar) {
    throw new GradleException("Unable to locate JavaFX Ant jar (ant-javafx.jar), JAVA_HOME may need to be set.")
}

configurations {
    jfxrt
    jfxant

    sourceSets {
        main {
            compileClasspath += configurations.jfxrt
        }
    }
}

dependencies {
    jfxrt files(javafxJar)
    jfxant files(antJavafxJar)
}

run.classpath.add(configurations.jfxrt)

jar {
    actions = []

    def antfx = NamespaceBuilder.newInstance(
            ant,
            'javafx:com.sun.javafx.tools.ant')


    ant.taskdef(
            resource: 'com/sun/javafx/tools/ant/antlib.xml',
            uri: 'javafx:com.sun.javafx.tools.ant',
            classpath: configurations.jfxant.asPath)

    doLast {
        antfx.application(
                id: 'IceGridGUI',
                name: 'IceGrid GUI',
                mainClass: 'com.zeroc.IceGridGUI.Main',
                fallbackClass: 'IceGridGUI.Fallback',
                toolkit: 'swing')

        antfx.resources(id: 'IceGridGUI.resources') {
        }

        antfx.jar(destfile: archivePath) {
            application(refid: 'IceGridGUI')
            resources(refid: 'IceGridGUI.resources')

            fileset(dir: sourceSets.main.output.classesDir)
            fileset(dir: sourceSets.main.output.resourcesDir)
        }
   }
}

startScripts {
    enabled = false
}

installDist {
    enabled = false
}