Skip to content

Commit 7344072

Browse files
authored
Merge pull request NASAWorldWind#66 from wcmatthysen/gradle-improvements
Gradle build-script improvements
2 parents 513ccd1 + 0766ca7 commit 7344072

File tree

4 files changed

+134
-39
lines changed

4 files changed

+134
-39
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jdk:
1010
- openjdk8
1111
- openjdk11
1212
- openjdk12
13-
- oraclejdk8
1413
- oraclejdk11
1514
- openjdk-ea
1615

@@ -38,12 +37,13 @@ before_install:
3837
install:
3938
# Using clean as dummy target; could install dependencies here if needed.
4039
- ./gradlew clean
41-
42-
# Use xvfb to run tests that require a GUI and give it some time to start
40+
41+
# Use xvfb to run tests that require a GUI.
42+
services:
43+
- xvfb
44+
4345
before_script:
4446
- "export DISPLAY=:99.0"
45-
- "sh -e /etc/init.d/xvfb start"
46-
- sleep 3
4747

4848
# Build the project
4949
script:
@@ -87,4 +87,4 @@ deploy:
8787
skip_cleanup: true
8888
on:
8989
tags: true
90-
jdk: oraclejdk8
90+
jdk: oraclejdk8

build.gradle

Lines changed: 123 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ version = '2.2.0' + (project.hasProperty('snapshot') ? '-SNAPSHOT' : '')
1818
sourceCompatibility = '1.8'
1919
targetCompatibility = '1.8'
2020

21+
ant {
22+
property(file: 'build.properties')
23+
property(file: "gdal.${org.gradle.internal.os.OperatingSystem.current().isWindows() ? 'win' : 'unix'}.properties")
24+
}
25+
2126
ext {
2227
joglVersion = '2.3.2'
2328
gdalVersion = '2.4.0'
@@ -32,14 +37,18 @@ repositories {
3237
}
3338

3439
dependencies {
35-
implementation "org.jogamp.jogl:jogl-all-main:${project.joglVersion}"
36-
implementation "org.jogamp.gluegen:gluegen-rt-main:${project.joglVersion}"
37-
38-
compile "org.gdal:gdal:${project.gdalVersion}"
40+
compile "org.jogamp.jogl:jogl-all-main:$project.joglVersion"
41+
compile "org.jogamp.gluegen:gluegen-rt-main:$project.joglVersion"
42+
43+
if (project.hasProperty('systemGDAL')) {
44+
compile files("${ant.properties['gdal.jar.dir']}/gdal.jar")
45+
} else {
46+
implementation "org.gdal:gdal:$project.gdalVersion"
47+
}
3948

40-
implementation "org.codehaus.jackson:jackson-core-asl:${project.jacksonVersion}"
49+
compile "org.codehaus.jackson:jackson-core-asl:$project.jacksonVersion"
4150

42-
testImplementation "junit:junit:${project.junitVersion}"
51+
testImplementation "junit:junit:$project.junitVersion"
4352
}
4453

4554
task sourcesJar(type: Jar, dependsOn: classes) {
@@ -64,12 +73,12 @@ task extensionsJar(type: Jar) {
6473
exclude 'images/**'
6574
exclude 'gov/nasa/worldwind/**'
6675
}
67-
}
68-
extensionsJar.doLast {
69-
copy {
70-
from "$buildDir/libs/${extensionsJar.archiveName}"
71-
into "${project.projectDir}"
72-
rename "${extensionsJar.archiveName}", "${extensionsJar.baseName}.${extensionsJar.extension}"
76+
doLast {
77+
copy {
78+
from "$buildDir/libs/$extensionsJar.archiveName"
79+
into project.projectDir
80+
rename "$extensionsJar.archiveName", "$extensionsJar.baseName.$extensionsJar.extension"
81+
}
7382
}
7483
}
7584

@@ -85,7 +94,7 @@ def pomConfig = {
8594
license {
8695
name 'NASA Open Source Agreement v1.3'
8796
url 'https://ti.arc.nasa.gov/opensource/nosa/'
88-
distribution "repo"
97+
distribution 'repo'
8998
}
9099
}
91100
developers {
@@ -96,7 +105,7 @@ def pomConfig = {
96105
}
97106
}
98107
scm {
99-
url "https://github.com/WorldWindEarth/WorldWindJava"
108+
url 'https://github.com/WorldWindEarth/WorldWindJava'
100109
}
101110
}
102111

@@ -145,7 +154,7 @@ bintray {
145154
githubRepo = 'WorldWindEarth/WorldWindJava'
146155
version {
147156
name = project.version
148-
desc = 'WorldWind v' + project.version
157+
desc = "WorldWind v$project.version"
149158
vcsTag = System.getenv('TRAVIS_TAG')
150159
released = new Date()
151160
}
@@ -194,25 +203,25 @@ compileJava {
194203

195204
test {
196205
dependsOn jar
197-
classpath += project.files("$buildDir/libs/${jar.archiveName}", configurations.runtime)
206+
classpath += project.files("$buildDir/libs/$jar.archiveName", configurations.runtime)
198207
}
199208

200209
jar {
201210
dependsOn classes
202211
from sourceSets.main.output
203212
exclude 'gov/nasa/worldwindx/**'
204-
}
205-
jar.doLast {
206-
copy {
207-
from "$buildDir/libs/${jar.archiveName}"
208-
into "${project.projectDir}"
209-
rename "${jar.archiveName}", "${jar.baseName}.${jar.extension}"
213+
doLast {
214+
copy {
215+
from "$buildDir/libs/$jar.archiveName"
216+
into project.projectDir
217+
rename "$jar.archiveName", "$jar.baseName.$jar.extension"
218+
}
210219
}
211220
}
212221

213222
javadoc {
214223
options {
215-
overview = "${project.projectDir}/src/overview.html"
224+
overview = "$project.projectDir/src/overview.html"
216225
windowTitle = 'WorldWindJava API'
217226
title = 'NASA WorldWind Java-Community Edition'
218227
header = 'NASA WorldWind-CE'
@@ -231,3 +240,94 @@ artifacts {
231240
archives extensionsJar
232241
archives javadocJar
233242
}
243+
244+
task processMilStd2525SVGs(dependsOn: jar) {
245+
group = 'build'
246+
description = 'Processes the MIL-STD-2525 SVG source files.'
247+
248+
// Set outputs of this task to be PNG directory.
249+
def milStd2525PngDir = file(ant.properties['milstd2525.png.dir'])
250+
outputs.dir(milStd2525PngDir)
251+
252+
doLast {
253+
def milStd2525SrcDir = file(ant.properties['milstd2525.src.dir'])
254+
255+
// If PNG directory doesn't exist, create it.
256+
if (!milStd2525PngDir.exists()) {
257+
milStd2525PngDir.mkdirs()
258+
}
259+
260+
def width = ant.properties['milstd2525.png.width']
261+
def height = ant.properties['milstd2525.png.height']
262+
263+
// Rasterize the MIL-STD-2525 SVG sources. Exclude empty directories in order
264+
// to suppress erroneous error messages from the Apache Batik Rasterizer.
265+
milStd2525SrcDir.traverse([type: groovy.io.FileType.DIRECTORIES, excludeNameFilter: ~/fills|frames|icons/]) { srcDir ->
266+
def dstDir = milStd2525PngDir.path + (srcDir.path - milStd2525SrcDir.path)
267+
exec {
268+
commandLine 'java',\
269+
'-jar',\
270+
"$project.projectDir/lib-external/batik/batik-rasterizer.jar",\
271+
'-m',\
272+
'image/png',\
273+
'-maxw',\
274+
width,\
275+
'-h',\
276+
height,\
277+
'-d',\
278+
dstDir,\
279+
srcDir
280+
}
281+
}
282+
283+
// The Forward Edge of Battle (FEBA, 2.X.2.4.2.1) image has a custom height of 16 pixels.
284+
milStd2525SrcDir.traverse([type: groovy.io.FileType.FILES, nameFilter: ~/g-g.dlf--------\.svg/]) { srcFile ->
285+
def dstFile = ((milStd2525PngDir.path + (srcFile.path - milStd2525SrcDir.path)) - '.svg') + '.png'
286+
exec {
287+
commandLine 'java',\
288+
'-jar',\
289+
"$project.projectDir/lib-external/batik/batik-rasterizer.jar",\
290+
'-m',\
291+
'image/png',\
292+
'-maxw',\
293+
width,\
294+
'-h',\
295+
'16',\
296+
'-d',\
297+
dstFile,\
298+
srcFile
299+
}
300+
}
301+
302+
// Trim the MIL-STD-2525 modifier images to remove transparent borders.
303+
def modifiersDir = file("$milStd2525PngDir.path/modifiers")
304+
modifiersDir.traverse([type: groovy.io.FileType.FILES]) { srcFile ->
305+
exec {
306+
commandLine 'java',\
307+
'-cp',\
308+
"$buildDir/libs/$jar.archiveName",\
309+
'gov.nasa.worldwind.util.ImageTrimmer',\
310+
srcFile
311+
}
312+
}
313+
}
314+
}
315+
316+
task milStd2525Zip(type: Zip, dependsOn: processMilStd2525SVGs) {
317+
group = 'build'
318+
description = 'Assembles the MIL-STD-2525 symbology package.'
319+
def milStd2525OutDir = file(ant.properties['milstd2525.out.dir'])
320+
def milStd2525PngDir = file(ant.properties['milstd2525.png.dir'])
321+
from milStd2525PngDir
322+
include '**/*'
323+
archiveName 'milstd2525-symbols.zip'
324+
destinationDir milStd2525OutDir
325+
}
326+
327+
task runLayerManager(type: JavaExec, dependsOn: classes) {
328+
group = 'run'
329+
description = 'Runs the LayerManager example app.'
330+
classpath sourceSets.main.runtimeClasspath
331+
main = 'gov.nasa.worldwindx.examples.layermanager.LayerManagerApp'
332+
systemProperty 'java.util.logging.config.file', "$project.projectDir/logging.properties"
333+
}

build.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -505,15 +505,11 @@
505505
</target>
506506

507507
<target name="runLayerManager" depends="build" description="Runs the LayerManager example app.">
508-
<echoproperties/>
509-
<java fork="true"
510-
classname="gov.nasa.worldwindx.examples.layermanager.LayerManagerApp"
511-
classpath="${gdal.jar.dir}/gdal.jar;gluegen-rt-natives-linux-amd64.jar;gluegen-rt-natives-linux-i586.jar;gluegen-rt-natives-macosx-universal.jar;gluegen-rt-natives-windows-amd64.jar;gluegen-rt-natives-windows-i586.jar;gluegen-rt.jar;jackson-core-asl.jar;jogl-all-natives-linux-amd64.jar;jogl-all-natives-linux-i586.jar;jogl-all-natives-macosx-universal.jar;jogl-all-natives-windows-amd64.jar;jogl-all-natives-windows-i586.jar;jogl-all.jar;junit-4.5.jar;vpf-symbols.jar;worldwind.jar;worldwindx.jar"
512-
>
513-
<env key="GDAL_DATA" path="${gdal.data.dir}"/>
514-
<env key="GDAL_DRIVER_PATH" path="${gdal.plugins.dir}"/>
508+
<echoproperties/>
509+
<java fork="true"
510+
classname="gov.nasa.worldwindx.examples.layermanager.LayerManagerApp"
511+
classpath="gluegen-rt-natives-linux-amd64.jar;gluegen-rt-natives-linux-i586.jar;gluegen-rt-natives-macosx-universal.jar;gluegen-rt-natives-windows-amd64.jar;gluegen-rt-natives-windows-i586.jar;gluegen-rt.jar;jackson-core-asl.jar;jogl-all-natives-linux-amd64.jar;jogl-all-natives-linux-i586.jar;jogl-all-natives-macosx-universal.jar;jogl-all-natives-windows-amd64.jar;jogl-all-natives-windows-i586.jar;jogl-all.jar;junit-4.5.jar;vpf-symbols.jar;worldwind.jar;worldwindx.jar">
515512
<sysproperty key="java.util.logging.config.file" value="${basedir}/logging.properties"/>
516-
</java>
513+
</java>
517514
</target>
518-
519515
</project>

gdal.unix.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ gdal.jar.dir=/usr/share/java
33
gdal.jni.dir=/usr/lib/jni
44
gdal.data.dir=/usr/share/gdal/2.2
55
gdal.plugins.dir=/usr/lib/gdalplugins
6-

0 commit comments

Comments
 (0)