Upgrade Gradle to 4.10.3
Also try to improve build time performance by reducing the required configuration:
MODIFY
dd-java-agent/agent-jmxfetch/agent-jmxfetch.gradle
dd-java-agent/agent-jmxfetch/agent-jmxfetch.gradle
@@ -28,13 +28,13 @@ jar {
classifier = 'unbundled'
}
-task submodulesUpdate(type:Exec) {
+tasks.register("submodulesUpdate", Exec) {
group 'Build Setup'
description 'Initializes and updates integrations-core git submodule'
commandLine 'git', 'submodule', 'update', '--init', 'integrations-core'
}
-task copyMetricConfigs(type:Exec) {
+tasks.register("copyMetricConfigs", Exec) {
group 'Build Setup'
description 'Copy metrics.yaml files from integrations-core into resources'
commandLine './copy-metric-configs.sh', 'integrations-core', sourceSets.main.output.resourcesDir

MODIFY
dd-java-agent/benchmark/benchmark.gradle
dd-java-agent/benchmark/benchmark.gradle
@@ -54,7 +54,7 @@ jmh {
}
// 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 += sourceSets.jmh.runtimeClasspath
main = "org.openjdk.jmh.Main"
@@ -66,6 +66,7 @@ task jmhAgent(type: JavaExec, dependsOn: project.tasks.jmhCompileGeneratedClasse
// args += ["-wi", "2"]
// args += ["-i", "5"]
+ dependsOn project.tasks.jmhCompileGeneratedClasses
}
tasks.jmhAgent.dependsOn project(':dd-java-agent').shadowJar

MODIFY
dd-java-agent/dd-java-agent.gradle
dd-java-agent/dd-java-agent.gradle
@@ -109,7 +109,7 @@ dependencies {
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 "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"
jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"

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

MODIFY
dd-smoke-tests/play/play.gradle
dd-smoke-tests/play/play.gradle
@@ -69,7 +69,7 @@ dependencies {
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
playHttpPort = randomOpenPort()
@@ -96,11 +96,11 @@ task startServer(type: com.github.psxpaul.task.ExecFork) {
dependsOn 'stage'
}
-task deletePIDFile() {
+tasks.register("deletePIDFile") {
delete "${buildDir}/stage/playBinary/RUNNING_PID"
}
-tasks.withType(Test) {
+tasks.withType(Test).configureEach {
// so the test can get this property
jvmArgs "-Ddatadog.smoketest.server.port=${playHttpPort}"
@@ -109,7 +109,7 @@ tasks.withType(Test) {
}
dependsOn startServer
-}
// clean up the PID file from the server
-tasks.withType(Test).forEach { it.finalizedBy deletePIDFile }
+ finalizedBy deletePIDFile
+}

MODIFY
dd-smoke-tests/springboot/springboot.gradle
dd-smoke-tests/springboot/springboot.gradle
@@ -29,7 +29,7 @@ dependencies {
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()
dependsOn project(':dd-java-agent').shadowJar, shadowJar
@@ -51,7 +51,7 @@ task startServer(type: com.github.psxpaul.task.ExecFork) {
stopAfter = test
}
-tasks.withType(Test) {
+tasks.withType(Test).configureEach {
jvmArgs "-Ddatadog.smoketest.server.port=${springbootHttpPort}"
dependsOn startServer

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

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

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

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

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

MODIFY
gradle/publish.gradle
gradle/publish.gradle
@@ -24,7 +24,7 @@ afterEvaluate {
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 {
mustRunAfter tasks.matching { it instanceof VerificationTask }
}

MODIFY
gradle/util.gradle
gradle/util.gradle
-task artifacts {
+tasks.register("artifacts") {
group = "Help"
description = "Displays the artifacts associated with each configuration of " + project
doFirst {

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

MODIFY
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.jar
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ

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

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