changeset 2437:708035ffd62e

Include deps of byteman-helper with relocated classes. Including jffi in the jar *with* relocation of the class namespace is not easily possible since it contains native libs which would have to be renamed too and natives recompiled. Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-August/020685.html
author Severin Gehwolf <sgehwolf@redhat.com>
date Mon, 06 Jun 2016 17:11:07 +0200
parents 7fedcccddf46
children 2896940c9722
files .hgignore pom.xml vm-byteman/byteman-helper-distro/pom.xml vm-byteman/byteman-helper/pom.xml vm-byteman/byteman-helper/src/main/resources/META-INF/services/org.jboss.byteman.thermostat.helper.agent.ipc.client.internal.ClientTransportProvider vm-byteman/byteman-helper/src/main/resources/META-INF/services/org.jboss.byteman.thermostat.helper.agent.ipc.common.internal.IPCPropertiesProvider
diffstat 6 files changed, 131 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Aug 30 11:19:17 2016 -0400
+++ b/.hgignore	Mon Jun 06 17:11:07 2016 +0200
@@ -5,6 +5,7 @@
 # vm-profiler's shade plugin seems to generate this
 # pom. As it's derivable, hgignore it :)
 vm-profiler/jvm-agent/dependency-reduced-pom.xml
+vm-byteman/byteman-helper/dependency-reduced-pom.xml
 
 # Keyring autogenerated files
 keyring/Makefile.in
--- a/pom.xml	Tue Aug 30 11:19:17 2016 -0400
+++ b/pom.xml	Mon Jun 06 17:11:07 2016 +0200
@@ -399,7 +399,7 @@
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-shade-plugin</artifactId>
-          <version>2.1</version>
+          <version>2.4.3</version>
         </plugin>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
--- a/vm-byteman/byteman-helper-distro/pom.xml	Tue Aug 30 11:19:17 2016 -0400
+++ b/vm-byteman/byteman-helper-distro/pom.xml	Mon Jun 06 17:11:07 2016 +0200
@@ -56,6 +56,7 @@
       <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-vm-byteman-helper</artifactId>
       <version>${project.version}</version>
+      <classifier>shaded</classifier>
     </dependency>
     <!--
         Dependency merely for byteman.jar copying to the right place
@@ -82,6 +83,10 @@
             </goals>
             <configuration>
               <outputDirectory>${thermostat.plugin.libs.dir}/thermostat-helper</outputDirectory>
+              <excludeTransitive>true</excludeTransitive>
+              <!-- Exclude byteman.jar and tools jar from the helper. Not needed
+                   at runtime -->
+              <excludeArtifactIds>byteman,tools</excludeArtifactIds>
             </configuration>
           </execution>
           <!-- Copy the byteman jar to directory
--- a/vm-byteman/byteman-helper/pom.xml	Tue Aug 30 11:19:17 2016 -0400
+++ b/vm-byteman/byteman-helper/pom.xml	Mon Jun 06 17:11:07 2016 +0200
@@ -57,6 +57,127 @@
           <target>1.6</target>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <configuration>
+          <shadedArtifactAttached>true</shadedArtifactAttached>
+          <artifactSet>
+            <includes>
+              <include>com.redhat.thermostat:thermostat-agent-ipc-client</include>
+              <include>com.redhat.thermostat:thermostat-agent-ipc-common</include>
+              <include>com.redhat.thermostat:thermostat-agent-ipc-unixsocket-client</include>
+              <include>com.redhat.thermostat:thermostat-agent-ipc-unixsocket-common</include>
+              <include>com.github.jnr:jnr-ffi</include>
+              <include>com.github.jnr:jnr-enxio</include>
+              <include>com.github.jnr:jnr-constants</include>
+              <include>com.github.jnr:jnr-posix</include>
+              <include>com.github.jnr:jnr-unixsocket</include>
+              <include>com.github.jnr:jnr-x86asm</include>
+              <include>com.github.jnr:jffi</include>
+              <include>com.github.jnr:jffi:*:native</include>
+              <!-- deps of jnr-ffi -->
+              <include>org.ow2.asm:asm</include>
+              <include>org.ow2.asm:asm-util</include>
+              <include>org.ow2.asm:asm-tree</include>
+              <include>org.ow2.asm:asm-analysis</include>
+              <include>org.ow2.asm:asm-commons</include>
+            </includes>
+          </artifactSet>
+          <relocations>
+            <relocation>
+              <pattern>org.objectweb.asm</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.objectweb.asm</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>com.redhat.thermostat.agent.ipc.client</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.agent.ipc.client</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>com.redhat.thermostat.agent.ipc.common</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.agent.ipc.common</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>com.redhat.thermostat.agent.ipc.unixsocket.client</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.agent.ipc.unixsocket.client</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>com.redhat.thermostat.agent.ipc.unixsocket.common</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.agent.ipc.unixsocket.common</shadedPattern>
+            </relocation>
+            <!-- jnr-ffi -->
+            <relocation>
+              <pattern>jnr.ffi</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.jnr.ffi</shadedPattern>
+            </relocation>
+            <!-- jnr-unixsocket -->
+            <relocation>
+              <pattern>jnr.unixsocket</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.jnr.unixsocket</shadedPattern>
+            </relocation>
+            <!-- FIXME:
+                 jffi cannot be relocated easily since it contains JNI functions for
+                 com.kenai.jffi.Foreign. Thus it can only be done if natives get renamed accordingly and
+                 subsequently recompiled too. -->
+            <!--
+            <relocation>
+              <pattern>com.kenai.jffi</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.com.kenai.jffi</shadedPattern>
+            </relocation>
+            -->
+            <!-- jnr-x86asm -->
+            <relocation>
+              <pattern>com.kenai.jnr.x86asm</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.com.kenai.jnr.x86asm</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>jnr.x86asm</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.jnr.x86asm</shadedPattern>
+            </relocation>
+            <!-- jnr-constants -->
+            <relocation>
+              <pattern>com.kenai.constantine</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.com.kenai.constantine</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>jnr.constants</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.jnr.constants</shadedPattern>
+            </relocation>
+            <!-- jnr-enxio -->
+            <relocation>
+              <pattern>jnr.enxio</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.jnr.enxio</shadedPattern>
+            </relocation>
+            <!-- jnr-posix -->
+            <relocation>
+              <pattern>jnr.posix</pattern>
+              <shadedPattern>org.jboss.byteman.thermostat.helper.jnr.posix</shadedPattern>
+            </relocation>
+          </relocations>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <!-- We need to shade deps as this would otherwise result in undesired behaviour in
+                 target JVMs which get the helper jar added to classpath/boot classpath. -->
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <!-- Skip inclusion of untransformed META-INF/services files. We use our own, relocated,
+                   versions included as resources. -->
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
+                  <resources>
+                    <resource>com.redhat.thermostat.agent.ipc.client.internal.ClientTransportProvider</resource>
+                    <resource>com.redhat.thermostat.agent.ipc.common.internal.IPCPropertiesProvider</resource>
+                  </resources>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   <dependencies>
@@ -92,6 +213,7 @@
       <groupId>org.jboss.byteman</groupId>
       <artifactId>byteman</artifactId>
       <version>${byteman.version}</version>
+      <scope>provided</scope>
     </dependency>
   </dependencies>
 </project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vm-byteman/byteman-helper/src/main/resources/META-INF/services/org.jboss.byteman.thermostat.helper.agent.ipc.client.internal.ClientTransportProvider	Mon Jun 06 17:11:07 2016 +0200
@@ -0,0 +1,1 @@
+org.jboss.byteman.thermostat.helper.agent.ipc.unixsocket.client.internal.UnixSocketTransportProvider
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vm-byteman/byteman-helper/src/main/resources/META-INF/services/org.jboss.byteman.thermostat.helper.agent.ipc.common.internal.IPCPropertiesProvider	Mon Jun 06 17:11:07 2016 +0200
@@ -0,0 +1,1 @@
+org.jboss.byteman.thermostat.helper.agent.ipc.unixsocket.common.internal.UnixSocketIPCPropertiesProvider