From 16eb9dfc08c8cadbd673e4b88f9e2a446dc2b4e3 Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Tue, 7 Jul 2020 09:08:58 +0100 Subject: [PATCH] NOTICK: Fix some Gradle technical debt. (#6430) --- build.gradle | 14 +++++++------- core-tests/build.gradle | 2 +- deterministic.gradle | 4 ++-- experimental/avalanche/build.gradle | 5 ++++- java8.gradle | 4 ++-- node/build.gradle | 4 ++-- node/capsule/build.gradle | 3 +-- samples/irs-demo/cordapp/build.gradle | 2 +- serialization-djvm/build.gradle | 2 +- testing/testserver/testcapsule/build.gradle | 3 +-- tools/demobench/build.gradle | 2 +- tools/error-tool/build.gradle | 10 ++++------ tools/explorer/build.gradle | 4 ++-- tools/explorer/capsule/build.gradle | 3 +-- tools/network-builder/build.gradle | 12 ++++++------ tools/shell-cli/build.gradle | 11 ++++++----- tools/shell/build.gradle | 2 +- 17 files changed, 43 insertions(+), 44 deletions(-) diff --git a/build.gradle b/build.gradle index 872fb36280..bf4959cb80 100644 --- a/build.gradle +++ b/build.gradle @@ -275,7 +275,7 @@ allprojects { toolVersion = "0.8.3" } - tasks.withType(JavaCompile) { + tasks.withType(JavaCompile).configureEach { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Xlint:-options" << "-parameters" options.compilerArgs << '-XDenableSunApiLintControl' if (warnings_as_errors) { @@ -287,7 +287,7 @@ allprojects { options.encoding = 'UTF-8' } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { languageVersion = "1.2" apiVersion = "1.2" @@ -302,7 +302,7 @@ allprojects { task.dependsOn tasks.withType(AbstractCompile) } - tasks.withType(Jar) { task -> + tasks.withType(Jar).configureEach { task -> // Includes War and Ear manifest { attributes('Corda-Release-Version': corda_release_version) @@ -314,7 +314,7 @@ allprojects { } } - tasks.withType(Test) { + tasks.withType(Test).configureEach { forkEvery = 10 ignoreFailures = project.hasProperty('tests.ignoreFailures') ? project.property('tests.ignoreFailures').toBoolean() : false failFast = project.hasProperty('tests.failFast') ? project.property('tests.failFast').toBoolean() : false @@ -339,7 +339,7 @@ allprojects { systemProperty 'java.security.egd', 'file:/dev/./urandom' } - tasks.withType(Test) { + tasks.withType(Test).configureEach { if (name.contains("integrationTest")) { maxParallelForks = (System.env.CORDA_INT_TESTING_FORKS == null) ? 1 : "$System.env.CORDA_INT_TESTING_FORKS".toInteger() } @@ -520,7 +520,7 @@ tasks.register('detektBaseline', JavaExec) { args(params) } -tasks.withType(Test) { +tasks.withType(Test).configureEach { reports.html.destination = file("${reporting.baseDir}/${name}") } @@ -626,7 +626,7 @@ dependxiesModule { skipTasks = "test,integrationTest,smokeTest,slowIntegrationTest" } -task generateApi(type: net.corda.plugins.GenerateApi) { +tasks.register('generateApi', net.corda.plugins.GenerateApi) { baseName = "api-corda" } diff --git a/core-tests/build.gradle b/core-tests/build.gradle index 8d1919f474..eb21b557f5 100644 --- a/core-tests/build.gradle +++ b/core-tests/build.gradle @@ -99,7 +99,7 @@ configurations { testArtifacts.extendsFrom testRuntimeClasspath } -tasks.withType(Test) { +tasks.withType(Test).configureEach { // fork a new test process for every test class forkEvery = 10 } diff --git a/deterministic.gradle b/deterministic.gradle index 2a7913d426..11bd05770f 100644 --- a/deterministic.gradle +++ b/deterministic.gradle @@ -16,7 +16,7 @@ ext { deterministic_rt_jar = jdk8uDeterministic.rt_jar } -tasks.withType(AbstractCompile) { +tasks.withType(AbstractCompile).configureEach { dependsOn jdkTask // This is a bit ugly, but Gradle isn't recognising the KotlinCompile task @@ -29,7 +29,7 @@ tasks.withType(AbstractCompile) { } } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { options.compilerArgs << '-bootclasspath' << deterministic_rt_jar sourceCompatibility = VERSION_1_8 targetCompatibility = VERSION_1_8 diff --git a/experimental/avalanche/build.gradle b/experimental/avalanche/build.gradle index e6f9c1ccae..540bc2947b 100644 --- a/experimental/avalanche/build.gradle +++ b/experimental/avalanche/build.gradle @@ -22,4 +22,7 @@ jar.enabled = false shadowJar { baseName = "avalanche" } -assemble.dependsOn shadowJar + +artifacts { + archives shadowJar +} diff --git a/java8.gradle b/java8.gradle index e0fbf629cc..50a462aa41 100644 --- a/java8.gradle +++ b/java8.gradle @@ -6,7 +6,7 @@ import static org.gradle.api.JavaVersion.VERSION_1_8 */ apply plugin: 'kotlin' -tasks.withType(AbstractCompile) { +tasks.withType(AbstractCompile).configureEach { // This is a bit ugly, but Gradle isn't recognising the KotlinCompile task // as it does the built-in JavaCompile task. if (it.class.name.startsWith('org.jetbrains.kotlin.gradle.tasks.KotlinCompile')) { @@ -16,7 +16,7 @@ tasks.withType(AbstractCompile) { } } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { sourceCompatibility = VERSION_1_8 targetCompatibility = VERSION_1_8 } diff --git a/node/build.gradle b/node/build.gradle index 60e071bbb6..db3cc95796 100644 --- a/node/build.gradle +++ b/node/build.gradle @@ -243,12 +243,12 @@ dependencies { testCompile project(':testing:cordapps:dbfailure:dbfworkflows') } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { // Resolves a Gradle warning about not scanning for pre-processors. options.compilerArgs << '-proc:none' } -tasks.withType(Test) { +tasks.withType(Test).configureEach { if (JavaVersion.current() == JavaVersion.VERSION_11) { jvmArgs '-Djdk.attach.allowAttachSelf=true' } diff --git a/node/capsule/build.gradle b/node/capsule/build.gradle index 78b1a48970..14cddd0332 100644 --- a/node/capsule/build.gradle +++ b/node/capsule/build.gradle @@ -119,9 +119,8 @@ task buildCordaJAR(type: FatCapsule, dependsOn: [ } } -assemble.dependsOn buildCordaJAR - artifacts { + archives buildCordaJAR runtimeArtifacts buildCordaJAR publish buildCordaJAR { classifier '' diff --git a/samples/irs-demo/cordapp/build.gradle b/samples/irs-demo/cordapp/build.gradle index bf6c020cdf..50474dd3e5 100644 --- a/samples/irs-demo/cordapp/build.gradle +++ b/samples/irs-demo/cordapp/build.gradle @@ -153,7 +153,7 @@ task integrationTest(type: Test, dependsOn: []) { // This fixes the "line too long" error when running this demo with windows CLI // TODO: Automatically apply to all projects via a plugin -tasks.withType(CreateStartScripts).each { task -> +tasks.withType(CreateStartScripts).configureEach { task -> task.doLast { String text = task.windowsScript.text // Replaces the per file classpath (which are all jars in "lib") with a wildcard on lib diff --git a/serialization-djvm/build.gradle b/serialization-djvm/build.gradle index 7ec41f9d32..f51557e2a3 100644 --- a/serialization-djvm/build.gradle +++ b/serialization-djvm/build.gradle @@ -56,7 +56,7 @@ jar { } } -tasks.withType(Test) { +tasks.withType(Test).configureEach { useJUnitPlatform() systemProperty 'deterministic-rt.path', configurations.jdkRt.asPath systemProperty 'sandbox-libraries.path', configurations.sandboxTesting.asPath diff --git a/testing/testserver/testcapsule/build.gradle b/testing/testserver/testcapsule/build.gradle index f69d05b263..f231f12c68 100644 --- a/testing/testserver/testcapsule/build.gradle +++ b/testing/testserver/testcapsule/build.gradle @@ -64,9 +64,8 @@ task buildWebserverJar(type: FatCapsule, dependsOn: project(':node').tasks.jar) } } -assemble.dependsOn buildWebserverJar - artifacts { + archives buildWebserverJar runtimeArtifacts buildWebserverJar publish buildWebserverJar { classifier '' diff --git a/tools/demobench/build.gradle b/tools/demobench/build.gradle index 1522d4b82d..be75806d58 100644 --- a/tools/demobench/build.gradle +++ b/tools/demobench/build.gradle @@ -90,7 +90,7 @@ dependencies { testCompile "junit:junit:$junit_version" } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { // Resolves a Gradle warning about not scanning for pre-processors. options.compilerArgs << '-proc:none' } diff --git a/tools/error-tool/build.gradle b/tools/error-tool/build.gradle index d1e11ec376..908775f7c2 100644 --- a/tools/error-tool/build.gradle +++ b/tools/error-tool/build.gradle @@ -1,17 +1,13 @@ apply plugin: 'kotlin' apply plugin: 'com.github.johnrengelman.shadow' -repositories { - mavenCentral() -} - dependencies { implementation project(":common-logging") implementation project(":tools:cliutils") implementation "info.picocli:picocli:$picocli_version" implementation "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" - testCompile "junit:junit:4.12" + testImplementation "junit:junit:$junit_version" } jar { @@ -28,4 +24,6 @@ shadowJar { } } -assemble.dependsOn shadowJar \ No newline at end of file +artifacts { + archives shadowJar +} diff --git a/tools/explorer/build.gradle b/tools/explorer/build.gradle index f4bc37cee9..82838e5c80 100644 --- a/tools/explorer/build.gradle +++ b/tools/explorer/build.gradle @@ -71,7 +71,7 @@ dependencies { compile "net.sf.jopt-simple:jopt-simple:$jopt_simple_version" } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { // Resolves a Gradle warning about not scanning for pre-processors. options.compilerArgs << '-proc:none' } @@ -82,4 +82,4 @@ jar { 'Automatic-Module-Name': 'net.corda.tools.explorer' ) } -} \ No newline at end of file +} diff --git a/tools/explorer/capsule/build.gradle b/tools/explorer/capsule/build.gradle index 05750ee7d6..56b5f3a5de 100644 --- a/tools/explorer/capsule/build.gradle +++ b/tools/explorer/capsule/build.gradle @@ -41,9 +41,8 @@ task buildExplorerJAR(type: FatCapsule, dependsOn: project(':tools:explorer').ta } } -assemble.dependsOn buildExplorerJAR - artifacts { + archives buildExplorerJAR runtimeArtifacts buildExplorerJAR publish buildExplorerJAR { classifier "" diff --git a/tools/network-builder/build.gradle b/tools/network-builder/build.gradle index 3306ac7c15..01c65cdcd4 100644 --- a/tools/network-builder/build.gradle +++ b/tools/network-builder/build.gradle @@ -62,7 +62,7 @@ dependencies { compile "org.controlsfx:controlsfx:$controlsfx_version" } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { // Resolves a Gradle warning about not scanning for pre-processors. options.compilerArgs << '-proc:none' } @@ -78,13 +78,13 @@ shadowJar { zip64 true } -task buildNetworkBuilder(dependsOn: shadowJar) -assemble.dependsOn buildNetworkBuilder +tasks.register('buildNetworkBuilder') { + dependsOn shadowJar +} artifacts { - publish shadowJar { - archiveClassifier = jdkClassifier - } + archives shadowJar + publish shadowJar } jar { diff --git a/tools/shell-cli/build.gradle b/tools/shell-cli/build.gradle index 31214428cb..80ebd521dd 100644 --- a/tools/shell-cli/build.gradle +++ b/tools/shell-cli/build.gradle @@ -27,16 +27,17 @@ processResources { } shadowJar { + archiveClassifier = jdkClassifier mergeServiceFiles() } -task buildShellCli(dependsOn: shadowJar) -assemble.dependsOn buildShellCli +tasks.register('buildShellCli') { + dependsOn shadowJar +} artifacts { - publish shadowJar { - archiveClassifier = jdkClassifier - } + archives shadowJar + publish shadowJar } jar { diff --git a/tools/shell/build.gradle b/tools/shell/build.gradle index f76070853b..4e6f55fda7 100644 --- a/tools/shell/build.gradle +++ b/tools/shell/build.gradle @@ -71,7 +71,7 @@ dependencies { integrationTestCompile project(':node-driver') } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { // Resolves a Gradle warning about not scanning for pre-processors. options.compilerArgs << '-proc:none' }