Skip to content

Commit b8ab17b

Browse files
authored
Merge pull request #1341 from benjdero/master
Problem: Java Gradle scripts should use task configuration avoidance API
2 parents 3db253a + c9f61fa commit b8ab17b

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

zproject_java.gsl

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ $(project.GENERATED_WARNING_HEADER:)
127127
*/
128128

129129
buildscript {
130-
configurations.all {
130+
configurations.configureEach {
131131
resolutionStrategy {
132132
force 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
133133
}
@@ -207,7 +207,7 @@ dependencies {
207207
// ------------------------------------------------------------------
208208
// Build section
209209

210-
task generateJniHeaders(type: Exec, dependsOn: 'classes') {
210+
tasks.register('generateJniHeaders', type: Exec, dependsOn: 'classes') {
211211
def classpath = sourceSets.main.output.classesDirs
212212
def appclasspath = configurations.runtimeClasspath.files*.getAbsolutePath().join(File.pathSeparator)
213213
def nativeIncludes = 'src/native/include'
@@ -222,14 +222,14 @@ task generateJniHeaders(type: Exec, dependsOn: 'classes') {
222222
commandLine("javac", "-h", "$nativeIncludes", "-classpath", "$classpath${File.pathSeparator}$appclasspath", *jniClasses, *utilityClasses)
223223
}
224224

225-
tasks.withType(Test) {
225+
tasks.withType(Test).configureEach {
226226
def defaultJavaLibraryPath = System.getProperty("java.library.path")
227227
if (osdetector.os == 'windows') {
228-
def extraJavaLibraryPath = hasNotEmptyProperty('buildPrefix') ? "$project.buildPrefix\\\\bin;$project.buildPrefix\\\\lib" : ''
229-
extraJavaLibraryPath = extraJavaLibraryPath.replace("/", "\\\\")
230-
systemProperty "java.library.path", "${projectDir}\\\\build\\\\Release${File.pathSeparator}" +
231-
"${extraJavaLibraryPath}${File.pathSeparator}" +
232-
"${defaultJavaLibraryPath}"
228+
def extraJavaLibraryPath = hasNotEmptyProperty('buildPrefix') ? "$project.buildPrefix\\\\bin;$project.buildPrefix\\\\lib" : ''
229+
extraJavaLibraryPath = extraJavaLibraryPath.replace("/", "\\\\")
230+
systemProperty "java.library.path", "${projectDir}\\\\build\\\\Release${File.pathSeparator}" +
231+
"${extraJavaLibraryPath}${File.pathSeparator}" +
232+
"${defaultJavaLibraryPath}"
233233
} else {
234234
def extraJavaLibraryPath = hasNotEmptyProperty('buildPrefix') ? "$project.buildPrefix/lib" : ''
235235
systemProperty "java.library.path", "${projectDir}/build${File.pathSeparator}" +
@@ -240,22 +240,22 @@ tasks.withType(Test) {
240240
}
241241
}
242242

243-
task initCMake(type: Exec, dependsOn: 'generateJniHeaders') {
244-
workingDir 'build'
243+
tasks.register('initCMake', type: Exec, dependsOn: 'generateJniHeaders') {
244+
workingDir 'build'
245245
def prefixPath = hasNotEmptyProperty('buildPrefix') ? "-DCMAKE_PREFIX_PATH=$project.buildPrefix" : ''
246246
commandLine 'cmake', "$prefixPath", '..'
247247
}
248248

249-
task buildNative(type: Exec, dependsOn: 'initCMake') {
249+
tasks.register('buildNative', type: Exec, dependsOn: 'initCMake') {
250250
if (osdetector.os == 'windows') {
251251
commandLine 'cmake',
252-
'--build', 'build',
252+
'--build', 'build',
253253
'--config', 'Release',
254254
'--target', '$(project.linkname)jni',
255-
'--', '-verbosity:Minimal', '-maxcpucount'
255+
'--', '-verbosity:Minimal', '-maxcpucount'
256256
} else {
257257
commandLine 'cmake',
258-
'--build', 'build'
258+
'--build', 'build'
259259
}
260260
}
261261

@@ -265,12 +265,12 @@ test.dependsOn buildNative
265265
// ------------------------------------------------------------------
266266
// Install and Publish section
267267

268-
task sourcesJar(type: Jar, dependsOn: 'classes') {
268+
tasks.register('sourcesJar', type: Jar, dependsOn: 'classes') {
269269
archiveClassifier = 'sources'
270270
from sourceSets.main.allSource
271271
}
272272

273-
task javadocJar(type: Jar, dependsOn: 'javadoc') {
273+
tasks.register('javadocJar', type: Jar, dependsOn: 'javadoc') {
274274
archiveClassifier = 'javadoc'
275275
from javadoc.destinationDir
276276
}
@@ -307,7 +307,6 @@ artifactoryPublish {
307307
publications ('mavenJava')
308308
}
309309

310-
311310
bintray {
312311
user = System.getenv('BINTRAY_USER')
313312
key = System.getenv('BINTRAY_KEY')
@@ -397,7 +396,6 @@ artifactoryPublish {
397396
publications ('mavenJava')
398397
}
399398

400-
401399
bintray {
402400
user = System.getenv('BINTRAY_USER')
403401
key = System.getenv('BINTRAY_KEY')
@@ -439,7 +437,7 @@ dependencies {
439437
// ------------------------------------------------------------------
440438
// Build section
441439

442-
task copyLibs(type: Copy) {
440+
tasks.register('copyLibs', type: Copy) {
443441
def libraryPaths = []
444442
if (project.hasProperty('buildPrefix')) {
445443
if (osdetector.os == 'windows') {
@@ -450,7 +448,7 @@ task copyLibs(type: Copy) {
450448
}
451449

452450
def javaLibraryPaths = System.getProperty('java.library.path').split(File.pathSeparator).toList()
453-
libraryPaths.addAll (javaLibraryPaths)
451+
libraryPaths.addAll(javaLibraryPaths)
454452

455453
libraryPaths.add('/usr/local/lib')
456454
if (osdetector.os == 'windows') {

0 commit comments

Comments
 (0)