Skip to content

New shading #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 5, 2017
1 change: 1 addition & 0 deletions dd-java-agent-ittests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.6.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testCompile group: 'ch.qos.logback', name: 'logback-classic' , version: '1.2.3'
testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.4.1.v20170120'
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.4.1.v20170120'
Expand Down
57 changes: 18 additions & 39 deletions dd-java-agent-ittests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
<name>dd-java-agent-ittests</name>
<description>Datadog Java Agent integration tests</description>
<url>https://github.com/datadog/dd-trace-java</url>

<packaging>jar</packaging>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<dd-trace.version>0.1.2-SNAPSHOT</dd-trace.version>
<!--Skip tests-->
<skipTests>true</skipTests>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much nicer. 👍

</properties>

<dependencies>
Expand All @@ -27,8 +29,22 @@
<version>${dd-trace.version}</version>
<scope>test</scope>
</dependency>
<!-- Required for the tracer resolver / annotation -->
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc3</version>
<scope>compile</scope>
</dependency>


<!-- JUnit tests -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-mock</artifactId>
Expand Down Expand Up @@ -194,37 +210,16 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<includes>
<!--<include>*Test.java</include>-->
</includes>
<excludes>
<exclude>*Test.java</exclude>
</excludes>
<!--<forkCount>3</forkCount>-->
<!--<reuseForks>false</reuseForks>-->
<argLine>
-javaagent:${M2_REPO}/com/datadoghq/dd-java-agent/${project.version}/dd-java-agent-${project.version}.jar
-Dorg.jboss.byteman.verbose=true
</argLine>
<!--<workingDirectory>target/FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory>-->
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
Expand All @@ -238,26 +233,10 @@
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<!-- <exclude>ch.qos.logback:*</exclude> -->
<!-- <exclude>org.slf4j:*</exclude> -->
</excludes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>otarules.btm</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Agent-Class>com.datadoghq.trace.agent.AnnotationsTracingAgent</Agent-Class>
<Premain-Class>com.datadoghq.trace.agent.AnnotationsTracingAgent
</Premain-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
<Boot-Class-Path>./${project.artifactId}.jar</Boot-Class-Path>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent-ittests/src/test/resources/dd-trace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sampler:
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}

# Enable custom annotation tracing over a selected set of packages
enableCustomAnnotationTracingOver: ["io.opentracing.contrib.agent"]
enableCustomAnnotationTracingOver: ["com.datadoghq.trace.agent"]

# Disable some instrumentations
# disabledInstrumentations: ["apache http", "mongo", "jetty", "tomcat", ...]
2 changes: 2 additions & 0 deletions dd-java-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {

compile group: 'io.opentracing.contrib', name: 'opentracing-agent', version: '0.1.0'
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
compile group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc3'


compile(group: 'io.opentracing.contrib', name: 'opentracing-web-servlet-filter', version: '0.0.9') {
Expand Down Expand Up @@ -45,6 +46,7 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.6.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testCompile group: 'ch.qos.logback', name: 'logback-classic' , version: '1.2.3'
compileOnly group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.3.6.v20151106'
compileOnly group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.0.M1'
compileOnly group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
Expand Down
50 changes: 46 additions & 4 deletions dd-java-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@
<version>${ot.agent.version}</version>
</dependency>


<!-- Used to find annotated methods -->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc3</version>
</dependency>

<!-- Server side instrumentation -->
<dependency>
Expand Down Expand Up @@ -236,7 +240,13 @@
</dependency>


<!-- JUnit tests -->
<!-- Tests -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-mock</artifactId>
Expand Down Expand Up @@ -287,15 +297,47 @@
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<!-- If not, the shade plugin doesn't work -->
<exclude>io.opentracing.contrib:opentracing-agent</exclude>
<exclude>org.jboss.byteman:byteman</exclude>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... so these artifacts were breaking for me too for gradle's shadow jar. I don't think it's safe to just exclude them like this though.

</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>javassist</pattern>
<shadedPattern>shaded.javassist</shadedPattern>
</relocation>
<relocation>
<pattern>org.reflections</pattern>
<shadedPattern>shaded.org.reflections</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>shaded.com.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>shaded.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>org.yaml</pattern>
<shadedPattern>shaded.org.yaml</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>shaded.org.slf4j</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>otarules.btm</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Agent-Class>com.datadoghq.trace.agent.AnnotationsTracingAgent</Agent-Class>
<Premain-Class>com.datadoghq.trace.agent.AnnotationsTracingAgent
</Premain-Class>
<Premain-Class>com.datadoghq.trace.agent.AnnotationsTracingAgent</Premain-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
<Boot-Class-Path>./${project.artifactId}.jar</Boot-Class-Path>
Expand Down
11 changes: 0 additions & 11 deletions dd-trace-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,4 @@
<name>dd-trace-annotations</name>
<url>https://github.com/datadog/dd-trace-java</url>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
1 change: 1 addition & 0 deletions dd-trace/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.6.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testCompile group: 'ch.qos.logback', name: 'logback-classic' , version: '1.2.3'
}

shadowJar {
Expand Down
34 changes: 14 additions & 20 deletions dd-trace/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<!-- Required for the tracer resolver / annotation -->
<dependency>
Expand All @@ -70,6 +65,12 @@
</dependency>

<!-- Testing dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -108,7 +109,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -119,28 +120,21 @@
<relocations>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>dd.com.fasterxml</shadedPattern>
<shadedPattern>shaded.com.fasterxml</shadedPattern>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this changed. I think it would be much better to use a custom prefix, not shaded, otherwise we'll have the same conflict problem with anyone else using the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tylerbenson I changed dd to shaded because I think I more explicit. There is no reason otherwise.

</relocation>
<!--<relocation>-->
<!--<pattern>com.google</pattern>-->
<!--<shadedPattern>dd.com.google</shadedPattern>-->
<!--</relocation>-->
<relocation>
<pattern>org.yaml</pattern>
<shadedPattern>dd.org.yaml</shadedPattern>
<pattern>com.google</pattern>
<shadedPattern>shaded.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>dd.org.slf4j</shadedPattern>
<pattern>org.yaml</pattern>
<shadedPattern>shaded.org.yaml</shadedPattern>
</relocation>
<relocation>
<pattern>ch.qos</pattern>
<shadedPattern>dd.ch.qos</shadedPattern>
<pattern>org.slf4j</pattern>
<shadedPattern>shaded.org.slf4j</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
</transformers>
</configuration>
</execution>
</executions>
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<url>https://github.com/datadog/dd-trace-java</url>
<connection>scm:git:git://github.com/datadog/dd-trace-java.git</connection>
<developerConnection>scm:git:[email protected]:datadog/dd-trace-java.git</developerConnection>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>

<modules>
<module>dd-trace</module>
Expand All @@ -47,6 +47,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
<opentracing.version>0.30.0</opentracing.version>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<distributionManagement>
Expand Down