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'
}
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

View File

@ -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

View File

@ -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"

View File

@ -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"
}

View File

@ -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 }
// clean up the PID file from the server
finalizedBy deletePIDFile
}

View File

@ -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

View File

@ -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()
@ -73,8 +73,8 @@ task startServer(type: com.github.psxpaul.task.ExecFork) {
waitForPort = wildflyHttpPort
waitForOutput = "Undertow HTTP listener default listening on 127.0.0.1:${wildflyHttpPort}"
environment = [
'JAVA_OPTS' : "-javaagent:${project(':dd-java-agent').tasks.shadowJar.archivePath}"
+ " -Ddd.writer.type=LoggingWriter" + " -Ddd.service.name=java-app"
'JAVA_OPTS': "-javaagent:${project(':dd-java-agent').tasks.shadowJar.archivePath}"
+ " -Ddd.writer.type=LoggingWriter" + " -Ddd.service.name=java-app"
+ " -Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"
+ " -Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
+ " -Djboss.http.port=${wildflyHttpPort} -Djboss.https.port=${httpsPort}"
@ -84,16 +84,16 @@ 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"
args = [ "--connect", "--controller=localhost:${wildflyManagementPort}", "command=:shutdown" ]
args = ["--connect", "--controller=localhost:${wildflyManagementPort}", "command=:shutdown"]
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 }
// ensure that the wildfly server gets shutdown
finalizedBy stopWildfly
}

View File

@ -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"

View File

@ -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
}

View File

@ -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 }
}
}

View File

@ -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 {

View File

@ -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 }
}

View File

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

View File

@ -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

Binary file not shown.

View File

@ -1,6 +1,5 @@
#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