Upgrade Gradle to 4.10.3

Also try to improve build time performance by reducing the required configuration:
https://blog.gradle.org/preview-avoiding-task-configuration-time
This commit is contained in:
Tyler Benson 2019-02-07 09:21:37 -08:00
parent 2643471f75
commit 000c0e4644
16 changed files with 51 additions and 48 deletions

View File

@ -28,13 +28,13 @@ jar {
classifier = 'unbundled' classifier = 'unbundled'
} }
task submodulesUpdate(type:Exec) { tasks.register("submodulesUpdate", Exec) {
group 'Build Setup' group 'Build Setup'
description 'Initializes and updates integrations-core git submodule' description 'Initializes and updates integrations-core git submodule'
commandLine 'git', 'submodule', 'update', '--init', 'integrations-core' commandLine 'git', 'submodule', 'update', '--init', 'integrations-core'
} }
task copyMetricConfigs(type:Exec) { tasks.register("copyMetricConfigs", Exec) {
group 'Build Setup' group 'Build Setup'
description 'Copy metrics.yaml files from integrations-core into resources' description 'Copy metrics.yaml files from integrations-core into resources'
commandLine './copy-metric-configs.sh', 'integrations-core', sourceSets.main.output.resourcesDir commandLine './copy-metric-configs.sh', 'integrations-core', sourceSets.main.output.resourcesDir

View File

@ -54,7 +54,7 @@ jmh {
} }
// configured as a separate task since the 'jmh' task did not like adding a javaagent argument. // configured as a separate task since the 'jmh' task did not like adding a javaagent argument.
task jmhAgent(type: JavaExec, dependsOn: project.tasks.jmhCompileGeneratedClasses) { tasks.register("jmhAgent", JavaExec) {
classpath = files(project.jmhCompileGeneratedClasses.destinationDir) classpath = files(project.jmhCompileGeneratedClasses.destinationDir)
classpath += sourceSets.jmh.runtimeClasspath classpath += sourceSets.jmh.runtimeClasspath
main = "org.openjdk.jmh.Main" main = "org.openjdk.jmh.Main"
@ -66,6 +66,7 @@ task jmhAgent(type: JavaExec, dependsOn: project.tasks.jmhCompileGeneratedClasse
// args += ["-wi", "2"] // args += ["-wi", "2"]
// args += ["-i", "5"] // args += ["-i", "5"]
dependsOn project.tasks.jmhCompileGeneratedClasses
} }
tasks.jmhAgent.dependsOn project(':dd-java-agent').shadowJar tasks.jmhAgent.dependsOn project(':dd-java-agent').shadowJar

View File

@ -109,7 +109,7 @@ dependencies {
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0' testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Ddd.writer.type=LogWriter", "-Ddd.service.name=java-app" jvmArgs "-Ddd.writer.type=LogWriter", "-Ddd.service.name=java-app"
jvmArgs "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug" jvmArgs "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"
jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug" jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"

View File

@ -42,13 +42,13 @@ dependencies {
} }
// See comment for FieldBackedProviderFieldInjectionDisabledTest about why this hack is here // See comment for FieldBackedProviderFieldInjectionDisabledTest about why this hack is here
tasks.withType(Test) { tasks.withType(Test).configureEach {
if (name != "testDisabledFieldInjection") { if (name != "testDisabledFieldInjection") {
exclude "context/FieldBackedProviderFieldInjectionDisabledTest.class" exclude "context/FieldBackedProviderFieldInjectionDisabledTest.class"
} }
} }
task testDisabledFieldInjection(type: Test) { tasks.register("testDisabledFieldInjection", Test) {
systemProperties "dd.trace.runtime.context.field.injection": "false" systemProperties "dd.trace.runtime.context.field.injection": "false"
include "context/FieldBackedProviderFieldInjectionDisabledTest.class" include "context/FieldBackedProviderFieldInjectionDisabledTest.class"
} }

View File

@ -69,7 +69,7 @@ dependencies {
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0' testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
} }
task startServer(type: com.github.psxpaul.task.ExecFork) { tasks.register("startServer", com.github.psxpaul.task.ExecFork) {
dependsOn project(':dd-java-agent').shadowJar dependsOn project(':dd-java-agent').shadowJar
playHttpPort = randomOpenPort() playHttpPort = randomOpenPort()
@ -96,11 +96,11 @@ task startServer(type: com.github.psxpaul.task.ExecFork) {
dependsOn 'stage' dependsOn 'stage'
} }
task deletePIDFile() { tasks.register("deletePIDFile") {
delete "${buildDir}/stage/playBinary/RUNNING_PID" delete "${buildDir}/stage/playBinary/RUNNING_PID"
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// so the test can get this property // so the test can get this property
jvmArgs "-Ddatadog.smoketest.server.port=${playHttpPort}" jvmArgs "-Ddatadog.smoketest.server.port=${playHttpPort}"
@ -109,7 +109,7 @@ tasks.withType(Test) {
} }
dependsOn startServer dependsOn startServer
}
// clean up the PID file from the server // clean up the PID file from the server
tasks.withType(Test).forEach { it.finalizedBy deletePIDFile } finalizedBy deletePIDFile
}

View File

@ -29,7 +29,7 @@ dependencies {
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0' testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
} }
task startServer(type: com.github.psxpaul.task.ExecFork) { tasks.register("startServer", com.github.psxpaul.task.ExecFork) {
springbootHttpPort = randomOpenPort() springbootHttpPort = randomOpenPort()
dependsOn project(':dd-java-agent').shadowJar, shadowJar dependsOn project(':dd-java-agent').shadowJar, shadowJar
@ -51,7 +51,7 @@ task startServer(type: com.github.psxpaul.task.ExecFork) {
stopAfter = test stopAfter = test
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Ddatadog.smoketest.server.port=${springbootHttpPort}" jvmArgs "-Ddatadog.smoketest.server.port=${springbootHttpPort}"
dependsOn startServer dependsOn startServer

View File

@ -36,7 +36,7 @@ dependencies {
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0' testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
} }
task unzip(type: Copy) { tasks.register("unzip", Copy) {
def zipFileNamePrefix = "servlet" def zipFileNamePrefix = "servlet"
def zipPath = project.configurations.compile.find { def zipPath = project.configurations.compile.find {
it.name.startsWith(zipFileNamePrefix) it.name.startsWith(zipFileNamePrefix)
@ -52,7 +52,7 @@ task unzip(type: Copy) {
} }
} }
task startServer(type: com.github.psxpaul.task.ExecFork) { tasks.register("startServer", com.github.psxpaul.task.ExecFork) {
dependsOn project(':dd-java-agent').shadowJar dependsOn project(':dd-java-agent').shadowJar
wildflyHttpPort = randomOpenPort() wildflyHttpPort = randomOpenPort()
@ -84,7 +84,7 @@ task startServer(type: com.github.psxpaul.task.ExecFork) {
dependsOn unzip dependsOn unzip
} }
task stopWildfly(type:Exec) { tasks.register("stopWildfly", Exec) {
project.getLogger().info("Shutting down Wildfly") project.getLogger().info("Shutting down Wildfly")
workingDir = "${buildDir}/wildfly-servlet-15.0.0.Final" workingDir = "${buildDir}/wildfly-servlet-15.0.0.Final"
commandLine = "${workingDir}/bin/jboss-cli.sh" commandLine = "${workingDir}/bin/jboss-cli.sh"
@ -93,7 +93,7 @@ task stopWildfly(type:Exec) {
dependsOn startServer dependsOn startServer
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// so the test can get this property // so the test can get this property
jvmArgs "-Ddatadog.smoketest.server.port=${wildflyHttpPort}" jvmArgs "-Ddatadog.smoketest.server.port=${wildflyHttpPort}"
@ -102,7 +102,7 @@ tasks.withType(Test) {
} }
dependsOn startServer dependsOn startServer
}
// ensure that the wildfly server gets shutdown // ensure that the wildfly server gets shutdown
tasks.withType(Test).forEach { it.finalizedBy stopWildfly } finalizedBy stopWildfly
}

View File

@ -32,8 +32,8 @@ repositories {
description = 'dd-trace-java' description = 'dd-trace-java'
task traceAgentTest {} tasks.register("traceAgentTest")
task latestDepTest {} tasks.register("latestDepTest")
// Applied here to allow publishing of artifactory build info // Applied here to allow publishing of artifactory build info
apply from: "${rootDir}/gradle/publish.gradle" apply from: "${rootDir}/gradle/publish.gradle"
@ -50,13 +50,13 @@ buildScan {
} }
} }
ext.gradleWrapperVersion = '4.10.2' ext.gradleWrapperVersion = '4.10.3'
task wrapper(type: Wrapper) { tasks.register("wrapper", Wrapper) {
gradleVersion = gradleWrapperVersion gradleVersion = gradleWrapperVersion
} }
allprojects { allprojects {
tasks.withType(JavaForkOptions) { tasks.withType(JavaForkOptions).configureEach {
maxHeapSize = System.properties["datadog.forkedMaxHeapSize"] maxHeapSize = System.properties["datadog.forkedMaxHeapSize"]
minHeapSize = System.properties["datadog.forkedMinHeapSize"] minHeapSize = System.properties["datadog.forkedMinHeapSize"]
jvmArgs "-XX:ErrorFile=/tmp/hs_err_pid%p.log" jvmArgs "-XX:ErrorFile=/tmp/hs_err_pid%p.log"

View File

@ -30,7 +30,7 @@ checkstyle {
plugins.withType(GroovyBasePlugin) { plugins.withType(GroovyBasePlugin) {
sourceSets.all { sourceSet -> sourceSets.all { sourceSet ->
task "${sourceSet.getTaskName('checkstyle', 'groovy')}"(type: Checkstyle) { tasks.register("${sourceSet.getTaskName('checkstyle', 'groovy')}", Checkstyle) {
configFile = new File(checkstyleConfigDir, "checkstyle-groovy.xml") configFile = new File(checkstyleConfigDir, "checkstyle-groovy.xml")
source sourceSet.allGroovy source sourceSet.allGroovy
classpath = sourceSet.compileClasspath classpath = sourceSet.compileClasspath
@ -41,11 +41,13 @@ plugins.withType(GroovyBasePlugin) {
def checkstyleTasks = tasks.withType(Checkstyle) def checkstyleTasks = tasks.withType(Checkstyle)
task checkstyle(dependsOn: checkstyleTasks) tasks.register("checkstyle") {
dependsOn checkstyleTasks
}
check.dependsOn checkstyleTasks check.dependsOn checkstyleTasks
tasks.withType(Test) { tasks.withType(Test).configureEach {
mustRunAfter checkstyleTasks mustRunAfter checkstyleTasks
} }
@ -57,6 +59,6 @@ googleJavaFormat {
exclude '**/build/**/*.java' exclude '**/build/**/*.java'
} }
tasks.withType(Checkstyle) { tasks.withType(Checkstyle).configureEach {
mustRunAfter verifyGoogleJavaFormat mustRunAfter verifyGoogleJavaFormat
} }

View File

@ -49,7 +49,7 @@ jar {
duplicatesStrategy = 'fail' duplicatesStrategy = 'fail'
} }
task packageSources(type: Jar) { tasks.register("packageSources", Jar) {
classifier = 'sources' classifier = 'sources'
from sourceSets.main.allSource from sourceSets.main.allSource
} }
@ -70,7 +70,7 @@ dependencies {
testCompile group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.19.0' testCompile group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.19.0'
} }
tasks.withType(Javadoc) { tasks.withType(Javadoc).configureEach {
options.encoding = "utf-8" options.encoding = "utf-8"
options.docEncoding = "utf-8" options.docEncoding = "utf-8"
options.charSet = "utf-8" options.charSet = "utf-8"
@ -96,14 +96,15 @@ javadoc {
} }
} }
task sourceJar(type: Jar) { tasks.register("sourceJar", Jar) {
from sourceSets.main.allJava from sourceSets.main.allJava
classifier = 'sources' classifier = 'sources'
} }
task javaDocJar(type: Jar, dependsOn: javadoc) { tasks.register("javaDocJar", Jar) {
from javadoc.destinationDir from javadoc.destinationDir
classifier = 'javadoc' classifier = 'javadoc'
dependsOn javadoc
} }
artifacts { artifacts {
@ -113,7 +114,7 @@ artifacts {
project.afterEvaluate { project.afterEvaluate {
if (project.plugins.hasPlugin('org.unbroken-dome.test-sets') && configurations.hasProperty("latestDepTestRuntime")) { if (project.plugins.hasPlugin('org.unbroken-dome.test-sets') && configurations.hasProperty("latestDepTestRuntime")) {
tasks.withType(Test) { tasks.withType(Test).configureEach {
doFirst { doFirst {
def testArtifacts = configurations.testRuntime.resolvedConfiguration.resolvedArtifacts def testArtifacts = configurations.testRuntime.resolvedConfiguration.resolvedArtifacts
def latestTestArtifacts = configurations.latestDepTestRuntime.resolvedConfiguration.resolvedArtifacts def latestTestArtifacts = configurations.latestDepTestRuntime.resolvedConfiguration.resolvedArtifacts
@ -140,7 +141,7 @@ if (project.plugins.hasPlugin('com.github.johnrengelman.shadow')) {
} }
if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) { if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) {
tasks.withType(AbstractArchiveTask) { tasks.withType(AbstractArchiveTask).configureEach {
version = null version = null
} }
} }
@ -200,7 +201,7 @@ def isTestingEnabled(String javaName) {
} }
// Disable default test tasks if current JVM doesn't match version requirements // Disable default test tasks if current JVM doesn't match version requirements
tasks.withType(Test) { tasks.withType(Test).configureEach {
if (name.endsWith("Generated")) { if (name.endsWith("Generated")) {
return return
} }
@ -226,7 +227,7 @@ for (def env : System.getenv().entrySet()) {
} }
tasks.check.dependsOn parentTask tasks.check.dependsOn parentTask
tasks.withType(Test) { tasks.withType(Test).configureEach {
if (name.endsWith("Generated")) { if (name.endsWith("Generated")) {
return return
} }
@ -256,7 +257,7 @@ for (def env : System.getenv().entrySet()) {
// Disable all tests if skipTests property was specified // Disable all tests if skipTests property was specified
if (project.hasProperty("skipTests")) { if (project.hasProperty("skipTests")) {
tasks.withType(Test) { tasks.withType(Test).configureEach {
onlyIf { false } onlyIf { false }
} }
} }

View File

@ -21,7 +21,7 @@ ext {
modifyPom = { pomModifications << it } modifyPom = { pomModifications << it }
} }
tasks.withType(Upload) { tasks.withType(Upload).configureEach {
repositories.withType(org.gradle.api.artifacts.maven.MavenResolver) { repositories.withType(org.gradle.api.artifacts.maven.MavenResolver) {
it.pom.whenConfigured { pom -> it.pom.whenConfigured { pom ->
pomModifications.each { pomModifications.each {

View File

@ -24,7 +24,7 @@ afterEvaluate {
assert description: "Project $project.path is published, must have a description" assert description: "Project $project.path is published, must have a description"
} }
tasks.withType(Upload).matching { it.name != "install" }.all { tasks.withType(Upload).matching { it.name != "install" }.configureEach {
rootProject.subprojects { rootProject.subprojects {
mustRunAfter tasks.matching { it instanceof VerificationTask } mustRunAfter tasks.matching { it instanceof VerificationTask }
} }

View File

@ -1,4 +1,4 @@
task artifacts { tasks.register("artifacts") {
group = "Help" group = "Help"
description = "Displays the artifacts associated with each configuration of " + project description = "Displays the artifacts associated with each configuration of " + project
doFirst { doFirst {

View File

@ -7,7 +7,7 @@ def getGitHash = { ->
return stdout.toString().trim() return stdout.toString().trim()
} }
task writeVersionNumberFile { tasks.register("writeVersionNumberFile") {
def versionFile = file("${sourceSets.main.output.resourcesDir}/${project.name}.version") def versionFile = file("${sourceSets.main.output.resourcesDir}/${project.name}.version")
inputs.property "version", project.version inputs.property "version", project.version

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Wed Sep 26 11:49:09 EDT 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip