Rename google and byteman dependencies
But exclude the ones that cause the tests to fail.
Also add a test to verify the correct version of guava is loaded with the agent running.
MODIFY
.gitignore
.gitignore
@@ -46,3 +46,4 @@ Thumbs.db
/logs/*
/bin
/out
+*/out

MODIFY
dd-java-agent-ittests/dd-java-agent-ittests.gradle
dd-java-agent-ittests/dd-java-agent-ittests.gradle
@@ -6,6 +6,7 @@ apply from: "${rootDir}/gradle/java.gradle"
description = 'dd-java-agent-ittests'
dependencies {
testCompile project(':dd-java-agent')
+
testCompile group: 'io.opentracing', name: 'opentracing-mock', version: '0.30.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.6.2'
@@ -32,6 +33,12 @@ dependencies {
testCompile group: 'org.apache.activemq', name: 'activemq-broker', version: '5.14.5'
}
+configurations.all {
+ resolutionStrategy {
+ force 'com.google.guava:guava:18.0' // Force to test package renaming in agent jar. (see ShadowPackageRenamingTest)
+ }
+}
+
test {
jvmArgs "-Ddd.trace.configurationFile=${project.buildDir}/resources/test/dd-trace.yaml"
jvmArgs "-javaagent:${project(':dd-java-agent').buildDir}/libs/dd-java-agent-${project.version}.jar"

ADD
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/agent/ShadowPackageRenamingTest.java
+package com.datadoghq.trace.agent;
+
+import com.google.common.collect.MapMaker;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ShadowPackageRenamingTest {
+
+ @Test
+ public void test() {
+ try {
+ (new MapMaker()).softValues(); // this method exists in 18.0 but was removed in 20.0
+ } catch (final NoSuchMethodError e) {
+ Assert.fail("wrong class was loaded");
+ }
+ }
+}

MODIFY
dd-java-agent/dd-java-agent.gradle
dd-java-agent/dd-java-agent.gradle
@@ -93,16 +93,22 @@ shadowJar {
// mergeServiceFiles()
- // Various tests fail when these are uncommented:
-// relocate 'com.google', 'dd.deps.com.google'
-// relocate 'org.jboss.byteman', 'dd.deps.org.jboss.byteman'
-
// Don't relocate slf4j or opentracing deps.
relocate 'com.fasterxml', 'dd.deps.com.fasterxml'
relocate 'javassist', 'dd.deps.javassist'
relocate 'org.reflections', 'dd.deps.org.reflections'
relocate 'org.yaml', 'dd.deps.org.yaml'
+ relocate('org.jboss.byteman', 'dd.deps.org.jboss.byteman') {
+ // Renaming these causes a verify error in the tests.
+ exclude 'org.jboss.byteman.rule.*'
+ exclude 'org.jboss.byteman.rule.helper.*'
+ }
+ relocate('com.google', 'dd.deps.com.google') {
+ // This is used in the Cassandra Cluster.connectAsync signature so we can't relocate it. :fingers_crossed:
+ exclude 'com.google.common.util.concurrent.ListenableFuture'
+ }
+
//Exclude Java 9 compiled classes:
exclude 'org/jboss/byteman/agent/JigsawAccessEnablerGenerator.class'
exclude 'org/jboss/byteman/agent/JigsawAccessManager$1.class'

Rename google and byteman dependencies

But exclude the ones that cause the tests to fail.
Also add a test to verify the correct version of guava is loaded with the agent running.