Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 42 additions & 38 deletions dd-java-agent/instrumentation/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import static org.gradle.api.plugins.JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME
import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
Expand All @@ -10,51 +13,56 @@ tasks.register("latestDepTest", Test)

Project parent_project = project
subprojects { Project subProj ->
apply plugin: 'instrument'
apply plugin: 'muzzle'

configurations {
instrumentPluginClasspath {
visible = false
canBeConsumed = false
canBeResolved = true
subProj.pluginManager.withPlugin("instrument") {
subProj.extensions.configure(InstrumentExtension) {
it.plugins.addAll(
'datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin',
'datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin',
'datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin',
)
}
}

instrument.plugins = [
'datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin',
'datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin',
'datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin',
]
subProj.configurations.register("instrumentPluginClasspath") {
it.visible = false
it.canBeConsumed = false
it.canBeResolved = true

subProj.tasks.withType(Javadoc).configureEach { enabled = false }
it.dependencies.add(subProj.dependencies.project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath'))
}
}

subProj.afterEvaluate {
if (!plugins.hasPlugin("java")) {
return
subProj.pluginManager.withPlugin("java") {
subProj.pluginManager.withPlugin("muzzle") {
subProj.configurations.matching { it.name == 'muzzleBootstrap' }.configureEach {
exclude group: 'org.snakeyaml', module: 'snakeyaml-engine' // we vendor this in the agent jar
}
}

subProj.tasks.withType(Javadoc).configureEach { enabled = false }

// Configures base dependencies for additional sourceSet
configurations
.matching { it.name.matches("${SourceSet.MAIN_SOURCE_SET_NAME}_java\\d+${JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME.capitalize()}") }
subProj.configurations
.matching { it.name.matches("${MAIN_SOURCE_SET_NAME}_java\\d+${IMPLEMENTATION_CONFIGURATION_NAME.capitalize()}") }
.configureEach {
it.dependencies.add(project.dependencyFactory.create(project(':dd-trace-api')))
it.dependencies.add(project.dependencyFactory.create(project(':dd-java-agent:agent-tooling')))
it.dependencies.add(subProj.dependencyFactory.create(project(':dd-trace-api')))
it.dependencies.add(subProj.dependencyFactory.create(project(':dd-java-agent:agent-tooling')))
it.dependencies.addLater(libs.bytebuddy)
}

configurations.named('muzzleBootstrap') {
exclude group: 'org.snakeyaml', module: 'snakeyaml-engine' // we vendor this in the agent jar
}
dependencies {
// Main
annotationProcessor project(':dd-java-agent:instrumentation-annotation-processor')
annotationProcessor libs.autoservice.processor
compileOnly libs.autoservice.annotation

// Apply common dependencies for instrumentation.
implementation project(':dd-trace-api')
implementation project(':dd-java-agent:agent-tooling')
implementation libs.bytebuddy

annotationProcessor project(':dd-java-agent:instrumentation-annotation-processor')
annotationProcessor libs.autoservice.processor
compileOnly libs.autoservice.annotation
// Tests
testAnnotationProcessor libs.autoservice.processor
testCompileOnly libs.autoservice.annotation

// Include instrumentations instrumenting core JDK classes to ensure interoperability with other instrumentation
testImplementation project(':dd-java-agent:instrumentation:java:java-concurrent:java-concurrent-1.8')
Expand All @@ -63,28 +71,24 @@ subprojects { Project subProj ->
testImplementation project(':dd-java-agent:instrumentation:classloading')

testImplementation project(':dd-java-agent:instrumentation-testing')
testAnnotationProcessor libs.autoservice.processor
testCompileOnly libs.autoservice.annotation

instrumentPluginClasspath project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath')
}

subProj.tasks.withType(Test).configureEach { subTask ->
if (subTask.name in ['latestDepTest', 'latestDepForkedTest']) {
subTask.jvmArgs '-Dtest.dd.latestDepTest=true'
}
}
}

def path = subProj.getPath()
subProj.plugins.withId("java") {
if (!path.equals(':dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs')) {
// don't include the redis RequestImpl stub
if (subProj.path != ':dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs') {
// don't include the redis RequestImpl stubs
parent_project.dependencies {
implementation project(path)
addProvider("implementation", providers.provider { project(subProj.path) })
}
}
}

subProj.apply plugin: 'instrument'
subProj.apply plugin: 'muzzle'
}

dependencies {
Expand Down
21 changes: 16 additions & 5 deletions dd-java-agent/instrumentation/dropwizard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@ dependencies {
testImplementation project(':dd-java-agent:instrumentation:rs:jax-rs:jax-rs-annotations:jax-rs-annotations-2')
testImplementation project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-3.0')

// Don't want to conflict with jetty from the test server.
testImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}

// First version with DropwizardTestSupport:
testImplementation group: 'io.dropwizard', name: 'dropwizard-testing', version: '0.8.0'
testImplementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.3'
testImplementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner', version: '2.9.10'

constraints {
// Don't want to conflict with jetty from the test server.
testImplementation('org.eclipse.jetty:jetty-server') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '9.2.9.v20150224'
}
}
testImplementation('org.eclipse.jetty:jetty-servlet') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '9.2.9.v20150224'
}
}
}

// Anything 1.0+ fails with a java.lang.NoClassDefFoundError: org/eclipse/jetty/server/RequestLog
// latestDepTestImplementation group: 'io.dropwizard', name: 'dropwizard-testing', version: '1.+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,24 @@ dependencies {
implementation(project(':dd-java-agent:instrumentation:jetty:jetty-client:jetty-client-common')) {
transitive = false
}
testImplementation(project(':dd-java-agent:instrumentation-testing')) {
// explicitly declared below.
exclude group: 'org.eclipse.jetty'
}
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-util-9.4.31')
testImplementation group: 'org.eclipse.jetty', name: 'jetty-client', version: '9.1.0.v20131115'
testImplementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.1.0.v20131115'
constraints {
testImplementation('org.eclipse.jetty:jetty-server') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '9.1.0.v20131115'
}
}
testImplementation('org.eclipse.jetty:jetty-servlet') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '9.1.0.v20131115'
}
}
}

latestDepTestImplementation group: 'org.eclipse.jetty', name: 'jetty-client', version: '9.+'
latestDepTestImplementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ dependencies {
implementation project(":dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0")
compileOnly group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.0.4.v20130625'

// Don't want to conflict with jetty from the test server.
testImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-util-9.4.31')

testImplementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.0.4.v20130625'
Expand All @@ -30,6 +26,22 @@ dependencies {
testImplementation testFixtures(project(":dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0"))
testImplementation testFixtures(project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-3.0'))

constraints {
// Don't want to conflict with jetty from the test server.
testImplementation('org.eclipse.jetty:jetty-server') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '9.0.4.v20130625'
}
}
testImplementation('org.eclipse.jetty:jetty-servlet') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '9.0.4.v20130625'
}
}
}

// Include all jetty-server instrumentation modules for testing. Only the version-compatible module will apply at runtime.
testRuntimeOnly project(":dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0")
testRuntimeOnly project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-2.2')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ dependencies {
testFixturesImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}
// Don't want to conflict with jetty from the test server.
testImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}

testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-util-9.4.31')

String jetty9Version = '9.0.0.v20130308'
Expand All @@ -46,4 +43,20 @@ dependencies {
testImplementation testFixtures(project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-3.0'))
testFixturesImplementation testFixtures(project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-3.0'))
testImplementation project(':dd-java-agent:appsec:appsec-test-fixtures')

constraints {
// Don't want to conflict with jetty from the test server.
testImplementation('org.eclipse.jetty:jetty-server') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly jetty9Version
}
}
testImplementation('org.eclipse.jetty:jetty-servlet') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly jetty9Version
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ dependencies {
}
testFixturesCompileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'

testImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-7.0') // See if there's any conflicts.
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-7.6') // See if there's any conflicts.
testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0') // See if there's any conflicts.
Expand All @@ -63,6 +60,21 @@ dependencies {
testImplementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.0.41'
testImplementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '8.0.41'

constraints {
testImplementation('org.eclipse.jetty:jetty-server') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '8.2.0.v20160908'
}
}
testImplementation('org.eclipse.jetty:jetty-servlet') {
because(":dd-java-agent:testing comes with a newer version that may cause conflicts")
version {
strictly '8.2.0.v20160908'
}
}
}

// Jetty 10 seems to refuse to run on java8.
// TODO: we need to setup separate test for Jetty 10 when that is released.
latestDepTestImplementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.+'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ dependencies {
// servlet request instrumentation required for linking request to response.
testImplementation project(':dd-java-agent:instrumentation:servlet:javax-servlet:javax-servlet-2.2')

// Don't want to conflict with jetty from the test server.
testImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}

testImplementation project(':dd-java-agent:instrumentation:jetty:jetty-util-9.4.31')
}

configurations.named('testImplementation') {
// Don't want to conflict with jetty from the test server.
// because :dd-java-agent:testing brings its own version of jetty-server
exclude(group: 'org.eclipse.jetty')
}

10 changes: 6 additions & 4 deletions dd-java-agent/instrumentation/tomcat/tomcat-5.5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ dependencies {

implementation project(':dd-java-agent:instrumentation:tomcat:tomcat-common')

testImplementation(project(':dd-java-agent:instrumentation-testing')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}

// Required jars for embedded tomcat:
testImplementation group: 'tomcat', name: 'catalina', version: tomcatVersion
testImplementation group: 'tomcat', name: 'tomcat-coyote', version: tomcatVersion
Expand Down Expand Up @@ -147,6 +143,12 @@ tasks.withType(Test).configureEach {
)
}

configurations.named('testImplementation') {
// Don't want to conflict with jetty from the test server.
// because :dd-java-agent:testing brings its own version of jetty-server
exclude(group: 'org.eclipse.jetty')
}

// Exclude all the dependencies from test for latestDepTest since the names are completely different.
["latestDepTestImplementation", "tomcat9TestImplementation", "latest10TestImplementation"].each {
configurations.named(it) {
Expand Down