Skip to content

Commit 696dcbc

Browse files
committed
Remove repackaged ASM source files and use Maven Shade instead
Using the Maven Shade plugin to relocate the ASM classes in the final JAR makes it much easier to update to another version of ASM in the future and can also be used for other dependencies without importing their source into this repository.
1 parent 51bb868 commit 696dcbc

27 files changed

+40
-14843
lines changed

Readme.md

-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,3 @@ Connect to the JVM with any JMX client and use the `de.codecentric.Agent` MBean
4848

4949
## Where are the freaking tests?
5050
Glad that you asked. Please take a look at the source files and then come up with a sensible unit test. If you manage to do that feel free to put up a PR.
51-
52-
## Info on ASM
53-
This agent uses ASM (http://asm.ow2.org/) for bytecode manipulation. It contains a repackaged asm 5.0.3 implementation in the `de.codecentric.performance.asm` package. Besides the package move it is the original ASM code and all of their copyrights apply.
54-
It has been repackaged to avoid conflicts with possible other ASM versions on the classpath.

pom.xml

+33
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5+
<prerequisites>
6+
<maven>3.0.0</maven>
7+
</prerequisites>
8+
59
<groupId>de.codecentric.performance</groupId>
610
<artifactId>allocation-tracker-agent</artifactId>
711
<version>0.0.1-SNAPSHOT</version>
@@ -39,9 +43,38 @@
3943
<downloadJavadocs>true</downloadJavadocs>
4044
</configuration>
4145
</plugin>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-shade-plugin</artifactId>
49+
<version>2.3</version>
50+
<executions>
51+
<execution>
52+
<phase>package</phase>
53+
<goals>
54+
<goal>shade</goal>
55+
</goals>
56+
<configuration>
57+
<relocations>
58+
<relocation>
59+
<pattern>org.objectweb.asm</pattern>
60+
<shadedPattern>de.codecentric.performance.agent.asm.org.objectweb.asm</shadedPattern>
61+
</relocation>
62+
</relocations>
63+
</configuration>
64+
</execution>
65+
</executions>
66+
</plugin>
4267
</plugins>
4368
</build>
4469

70+
<dependencies>
71+
<dependency>
72+
<groupId>org.ow2.asm</groupId>
73+
<artifactId>asm</artifactId>
74+
<version>5.0.3</version>
75+
</dependency>
76+
</dependencies>
77+
4578
<profiles>
4679
<profile>
4780
<id>java-6</id>

src/main/java/de/codecentric/performance/agent/allocation/AllocationTrackerClassFileTransformer.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import java.lang.instrument.IllegalClassFormatException;
55
import java.security.ProtectionDomain;
66

7-
import de.codecentric.performance.agent.asm.org.objectweb.asm.ClassReader;
8-
import de.codecentric.performance.agent.asm.org.objectweb.asm.ClassVisitor;
9-
import de.codecentric.performance.agent.asm.org.objectweb.asm.ClassWriter;
10-
import de.codecentric.performance.agent.asm.org.objectweb.asm.MethodVisitor;
11-
import de.codecentric.performance.agent.asm.org.objectweb.asm.Opcodes;
7+
import org.objectweb.asm.ClassReader;
8+
import org.objectweb.asm.ClassVisitor;
9+
import org.objectweb.asm.ClassWriter;
10+
import org.objectweb.asm.MethodVisitor;
11+
import org.objectweb.asm.Opcodes;
1212

1313
/**
1414
* ClassFileTransformer implementation which will use ASM to visit the bytecode of constructors of classes matching the

src/main/java/de/codecentric/performance/agent/allocation/ConstructorVisitor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.codecentric.performance.agent.allocation;
22

3-
import de.codecentric.performance.agent.asm.org.objectweb.asm.MethodVisitor;
4-
import de.codecentric.performance.agent.asm.org.objectweb.asm.Opcodes;
3+
import org.objectweb.asm.MethodVisitor;
4+
import org.objectweb.asm.Opcodes;
55

66
/**
77
* Changes the bytecode of the visited constructor to call the static tracker. technically could be added to any method.

src/main/java/de/codecentric/performance/agent/asm/org/objectweb/asm/AnnotationVisitor.java

-169
This file was deleted.

0 commit comments

Comments
 (0)