summaryrefslogtreecommitdiff
path: root/java/src/IceGridGUI/plain-jar.gradle
blob: 901135cef782cd79e9c2e4348cc8909e50a0b45e (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
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

task copyTmpJars(type: Copy, dependsOn: jar) {
    from new File("${projectDir}/build/libs/${tmpJarName}")
    into "${libDir}"
    rename("${tmpJarName}", "${jarName}")

}

task updateManifest(dependsOn: copyTmpJars) {
    doLast {
        ant.jar(update: true, destfile: "${libDir}/${jarName}") {
            delegate.manifest {
                attribute(name: "Main-Class", value: "com.zeroc.IceGridGUI.Main")
                attribute(name: "Built-By", value: "ZeroC, Inc.")
                attribute(name: "Class-Path", value: configurations.runtimeClasspath.resolve().collect { "file://${it.toURI().getRawPath()}" }.join(' '))
            }
        }
    }
}
updateManifest.outputs.files("${libDir}/${jarName}")
assemble.dependsOn(updateManifest)

//
// Copy JARs to the install location
//
task copyJars(type: Copy, dependsOn: jar) {
    from new File("${projectDir}/build/libs/${tmpJarName}")
    into "${DESTDIR}${jarDir}"
    rename("${tmpJarName}", "${jarName}")
}

//
// We need to update the manifest of the installed IceGridGUI jar and fix the
// Class-Path to point to the installed JAR files.
//
task updateInstallManifest(dependsOn: copyJars) {
    doLast {
        ant.jar(update: true, destfile: "${DESTDIR}${jarDir}/${jarName}") {
            delegate.manifest {
                attribute(name: "Main-Class", value: "com.zeroc.IceGridGUI.Main")
                attribute(name: "Built-By", value: "ZeroC, Inc.")
                attribute(name: "Class-Path", value: configurations.runtimeClasspath.resolve().collect {
                    "file://${it.toURI().getRawPath()}" }.join(' ').replaceAll("${libDir.replaceAll('\\\\', '/')}", "${jarDir.replaceAll('\\\\', '/')}"))
            }
        }
    }
}
updateInstallManifest.outputs.files("${DESTDIR}${jarDir}/${jarName}")
task install(dependsOn: updateInstallManifest)