Some Gradle optimizations (#2949)

* Gradle optimizations

* Finish
This commit is contained in:
Anuraag Agrawal 2021-05-11 17:45:54 +09:00 committed by GitHub
parent 542415841d
commit abeca79e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 174 additions and 159 deletions

View File

@ -1,5 +1,6 @@
plugins { plugins {
id "me.champeau.jmh" version "0.6.2" id "me.champeau.jmh"
id "com.github.johnrengelman.shadow"
} }
apply from: "$rootDir/gradle/java.gradle" apply from: "$rootDir/gradle/java.gradle"
@ -25,7 +26,6 @@ jmh {
profilers = ['io.opentelemetry.benchmark.UsedMemoryProfiler', 'gc'] profilers = ['io.opentelemetry.benchmark.UsedMemoryProfiler', 'gc']
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
jmhVersion = '1.28' // Specifies JMH version
def jmhIncludeSingleClass = project.findProperty('jmhIncludeSingleClass') def jmhIncludeSingleClass = project.findProperty('jmhIncludeSingleClass')
if (jmhIncludeSingleClass != null) { if (jmhIncludeSingleClass != null) {
@ -33,7 +33,9 @@ jmh {
} }
} }
tasks.jmh.dependsOn(':javaagent:shadowJar') tasks.named('jmh').configure {
dependsOn(':javaagent:shadowJar')
}
/* /*
If using libasyncProfiler, use the following to generate nice svg flamegraphs. If using libasyncProfiler, use the following to generate nice svg flamegraphs.

View File

@ -4,22 +4,22 @@ import nebula.plugin.release.git.opinion.Strategies
plugins { plugins {
id 'idea' id 'idea'
id "io.github.gradle-nexus.publish-plugin" version "1.0.0" id "io.github.gradle-nexus.publish-plugin"
id "nebula.release" version "15.3.0" id "nebula.release"
id 'org.gradle.test-retry' version '1.2.0' apply false id 'org.gradle.test-retry' apply false
id 'org.unbroken-dome.test-sets' version '3.0.1' apply false id 'org.unbroken-dome.test-sets' apply false
id 'com.github.ben-manes.versions' version '0.27.0' id 'com.github.ben-manes.versions'
id 'com.dorongold.task-tree' version '1.5' id 'com.dorongold.task-tree'
id "com.github.johnrengelman.shadow" version "6.1.0" apply false id "com.github.johnrengelman.shadow" apply false
id "com.diffplug.spotless" version "5.8.2" id "com.diffplug.spotless"
id "com.github.spotbugs" version "4.6.0" apply false id "com.github.spotbugs" apply false
id "net.ltgt.errorprone" version "1.3.0" apply false id "net.ltgt.errorprone" apply false
} }
release { release {
@ -89,6 +89,3 @@ spotless {
endWithNewline() endWithNewline()
} }
} }
task formatCode(dependsOn: ['spotlessApply'])
check.dependsOn 'spotlessCheck'

View File

@ -5,7 +5,6 @@
package io.opentelemetry.instrumentation.gradle.bytebuddy; package io.opentelemetry.instrumentation.gradle.bytebuddy;
import com.google.common.collect.ImmutableList;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -13,6 +12,7 @@ import net.bytebuddy.build.gradle.ByteBuddySimpleTask;
import net.bytebuddy.build.gradle.Transformation; import net.bytebuddy.build.gradle.Transformation;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task; import org.gradle.api.Task;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.compile.AbstractCompile; import org.gradle.api.tasks.compile.AbstractCompile;
@ -40,10 +40,10 @@ public class ByteBuddyPluginConfigurator {
private final Project project; private final Project project;
private final SourceSet sourceSet; private final SourceSet sourceSet;
private final String pluginClassName; private final String pluginClassName;
private final Iterable<File> inputClasspath; private final FileCollection inputClasspath;
public ByteBuddyPluginConfigurator( public ByteBuddyPluginConfigurator(
Project project, SourceSet sourceSet, String pluginClassName, Iterable<File> inputClasspath) { Project project, SourceSet sourceSet, String pluginClassName, FileCollection inputClasspath) {
this.project = project; this.project = project;
this.sourceSet = sourceSet; this.sourceSet = sourceSet;
this.pluginClassName = pluginClassName; this.pluginClassName = pluginClassName;
@ -51,18 +51,18 @@ public class ByteBuddyPluginConfigurator {
// add build resources dir to classpath if it's present // add build resources dir to classpath if it's present
File resourcesDir = sourceSet.getOutput().getResourcesDir(); File resourcesDir = sourceSet.getOutput().getResourcesDir();
this.inputClasspath = this.inputClasspath =
resourcesDir == null resourcesDir == null ? inputClasspath : inputClasspath.plus(project.files(resourcesDir));
? inputClasspath
: ImmutableList.<File>builder()
.addAll(inputClasspath)
.add(sourceSet.getOutput().getResourcesDir())
.build();
} }
public void configure() { public void configure() {
String taskName = getTaskName(); String taskName = getTaskName();
Task byteBuddyTask = project.getTasks().create(taskName); Task byteBuddyTask =
project
.getTasks()
// TODO(anuraaga): Use lazy configuration to create muzzle task.
.create(
taskName,
task -> {
for (String language : LANGUAGES) { for (String language : LANGUAGES) {
AbstractCompile compile = getCompileTask(language); AbstractCompile compile = getCompileTask(language);
@ -70,15 +70,24 @@ public class ByteBuddyPluginConfigurator {
Task languageTask = createLanguageTask(compile, taskName + language); Task languageTask = createLanguageTask(compile, taskName + language);
// We also process resources for SPI classes. // We also process resources for SPI classes.
languageTask.dependsOn(sourceSet.getProcessResourcesTaskName()); languageTask.dependsOn(sourceSet.getProcessResourcesTaskName());
byteBuddyTask.dependsOn(languageTask); task.dependsOn(languageTask);
} }
} }
});
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(byteBuddyTask); project
.getTasks()
.named(sourceSet.getClassesTaskName())
.configure(task -> task.dependsOn(byteBuddyTask));
} }
private Task createLanguageTask(AbstractCompile compileTask, String name) { private Task createLanguageTask(AbstractCompile compileTask, String name) {
ByteBuddySimpleTask task = project.getTasks().create(name, ByteBuddySimpleTask.class); return project
.getTasks()
.create(
name,
ByteBuddySimpleTask.class,
task -> {
task.setGroup("Byte Buddy"); task.setGroup("Byte Buddy");
task.getOutputs().cacheIf(unused -> true); task.getOutputs().cacheIf(unused -> true);
@ -97,7 +106,7 @@ public class ByteBuddyPluginConfigurator {
task.dependsOn(compileTask); task.dependsOn(compileTask);
task.getTransformations().add(createTransformation(inputClasspath, pluginClassName)); task.getTransformations().add(createTransformation(inputClasspath, pluginClassName));
return task; });
} }
private AbstractCompile getCompileTask(String language) { private AbstractCompile getCompileTask(String language) {
@ -123,7 +132,7 @@ public class ByteBuddyPluginConfigurator {
} }
private static Transformation createTransformation( private static Transformation createTransformation(
Iterable<File> classPath, String pluginClassName) { FileCollection classPath, String pluginClassName) {
Transformation transformation = new ClasspathTransformation(classPath, pluginClassName); Transformation transformation = new ClasspathTransformation(classPath, pluginClassName);
transformation.setPlugin(ClasspathByteBuddyPlugin.class); transformation.setPlugin(ClasspathByteBuddyPlugin.class);
return transformation; return transformation;

View File

@ -68,9 +68,14 @@ configurations {
if (testLatestDeps) { if (testLatestDeps) {
afterEvaluate { afterEvaluate {
def latestDepTest = tasks.findByName('latestDepTest') // Try/catch seems to be the only way to access an optional task with lazy configuration API.
if (latestDepTest) { try {
tasks.test.dependsOn latestDepTest def latestDepTest = tasks.named('latestDepTest')
tasks.named('test').configure {
dependsOn(latestDepTest)
}
} catch (UnknownDomainObjectException e) {
// Ignore
} }
} }
} }

View File

@ -80,7 +80,7 @@ configurations {
testInstrumentation testInstrumentation
} }
shadowJar { tasks.named('shadowJar').configure {
configurations = [project.configurations.runtimeClasspath, project.configurations.testInstrumentation] configurations = [project.configurations.runtimeClasspath, project.configurations.testInstrumentation]
mergeServiceFiles() mergeServiceFiles()

View File

@ -4,8 +4,8 @@ jacoco {
toolVersion = "0.8.6" toolVersion = "0.8.6"
} }
jacocoTestReport { tasks.named('jacocoTestReport').configure {
dependsOn test dependsOn('test')
reports { reports {
xml.enabled true xml.enabled true
csv.enabled false csv.enabled false
@ -30,7 +30,7 @@ project.ext.minimumBranchCoverage = 0.9
project.ext.minimumInstructionCoverage = 0.9 project.ext.minimumInstructionCoverage = 0.9
afterEvaluate { afterEvaluate {
tasks.withType(Test) { tasks.withType(Test).configureEach {
jacoco { jacoco {
// Make sure that excluded classes do not get jacoco instrumentation applied since it may confuse apm agent in some cases // Make sure that excluded classes do not get jacoco instrumentation applied since it may confuse apm agent in some cases
excludes = project.excludedClassesCoverage excludes = project.excludedClassesCoverage
@ -59,6 +59,10 @@ afterEvaluate {
} }
} }
jacocoTestCoverageVerification.dependsOn jacocoTestReport tasks.named('jacocoTestCoverageVerification').configure {
check.dependsOn jacocoTestCoverageVerification dependsOn('jacocoTestReport')
}
tasks.named('check').configure {
dependsOn('jacocoTestCoverageVerification')
}
} }

View File

@ -50,48 +50,20 @@ java {
withSourcesJar() withSourcesJar()
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
options.release.set(project.ext.release.majorVersion.toInteger()) options.release.set(project.ext.release.majorVersion.toInteger())
options.compilerArgs.add("-Werror") options.compilerArgs.add("-Werror")
} }
//Groovy and Scala compilers don't actually understand --release option //Groovy and Scala compilers don't actually understand --release option
tasks.withType(GroovyCompile) { tasks.withType(GroovyCompile).configureEach {
sourceCompatibility = JavaVersion.toVersion(project.ext.release) sourceCompatibility = JavaVersion.toVersion(project.ext.release)
targetCompatibility = JavaVersion.toVersion(project.ext.release) targetCompatibility = JavaVersion.toVersion(project.ext.release)
} }
tasks.withType(ScalaCompile) { tasks.withType(ScalaCompile).configureEach {
sourceCompatibility = JavaVersion.toVersion(project.ext.release) sourceCompatibility = JavaVersion.toVersion(project.ext.release)
targetCompatibility = JavaVersion.toVersion(project.ext.release) targetCompatibility = JavaVersion.toVersion(project.ext.release)
} }
apply plugin: "eclipse"
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
}
}
if (configurations.find { it.name == 'jmh' }) {
eclipse.classpath.plusConfigurations += [configurations.jmh]
}
jar {
/*
Make Jar build fail on duplicate files
By default Gradle Jar task can put multiple files with the same name
into a Jar. This may lead to confusion. For example if auto-service
annotation processing creates files with same name in `scala` and
`java` directory this would result in Jar having two files with the
same name in it. Which in turn would result in only one of those
files being actually considered when that Jar is used leading to very
confusing failures.
Instead we should 'fail early' and avoid building such Jars.
*/
duplicatesStrategy = 'fail'
}
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
@ -113,7 +85,22 @@ dependencies {
testImplementation group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.19.0' testImplementation group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.19.0'
} }
jar { tasks.named('jar').configure {
/*
Make Jar build fail on duplicate files
By default Gradle Jar task can put multiple files with the same name
into a Jar. This may lead to confusion. For example if auto-service
annotation processing creates files with same name in `scala` and
`java` directory this would result in Jar having two files with the
same name in it. Which in turn would result in only one of those
files being actually considered when that Jar is used leading to very
confusing failures.
Instead we should 'fail early' and avoid building such Jars.
*/
duplicatesStrategy = 'fail'
manifest { manifest {
attributes( attributes(
"Implementation-Title": project.name, "Implementation-Title": project.name,
@ -132,7 +119,7 @@ normalization {
} }
} }
javadoc { tasks.named('javadoc').configure {
options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('Xdoclint:none', '-quiet')
// non-standard option to fail on warnings, see https://bugs.openjdk.java.net/browse/JDK-8200363 // non-standard option to fail on warnings, see https://bugs.openjdk.java.net/browse/JDK-8200363
options.addStringOption('Xwerror', '-quiet') options.addStringOption('Xwerror', '-quiet')
@ -183,7 +170,7 @@ def isJavaVersionAllowed(JavaVersion version) {
def testJavaVersion = rootProject.findProperty('testJavaVersion') def testJavaVersion = rootProject.findProperty('testJavaVersion')
if (testJavaVersion != null) { if (testJavaVersion != null) {
def requestedJavaVersion = JavaVersion.toVersion(testJavaVersion) def requestedJavaVersion = JavaVersion.toVersion(testJavaVersion)
tasks.withType(Test).all { tasks.withType(Test).configureEach {
javaLauncher = javaToolchains.launcherFor { javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(requestedJavaVersion.majorVersion) languageVersion = JavaLanguageVersion.of(requestedJavaVersion.majorVersion)
} }
@ -194,7 +181,7 @@ if (testJavaVersion != null) {
// the default test task's version so commands like `./gradlew check` can test all projects regardless // the default test task's version so commands like `./gradlew check` can test all projects regardless
// of Java version. // of Java version.
if (!isJavaVersionAllowed(JavaVersion.toVersion(DEFAULT_JAVA_VERSION))) { if (!isJavaVersionAllowed(JavaVersion.toVersion(DEFAULT_JAVA_VERSION))) {
tasks.withType(Test) { tasks.withType(Test).configureEach {
javaLauncher = javaToolchains.launcherFor { javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(project.getProperty('maxJavaVersionForTests').majorVersion) languageVersion = JavaLanguageVersion.of(project.getProperty('maxJavaVersionForTests').majorVersion)
} }
@ -229,7 +216,7 @@ tasks.withType(Test).configureEach {
jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=${rootProject.findProperty('enableStrictContext') ?: false}" jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=${rootProject.findProperty('enableStrictContext') ?: false}"
} }
tasks.withType(AbstractArchiveTask) { tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false preserveFileTimestamps = false
reproducibleFileOrder = true reproducibleFileOrder = true
} }
@ -240,7 +227,7 @@ plugins.withId('net.ltgt.errorprone') {
errorprone group: "com.google.errorprone", name: "error_prone_core", version: versions.errorprone errorprone group: "com.google.errorprone", name: "error_prone_core", version: versions.errorprone
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
if (!name.toLowerCase().contains("test")) { if (!name.toLowerCase().contains("test")) {
options.errorprone { options.errorprone {
error("NullAway") error("NullAway")

View File

@ -88,7 +88,9 @@ private String artifactPrefix(Project p, String archivesBaseName) {
return 'opentelemetry-' return 'opentelemetry-'
} }
rootProject.tasks.release.finalizedBy tasks.publishToSonatype rootProject.tasks.named('release').configure {
finalizedBy tasks.publishToSonatype
}
tasks.withType(Sign).configureEach { tasks.withType(Sign).configureEach {
onlyIf { System.getenv("CI") != null } onlyIf { System.getenv("CI") != null }

View File

@ -11,7 +11,9 @@ allprojects {
excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml") excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
} }
spotbugsTest { // NB: For some reason, SpotBugsTask can't be referenced even when importing it.
tasks.withType(VerificationTask).configureEach {
if (name.startsWith("spotbugs")) {
reports { reports {
html.enabled = !isCI html.enabled = !isCI
xml.enabled = isCI xml.enabled = isCI
@ -20,13 +22,5 @@ allprojects {
} }
} }
} }
spotbugsMain {
reports {
html.enabled = !isCI
xml.enabled = isCI
html {
stylesheet = 'fancy-hist.xsl'
}
}
} }
} }

View File

@ -27,6 +27,3 @@ spotless {
endWithNewline() endWithNewline()
} }
} }
task formatCode(dependsOn: ['spotlessApply'])
check.dependsOn 'spotlessCheck'

View File

@ -1,7 +1,7 @@
// Enable testing kotlin code in groovy spock tests. // Enable testing kotlin code in groovy spock tests.
apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'org.jetbrains.kotlin.jvm'
compileTestGroovy { tasks.named('compileTestGroovy').configure {
//Note: look like it should be `classpath += files(sourceSets.test.kotlin.classesDirectory)` //Note: look like it should be `classpath += files(sourceSets.test.kotlin.classesDirectory)`
//instead, but kotlin plugin doesn't support it (yet?) //instead, but kotlin plugin doesn't support it (yet?)
classpath += files(compileTestKotlin.destinationDir) classpath += files(compileTestKotlin.destinationDir)

View File

@ -6,6 +6,6 @@ dependencies {
testImplementation deps.scala testImplementation deps.scala
} }
compileTestGroovy { tasks.named('compileTestGroovy').configure {
classpath += files(sourceSets.test.scala.classesDirectory) classpath += files(sourceSets.test.scala.classesDirectory)
} }

View File

@ -17,6 +17,6 @@ dependencies {
testImplementation group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0' testImplementation group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs '-Dotel.instrumentation.akka-actor.enabled=true' jvmArgs '-Dotel.instrumentation.akka-actor.enabled=true'
} }

View File

@ -63,7 +63,7 @@ compileVersion101TestGroovy {
dependsOn compileVersion101TestScala dependsOn compileVersion101TestScala
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2639 // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2639
jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false" jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false"
} }

View File

@ -46,7 +46,7 @@ dependencies {
latestDepTestLibrary group: 'org.apache.camel', name: 'camel-aws', version: '2.+' latestDepTestLibrary group: 'org.apache.camel', name: 'camel-aws', version: '2.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.apache-camel.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.apache-camel.experimental-span-attributes=true"
jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true"

View File

@ -97,7 +97,7 @@ if (!testLatestDeps) {
check.dependsOn test_before_1_11_106, testSqs check.dependsOn test_before_1_11_106, testSqs
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true"
} }

View File

@ -22,7 +22,7 @@ dependencies {
testImplementation project(':instrumentation:netty:netty-4.1:javaagent') testImplementation project(':instrumentation:netty:netty-4.1:javaagent')
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true"
} }

View File

@ -31,7 +31,7 @@ dependencies {
latestDepTestLibrary group: 'com.couchbase.client', name: 'java-client', version: '2.+' latestDepTestLibrary group: 'com.couchbase.client', name: 'java-client', version: '2.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.couchbase.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.couchbase.experimental-span-attributes=true"
} }

View File

@ -38,7 +38,7 @@ dependencies {
testImplementation group: 'org.elasticsearch.client', name: 'transport', version: '5.0.0' testImplementation group: 'org.elasticsearch.client', name: 'transport', version: '5.0.0'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true"
} }

View File

@ -43,7 +43,7 @@ dependencies {
latestDepTestLibrary group: 'org.springframework.data', name: 'spring-data-elasticsearch', version: '3.0.+' latestDepTestLibrary group: 'org.springframework.data', name: 'spring-data-elasticsearch', version: '3.0.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true"
} }

View File

@ -37,7 +37,7 @@ dependencies {
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0' testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true"
} }

View File

@ -6,7 +6,7 @@ muzzle {
} }
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Dotel.instrumentation.executors.include=ExecutorInstrumentationTest\$CustomThreadPoolExecutor" jvmArgs "-Dotel.instrumentation.executors.include=ExecutorInstrumentationTest\$CustomThreadPoolExecutor"
jvmArgs "-Djava.awt.headless=true" jvmArgs "-Djava.awt.headless=true"
} }

View File

@ -20,11 +20,11 @@ dependencies {
latestDepTestLibrary group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.+' latestDepTestLibrary group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Dotel.instrumentation.grizzly.enabled=true" jvmArgs "-Dotel.instrumentation.grizzly.enabled=true"
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2640 // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2640
jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false" jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false"
} }

View File

@ -15,7 +15,7 @@ dependencies {
library group: 'io.reactivex', name: 'rxjava', version: '1.0.7' library group: 'io.reactivex', name: 'rxjava', version: '1.0.7'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.hystrix.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.hystrix.experimental-span-attributes=true"
// Disable so failure testing below doesn't inadvertently change the behavior. // Disable so failure testing below doesn't inadvertently change the behavior.

View File

@ -38,7 +38,7 @@ dependencies {
latestDepTestLibrary group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.+' latestDepTestLibrary group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true"
} }

View File

@ -46,7 +46,7 @@ test {
systemProperty 'testLatestDeps', testLatestDeps systemProperty 'testLatestDeps', testLatestDeps
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true"
} }

View File

@ -49,7 +49,7 @@ test {
systemProperty 'testLatestDeps', testLatestDeps systemProperty 'testLatestDeps', testLatestDeps
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true"
} }

View File

@ -53,7 +53,7 @@ if (findProperty('testLatestDeps')) {
} }
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.jaxrs.experimental-span-attributes=true"
} }

View File

@ -26,6 +26,6 @@ dependencies {
latestDepTestLibrary group: 'org.apache.derby', name: 'derby', version: '10.14.+' latestDepTestLibrary group: 'org.apache.derby', name: 'derby', version: '10.14.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Dotel.instrumentation.jdbc-datasource.enabled=true" jvmArgs "-Dotel.instrumentation.jdbc-datasource.enabled=true"
} }

View File

@ -34,7 +34,7 @@ dependencies {
latestDepTestLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '9.+' latestDepTestLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '9.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// skip jar scanning using environment variables: // skip jar scanning using environment variables:
// http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html#JAR_Scanning // http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html#JAR_Scanning
// having this set allows us to test with old versions of the tomcat api since // having this set allows us to test with old versions of the tomcat api since

View File

@ -29,7 +29,7 @@ dependencies {
latestDepTestLibrary group: 'org.assertj', name: 'assertj-core', version: '3.+' latestDepTestLibrary group: 'org.assertj', name: 'assertj-core', version: '3.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.kafka.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.kafka.experimental-span-attributes=true"
} }

View File

@ -34,7 +34,7 @@ dependencies {
latestDepTestLibrary group: 'org.assertj', name: 'assertj-core', version: '3.+' latestDepTestLibrary group: 'org.assertj', name: 'assertj-core', version: '3.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.kafka.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.kafka.experimental-span-attributes=true"
} }

View File

@ -17,7 +17,7 @@ dependencies {
testInstrumentation(project(':instrumentation:okhttp:okhttp-3.0:javaagent')) testInstrumentation(project(':instrumentation:okhttp:okhttp-3.0:javaagent'))
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.kubernetes-client.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.kubernetes-client.experimental-span-attributes=true"
} }

View File

@ -18,7 +18,7 @@ dependencies {
latestDepTestLibrary group: 'biz.paluch.redis', name: 'lettuce', version: '4.+' latestDepTestLibrary group: 'biz.paluch.redis', name: 'lettuce', version: '4.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.lettuce.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.lettuce.experimental-span-attributes=true"
} }

View File

@ -19,7 +19,7 @@ dependencies {
testInstrumentation project(':instrumentation:reactor-3.1:javaagent') testInstrumentation project(':instrumentation:reactor-3.1:javaagent')
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.lettuce.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.lettuce.experimental-span-attributes=true"
} }

View File

@ -10,6 +10,6 @@ dependencies {
compileOnly project(':javaagent-tooling') compileOnly project(':javaagent-tooling')
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Dotel.instrumentation.methods.include=package.ClassName[method1,method2];MethodTest\$ConfigTracedCallable[call]" jvmArgs "-Dotel.instrumentation.methods.include=package.ClassName[method1,method2];MethodTest\$ConfigTracedCallable[call]"
} }

View File

@ -23,7 +23,7 @@ configurations.testRuntime {
} }
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.rabbitmq.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.rabbitmq.experimental-span-attributes=true"
} }

View File

@ -20,7 +20,7 @@ dependencies {
} }
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2648 // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2648
jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false" jvmArgs "-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false"
} }

View File

@ -6,7 +6,9 @@ muzzle {
} }
} }
task "rmic", dependsOn: testClasses { def rmic = tasks.register('rmic') {
dependsOn(testClasses)
def clazz = 'rmi.app.ServerLegacy' def clazz = 'rmi.app.ServerLegacy'
// Try one level up too in case java.home refers to jre directory inside jdk directory // Try one level up too in case java.home refers to jre directory inside jdk directory
@ -19,7 +21,7 @@ task "rmic", dependsOn: testClasses {
command.execute().text command.execute().text
} }
test.dependsOn "rmic" test.dependsOn rmic
// We cannot use "--release" javac option here because that will forbid importing "sun.rmi" package. // We cannot use "--release" javac option here because that will forbid importing "sun.rmi" package.
// We also can't seem to use the toolchain without the "--release" option. So disable everything. // We also can't seem to use the toolchain without the "--release" option. So disable everything.
@ -32,12 +34,12 @@ java {
} }
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile).configureEach {
options.release = null options.release = null
} }
tasks.withType(GroovyCompile) { tasks.withType(GroovyCompile).configureEach {
options.release = null options.release = null
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Djava.rmi.server.hostname=127.0.0.1" jvmArgs "-Djava.rmi.server.hostname=127.0.0.1"
} }

View File

@ -16,6 +16,6 @@ dependencies {
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Dotel.instrumentation.rocketmq-client.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.rocketmq-client.experimental-span-attributes=true"
} }

View File

@ -13,6 +13,6 @@ dependencies {
testLibrary group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.0' testLibrary group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.0'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs "-Djava.awt.headless=true" jvmArgs "-Djava.awt.headless=true"
} }

View File

@ -17,7 +17,7 @@ dependencies {
testInstrumentation project(':instrumentation:spring:spring-core-2.0:javaagent') testInstrumentation project(':instrumentation:spring:spring-core-2.0:javaagent')
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
jvmArgs '-Dotel.instrumentation.spring-batch.enabled=true' jvmArgs '-Dotel.instrumentation.spring-batch.enabled=true'
} }
test { test {

View File

@ -51,7 +51,7 @@ dependencies {
testImplementation group: 'org.spockframework', name: 'spock-spring', version: '1.1-groovy-2.4' testImplementation group: 'org.spockframework', name: 'spock-spring', version: '1.1-groovy-2.4'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs '-Dotel.instrumentation.spring-webflux.experimental-span-attributes=true' jvmArgs '-Dotel.instrumentation.spring-webflux.experimental-span-attributes=true'
// TODO(anuraaga): There is no actual context leak - it just seems that the server-side does not // TODO(anuraaga): There is no actual context leak - it just seems that the server-side does not

View File

@ -57,7 +57,7 @@ dependencies {
testImplementation "org.glassfish.jaxb:jaxb-runtime:2.3.2" testImplementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs '-Dotel.instrumentation.spring-webmvc.experimental-span-attributes=true' jvmArgs '-Dotel.instrumentation.spring-webmvc.experimental-span-attributes=true'
} }

View File

@ -16,7 +16,7 @@ dependencies {
testImplementation deps.testcontainers testImplementation deps.testcontainers
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.spymemcached.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.spymemcached.experimental-span-attributes=true"
} }

View File

@ -18,7 +18,7 @@ dependencies {
latestDepTestLibrary group: 'com.twilio.sdk', name: 'twilio', version: '7.+' latestDepTestLibrary group: 'com.twilio.sdk', name: 'twilio', version: '7.+'
} }
tasks.withType(Test) { tasks.withType(Test).configureEach {
// TODO run tests both with and without experimental span attributes // TODO run tests both with and without experimental span attributes
jvmArgs "-Dotel.instrumentation.twilio.experimental-span-attributes=true" jvmArgs "-Dotel.instrumentation.twilio.experimental-span-attributes=true"
} }

View File

@ -1,3 +1,19 @@
pluginManagement {
plugins {
id "com.diffplug.spotless" version "5.8.2"
id 'com.dorongold.task-tree' version '1.5'
id 'com.github.ben-manes.versions' version '0.27.0'
id "com.github.johnrengelman.shadow" version "6.1.0"
id "com.github.spotbugs" version "4.6.0"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "me.champeau.jmh" version "0.6.4"
id "net.ltgt.errorprone" version "1.3.0"
id 'org.unbroken-dome.test-sets' version '3.0.1'
id "nebula.release" version "15.3.0"
id 'org.gradle.test-retry' version '1.2.0'
}
}
plugins { plugins {
id 'com.gradle.enterprise' version '3.5' id 'com.gradle.enterprise' version '3.5'
id 'com.github.burrunan.s3-build-cache' version '1.1' id 'com.github.burrunan.s3-build-cache' version '1.1'