Browse Source

Merge pull request #53 from kriegaex/remove-asm-renamed

Remove ASM-renamed, replace by dynamic relocation via Maven Shade
tags/V1_9_7_M2
Andy Clement 3 years ago
parent
commit
d2d5533f8f
No account linked to committer's email address

+ 2
- 2
ajde.core/pom.xml View File

@@ -42,8 +42,8 @@
<artifactId>org.eclipse.jdt.core</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>

+ 2
- 2
ajde/pom.xml View File

@@ -33,8 +33,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>

+ 2
- 2
ajdoc/pom.xml View File

@@ -55,8 +55,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>

+ 0
- 184
asm-renamed/pom.xml View File

@@ -1,184 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<!-- The AspectJ root POM is the parent, but this module is not a submodule -->
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
<version>1.9.7.BUILD-SNAPSHOT</version>
</parent>

<artifactId>asm-renamed</artifactId>
<version>${asm.version}</version>

<name>ASM for AspectJ</name>
<description>
This module relocates the original ASM artifact from package name 'org.objectweb.asm' to 'aj.org.objectweb.asm',
using Maven Shade Plugin.

In order to avoid committing the binary to the AspectJ SCM repository and using it as a system-scoped dependency, we
deploy it to aspectj.dev.

Whenever it is necessary to upgrade to a new ASM version in order to make AspectJ compatible with a new Java
version, please build and deploy this module after upgrading property 'asm.version'. Make sure you have the
credentials for write access to the aspectj.dev Maven repository WebDAV share and the correct server, profile and
property entries in settings.xml.

Then you should be able to run 'mvn clean deploy' for this module and be fine.

Caveat for IntelliJ IDEA: The project cannot be built in IDEA (Ctrl-F9) if this module is visible in the Maven view.
If so, right-click it and select "Unlink Maven Projects". Unfortunately, "Ignore Projects" is not enough. If Maven
knows of this Maven module, it cannot compile other modules depending on shaded class names, because it cannot find
the binaries. IDEA will just stop looking at the local Maven repository in this case.
</description>

<properties>
<!-- By default, do not deploy artifacts - but deploy this one used by the main build -->
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<!-- Nothing to compile in this module -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<!-- Re-create original source JAR in order to avoid re-shading already shaded JAR in non-clean builds -->
<forceCreation>true</forceCreation>
<!--
Avoid attaching the source JAR here, because Maven Shade will add the source uber JAR later. Because both
JARs have the same final name, Maven Install/Deploy would see two artifacts attached to the build, which
would lead to double deployment and hence to an error "Transfer failed for ...-sources.jar 409 Conflict".
See also https://issues.apache.org/jira/browse/MDEPLOY-254 and comments by Alexander Kriegisch.
-->
<attach>false</attach>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<!-- Re-create original JAR in order to avoid re-shading already shaded JAR in non-clean builds -->
<forceCreation>true</forceCreation>
</configuration>
<executions>
<execution>
<!-- Avoid creating test JAR -->
<id>test-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createSourcesJar>true</createSourcesJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>false</shadedArtifactAttached>
</configuration>
<executions>
<execution>
<id>asm-relocate</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<shadeSourcesContent>true</shadeSourcesContent>
<artifactSet>
<excludes>
<exclude>${project.groupId}</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*</artifact>
<excludes>
<exclude>META-INF/*</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>aj.org.objectweb.asm</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<!-- Remove shaded dependencies from uber JAR -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
<configuration>
<flattenMode>defaults</flattenMode>
<pomElements>
<dependencies>remove</dependencies>
</pomElements>
<outputDirectory>${project.build.directory}</outputDirectory>
<flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
</dependencies>

</project>

+ 1
- 1
aspectjtools/aspectjtools-assembly.xml View File

@@ -17,7 +17,7 @@
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.aspectj:org.eclipse.jdt.core</include>
<include>org.aspectj:asm-renamed</include>
<include>org.ow2.asm:asm</include>
</includes>
</dependencySet>
</dependencySets>

+ 47
- 3
aspectjtools/pom.xml View File

@@ -50,7 +50,8 @@
<configuration>
<classifier>sources</classifier>
<!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>-->
<includeArtifactIds>org.eclipse.jdt.core,asm-renamed</includeArtifactIds>
<includeGroupIds>org.aspectj,org.ow2.asm</includeGroupIds>
<includeArtifactIds>org.eclipse.jdt.core,asm</includeArtifactIds>
<outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory>
<!-- Avoid accidentally shading test-scoped dependencies like JUnit -->
<includeScope>runtime</includeScope>
@@ -140,6 +141,49 @@
</executions>
</plugin>

<!--
Relocate ASM from 'org.objectweb.asm' to 'aj.org.objectweb.asm'

TODO: Using Maven Shade after Maven Assembly instead of creating uber JAR and relocating package names at the
same time is suboptimal and maybe slower than doing both at the same time. Migrating from Assembly to Shade
requires all dependencies to produce source JARs, though, which currently is not the case. Because we also
want to create a complete source JAR, for now we keep Assembly around, because it manually copies project
sources from their respective directories before zipping them up.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createSourcesJar>true</createSourcesJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>false</shadedArtifactAttached>
</configuration>
<executions>
<execution>
<id>asm-relocate</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<shadeSourcesContent>true</shadeSourcesContent>
<artifactSet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>aj.org.objectweb.asm</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>

<!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -179,8 +223,8 @@
<artifactId>org.eclipse.jdt.core</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
</dependencies>


+ 1
- 1
aspectjweaver/aspectjweaver-assembly.xml View File

@@ -16,7 +16,7 @@
<!-- Avoid warning when trying to add non-existing main artifact JAR -->
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.aspectj:asm-renamed</include>
<include>org.ow2.asm:asm</include>
</includes>
</dependencySet>
</dependencySets>

+ 47
- 3
aspectjweaver/pom.xml View File

@@ -50,7 +50,8 @@
<configuration>
<classifier>sources</classifier>
<!--<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>-->
<includeArtifactIds>asm-renamed</includeArtifactIds>
<includeGroupIds>org.ow2.asm</includeGroupIds>
<includeArtifactIds>asm</includeArtifactIds>
<outputDirectory>${project.build.directory}/unzipped-sources</outputDirectory>
<!-- Avoid accidentally shading test-scoped dependencies like JUnit -->
<includeScope>runtime</includeScope>
@@ -143,6 +144,49 @@
</executions>
</plugin>

<!--
Relocate ASM from 'org.objectweb.asm' to 'aj.org.objectweb.asm'

TODO: Using Maven Shade after Maven Assembly instead of creating uber JAR and relocating package names at the
same time is suboptimal and maybe slower than doing both at the same time. Migrating from Assembly to Shade
requires all dependencies to produce source JARs, though, which currently is not the case. Because we also
want to create a complete source JAR, for now we keep Assembly around, because it manually copies project
sources from their respective directories before zipping them up.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createSourcesJar>true</createSourcesJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>false</shadedArtifactAttached>
</configuration>
<executions>
<execution>
<id>asm-relocate</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<shadeSourcesContent>true</shadeSourcesContent>
<artifactSet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>aj.org.objectweb.asm</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>

<!-- Caveat: Attaching the flattened POM needs packaging=jar, so do not use packaging=pom for this module -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -178,8 +222,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
</dependencies>


+ 2
- 2
loadtime/pom.xml View File

@@ -38,8 +38,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>

+ 2
- 2
org.aspectj.ajdt.core/pom.xml View File

@@ -64,8 +64,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
</dependencies>


+ 4
- 4
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java View File

@@ -63,12 +63,12 @@ public abstract class AjcTestCase extends TestCase {
*/
protected Ajc ajc;

public static final String CLASSPATH_ASM_RENAMED =
public static final String CLASSPATH_ASM =
Arrays.stream(System.getProperty("java.class.path")
.split(File.pathSeparator))
.filter(path -> path.contains("asm-renamed"))
.filter(path -> path.replace('\\', '/').contains("org/ow2/asm/"))
.findFirst()
.orElseThrow(() -> new RuntimeException("library 'asm-renamed' not found on classpath"));
.orElseThrow(() -> new RuntimeException("ASM library not found on classpath"));

// see Ajc and AntSpec
public static final String DEFAULT_CLASSPATH_ENTRIES =
@@ -76,7 +76,7 @@ public abstract class AjcTestCase extends TestCase {
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "junit" + File.separator + "junit.jar"
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel.jar"
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "bcel" + File.separator + "bcel-verifier.jar"
+ File.pathSeparator + CLASSPATH_ASM_RENAMED
+ File.pathSeparator + CLASSPATH_ASM
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "testing-client.jar"
// hmmm, this next one should perhaps point to an aj-build jar...
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar"

+ 0
- 5
pom.xml View File

@@ -148,11 +148,6 @@
<module>run-all-junit-tests</module>
<module>docs</module>

<!-- FYI: These are NOT meant to be sub-modules but a stand-alone projects built and deployed independently. -->
<!--
<module>asm-renamed</module>
-->

<!-- create the important artifacts we care about -->
<module>aspectjrt</module>
<module>aspectjweaver</module>

+ 3
- 3
run-all-junit-tests/pom.xml View File

@@ -157,8 +157,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -245,7 +245,7 @@
<usedDependencies>
<!-- The tests need these during runtime, even though no direct usage is in our classes -->
<usedDependency>ant:ant-launcher</usedDependency>
<usedDependency>org.aspectj:asm-renamed</usedDependency>
<usedDependency>org.ow2.asm:asm</usedDependency>
<usedDependency>org.aspectj:ajde</usedDependency>
<usedDependency>org.aspectj:build</usedDependency>
<usedDependency>org.aspectj:tests</usedDependency>

+ 2
- 2
taskdefs/pom.xml View File

@@ -39,8 +39,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<!-- Identical to lib/ant/lib/ant.jar, a former system-scoped dependency -->

+ 2
- 2
testing-drivers/pom.xml View File

@@ -35,8 +35,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
</dependencies>


+ 2
- 2
testing/pom.xml View File

@@ -49,8 +49,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>

+ 4
- 4
tests/java5/ataspectj/ataspectj/UnweavableTest.java View File

@@ -22,10 +22,10 @@ import java.io.Serializable;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import aj.org.objectweb.asm.ClassWriter;
import aj.org.objectweb.asm.Opcodes;
import aj.org.objectweb.asm.MethodVisitor;
import aj.org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.AnnotationVisitor;

/**
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>

+ 2
- 2
tests/pom.xml View File

@@ -40,8 +40,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>

+ 2
- 2
weaver/pom.xml View File

@@ -62,8 +62,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>asm-renamed</artifactId>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
</dependencies>
</project>

+ 5
- 1
weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java View File

@@ -754,7 +754,11 @@ public final class LazyClassGen {
// are required (unless turning off the verifier)
if ((myGen.getMajor() == Constants.MAJOR_1_6 && world.shouldGenerateStackMaps()) || myGen.getMajor() > Constants.MAJOR_1_6) {
if (!AsmDetector.isAsmAround) {
throw new BCException("Unable to find Asm for stackmap generation (Looking for 'aj.org.objectweb.asm.ClassReader'). Stackmap generation for woven code is required to avoid verify errors on a Java 1.7 or higher runtime");
throw new BCException(
"Unable to find ASM classes (" + AsmDetector.CLASS_READER + ", " + AsmDetector.CLASS_VISITOR + ") " +
"for stackmap generation. Stackmap generation for woven code is required to avoid verify errors " +
"on a Java 1.7 or higher runtime."
);
}
wovenClassFileData = StackMapAdder.addStackMaps(world, wovenClassFileData);
}

+ 8
- 9
weaver/src/main/java/org/aspectj/weaver/bcel/asm/AsmDetector.java View File

@@ -11,26 +11,25 @@
* ******************************************************************/
package org.aspectj.weaver.bcel.asm;

import java.lang.reflect.Method;

/**
* Determines if a version of asm is around that will enable us to add stack map attributes to classes that we produce.
*
*
* @author Andy Clement
*/
public class AsmDetector {

public static final String CLASS_READER = "org.objectweb.asm.ClassReader";
public static final String CLASS_VISITOR = "org.objectweb.asm.ClassVisitor";
public static boolean isAsmAround;

static {
try {
Class<?> reader = Class.forName("aj.org.objectweb.asm.ClassReader");
Class<?> visitor = Class.forName("aj.org.objectweb.asm.ClassVisitor");
Method m = reader.getMethod("accept", new Class[] { visitor, Integer.TYPE });
isAsmAround = m != null;
Class<?> reader = Class.forName(CLASS_READER);
Class<?> visitor = Class.forName(CLASS_VISITOR);
reader.getMethod("accept", visitor, Integer.TYPE);
isAsmAround = true;
} catch (Exception e) {
isAsmAround = false;
}
// System.out.println(isAsmAround?"ASM detected":"No ASM found");
//System.out.println(isAsmAround ? "ASM detected" : "No ASM found");
}
}

+ 5
- 5
weaver/src/main/java/org/aspectj/weaver/bcel/asm/StackMapAdder.java View File

@@ -15,11 +15,11 @@ import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.World;

import aj.org.objectweb.asm.ClassReader;
import aj.org.objectweb.asm.ClassVisitor;
import aj.org.objectweb.asm.ClassWriter;
import aj.org.objectweb.asm.MethodVisitor;
import aj.org.objectweb.asm.Opcodes;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

/**
* Uses asm to add the stack map attribute to methods in a class. The class is passed in as pure byte data and then a reader/writer

Loading…
Cancel
Save