NOTICK: Fix some Gradle technical debt. (#6430)

This commit is contained in:
Chris Rankin 2020-07-07 09:08:58 +01:00 committed by GitHub
parent 8175d4f0fb
commit 16eb9dfc08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 43 additions and 44 deletions

View File

@ -275,7 +275,7 @@ allprojects {
toolVersion = "0.8.3" toolVersion = "0.8.3"
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Xlint:-options" << "-parameters" options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Xlint:-options" << "-parameters"
options.compilerArgs << '-XDenableSunApiLintControl' options.compilerArgs << '-XDenableSunApiLintControl'
if (warnings_as_errors) { if (warnings_as_errors) {
@ -287,7 +287,7 @@ allprojects {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions { kotlinOptions {
languageVersion = "1.2" languageVersion = "1.2"
apiVersion = "1.2" apiVersion = "1.2"
@ -302,7 +302,7 @@ allprojects {
task.dependsOn tasks.withType(AbstractCompile) task.dependsOn tasks.withType(AbstractCompile)
} }
tasks.withType(Jar) { task -> tasks.withType(Jar).configureEach { task ->
// Includes War and Ear // Includes War and Ear
manifest { manifest {
attributes('Corda-Release-Version': corda_release_version) attributes('Corda-Release-Version': corda_release_version)
@ -314,7 +314,7 @@ allprojects {
} }
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
forkEvery = 10 forkEvery = 10
ignoreFailures = project.hasProperty('tests.ignoreFailures') ? project.property('tests.ignoreFailures').toBoolean() : false ignoreFailures = project.hasProperty('tests.ignoreFailures') ? project.property('tests.ignoreFailures').toBoolean() : false
failFast = project.hasProperty('tests.failFast') ? project.property('tests.failFast').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' systemProperty 'java.security.egd', 'file:/dev/./urandom'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
if (name.contains("integrationTest")) { if (name.contains("integrationTest")) {
maxParallelForks = (System.env.CORDA_INT_TESTING_FORKS == null) ? 1 : "$System.env.CORDA_INT_TESTING_FORKS".toInteger() 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) args(params)
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
reports.html.destination = file("${reporting.baseDir}/${name}") reports.html.destination = file("${reporting.baseDir}/${name}")
} }
@ -626,7 +626,7 @@ dependxiesModule {
skipTasks = "test,integrationTest,smokeTest,slowIntegrationTest" skipTasks = "test,integrationTest,smokeTest,slowIntegrationTest"
} }
task generateApi(type: net.corda.plugins.GenerateApi) { tasks.register('generateApi', net.corda.plugins.GenerateApi) {
baseName = "api-corda" baseName = "api-corda"
} }

View File

@ -99,7 +99,7 @@ configurations {
testArtifacts.extendsFrom testRuntimeClasspath testArtifacts.extendsFrom testRuntimeClasspath
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// fork a new test process for every test class // fork a new test process for every test class
forkEvery = 10 forkEvery = 10
} }

View File

@ -16,7 +16,7 @@ ext {
deterministic_rt_jar = jdk8uDeterministic.rt_jar deterministic_rt_jar = jdk8uDeterministic.rt_jar
} }
tasks.withType(AbstractCompile) { tasks.withType(AbstractCompile).configureEach {
dependsOn jdkTask dependsOn jdkTask
// This is a bit ugly, but Gradle isn't recognising the KotlinCompile task // 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 options.compilerArgs << '-bootclasspath' << deterministic_rt_jar
sourceCompatibility = VERSION_1_8 sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8 targetCompatibility = VERSION_1_8

View File

@ -22,4 +22,7 @@ jar.enabled = false
shadowJar { shadowJar {
baseName = "avalanche" baseName = "avalanche"
} }
assemble.dependsOn shadowJar
artifacts {
archives shadowJar
}

View File

@ -6,7 +6,7 @@ import static org.gradle.api.JavaVersion.VERSION_1_8
*/ */
apply plugin: 'kotlin' apply plugin: 'kotlin'
tasks.withType(AbstractCompile) { tasks.withType(AbstractCompile).configureEach {
// This is a bit ugly, but Gradle isn't recognising the KotlinCompile task // This is a bit ugly, but Gradle isn't recognising the KotlinCompile task
// as it does the built-in JavaCompile task. // as it does the built-in JavaCompile task.
if (it.class.name.startsWith('org.jetbrains.kotlin.gradle.tasks.KotlinCompile')) { 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 sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8 targetCompatibility = VERSION_1_8
} }

View File

@ -243,12 +243,12 @@ dependencies {
testCompile project(':testing:cordapps:dbfailure:dbfworkflows') testCompile project(':testing:cordapps:dbfailure:dbfworkflows')
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
// Resolves a Gradle warning about not scanning for pre-processors. // Resolves a Gradle warning about not scanning for pre-processors.
options.compilerArgs << '-proc:none' options.compilerArgs << '-proc:none'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
if (JavaVersion.current() == JavaVersion.VERSION_11) { if (JavaVersion.current() == JavaVersion.VERSION_11) {
jvmArgs '-Djdk.attach.allowAttachSelf=true' jvmArgs '-Djdk.attach.allowAttachSelf=true'
} }

View File

@ -119,9 +119,8 @@ task buildCordaJAR(type: FatCapsule, dependsOn: [
} }
} }
assemble.dependsOn buildCordaJAR
artifacts { artifacts {
archives buildCordaJAR
runtimeArtifacts buildCordaJAR runtimeArtifacts buildCordaJAR
publish buildCordaJAR { publish buildCordaJAR {
classifier '' classifier ''

View File

@ -153,7 +153,7 @@ task integrationTest(type: Test, dependsOn: []) {
// This fixes the "line too long" error when running this demo with windows CLI // This fixes the "line too long" error when running this demo with windows CLI
// TODO: Automatically apply to all projects via a plugin // TODO: Automatically apply to all projects via a plugin
tasks.withType(CreateStartScripts).each { task -> tasks.withType(CreateStartScripts).configureEach { task ->
task.doLast { task.doLast {
String text = task.windowsScript.text String text = task.windowsScript.text
// Replaces the per file classpath (which are all jars in "lib") with a wildcard on lib // Replaces the per file classpath (which are all jars in "lib") with a wildcard on lib

View File

@ -56,7 +56,7 @@ jar {
} }
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
useJUnitPlatform() useJUnitPlatform()
systemProperty 'deterministic-rt.path', configurations.jdkRt.asPath systemProperty 'deterministic-rt.path', configurations.jdkRt.asPath
systemProperty 'sandbox-libraries.path', configurations.sandboxTesting.asPath systemProperty 'sandbox-libraries.path', configurations.sandboxTesting.asPath

View File

@ -64,9 +64,8 @@ task buildWebserverJar(type: FatCapsule, dependsOn: project(':node').tasks.jar)
} }
} }
assemble.dependsOn buildWebserverJar
artifacts { artifacts {
archives buildWebserverJar
runtimeArtifacts buildWebserverJar runtimeArtifacts buildWebserverJar
publish buildWebserverJar { publish buildWebserverJar {
classifier '' classifier ''

View File

@ -90,7 +90,7 @@ dependencies {
testCompile "junit:junit:$junit_version" testCompile "junit:junit:$junit_version"
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
// Resolves a Gradle warning about not scanning for pre-processors. // Resolves a Gradle warning about not scanning for pre-processors.
options.compilerArgs << '-proc:none' options.compilerArgs << '-proc:none'
} }

View File

@ -1,17 +1,13 @@
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
repositories {
mavenCentral()
}
dependencies { dependencies {
implementation project(":common-logging") implementation project(":common-logging")
implementation project(":tools:cliutils") implementation project(":tools:cliutils")
implementation "info.picocli:picocli:$picocli_version" implementation "info.picocli:picocli:$picocli_version"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" implementation "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
testCompile "junit:junit:4.12" testImplementation "junit:junit:$junit_version"
} }
jar { jar {
@ -28,4 +24,6 @@ shadowJar {
} }
} }
assemble.dependsOn shadowJar artifacts {
archives shadowJar
}

View File

@ -71,7 +71,7 @@ dependencies {
compile "net.sf.jopt-simple:jopt-simple:$jopt_simple_version" 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. // Resolves a Gradle warning about not scanning for pre-processors.
options.compilerArgs << '-proc:none' options.compilerArgs << '-proc:none'
} }

View File

@ -41,9 +41,8 @@ task buildExplorerJAR(type: FatCapsule, dependsOn: project(':tools:explorer').ta
} }
} }
assemble.dependsOn buildExplorerJAR
artifacts { artifacts {
archives buildExplorerJAR
runtimeArtifacts buildExplorerJAR runtimeArtifacts buildExplorerJAR
publish buildExplorerJAR { publish buildExplorerJAR {
classifier "" classifier ""

View File

@ -62,7 +62,7 @@ dependencies {
compile "org.controlsfx:controlsfx:$controlsfx_version" compile "org.controlsfx:controlsfx:$controlsfx_version"
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
// Resolves a Gradle warning about not scanning for pre-processors. // Resolves a Gradle warning about not scanning for pre-processors.
options.compilerArgs << '-proc:none' options.compilerArgs << '-proc:none'
} }
@ -78,13 +78,13 @@ shadowJar {
zip64 true zip64 true
} }
task buildNetworkBuilder(dependsOn: shadowJar) tasks.register('buildNetworkBuilder') {
assemble.dependsOn buildNetworkBuilder dependsOn shadowJar
}
artifacts { artifacts {
publish shadowJar { archives shadowJar
archiveClassifier = jdkClassifier publish shadowJar
}
} }
jar { jar {

View File

@ -27,16 +27,17 @@ processResources {
} }
shadowJar { shadowJar {
archiveClassifier = jdkClassifier
mergeServiceFiles() mergeServiceFiles()
} }
task buildShellCli(dependsOn: shadowJar) tasks.register('buildShellCli') {
assemble.dependsOn buildShellCli dependsOn shadowJar
}
artifacts { artifacts {
publish shadowJar { archives shadowJar
archiveClassifier = jdkClassifier publish shadowJar
}
} }
jar { jar {

View File

@ -71,7 +71,7 @@ dependencies {
integrationTestCompile project(':node-driver') integrationTestCompile project(':node-driver')
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
// Resolves a Gradle warning about not scanning for pre-processors. // Resolves a Gradle warning about not scanning for pre-processors.
options.compilerArgs << '-proc:none' options.compilerArgs << '-proc:none'
} }