You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by dk...@apache.org on 2019/10/31 14:51:56 UTC
[ws-axiom] 04/11: Merge r1797614 (with changes) to the 1.2 branch.
This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch 1.2.x
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
commit 87dd7a4c360ee8377afdfed6f9842499743c5e39
Author: Andreas Veithen <ve...@apache.org>
AuthorDate: Sun Mar 31 18:32:30 2019 +0000
Merge r1797614 (with changes) to the 1.2 branch.
---
apidocs/pom.xml | 4 +-
aspects/pom.xml | 12 ++++
axiom-compat/pom.xml | 4 +-
.../pom.xml | 12 ++--
.../buildutils/classes/AspectJCodeRemover.java | 39 ++++++++++
.../axiom/buildutils/classes/PostProcessMojo.java | 82 ++++++++++++++++++++++
.../axiom/buildutils/javadoc/PostProcessMojo.java | 2 +-
buildutils/pom.xml | 34 ++++++++-
testing/xml-truth/pom.xml | 4 +-
9 files changed, 179 insertions(+), 14 deletions(-)
diff --git a/apidocs/pom.xml b/apidocs/pom.xml
index a681fcd..8fa1a4b 100644
--- a/apidocs/pom.xml
+++ b/apidocs/pom.xml
@@ -115,13 +115,13 @@
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
- <artifactId>javadoc-postprocessor-plugin</artifactId>
+ <artifactId>buildutils-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<phase>site</phase>
<goals>
- <goal>post-process</goal>
+ <goal>post-process-javadoc</goal>
</goals>
<configuration>
<javadocDirectory>${project.reporting.outputDirectory}</javadocDirectory>
diff --git a/aspects/pom.xml b/aspects/pom.xml
index fef42ba..511746b 100644
--- a/aspects/pom.xml
+++ b/aspects/pom.xml
@@ -107,6 +107,18 @@
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>buildutils-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>post-process-classes</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/axiom-compat/pom.xml b/axiom-compat/pom.xml
index d5345bb..596f201 100644
--- a/axiom-compat/pom.xml
+++ b/axiom-compat/pom.xml
@@ -103,13 +103,13 @@
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
- <artifactId>javadoc-postprocessor-plugin</artifactId>
+ <artifactId>buildutils-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<phase>site</phase>
<goals>
- <goal>post-process</goal>
+ <goal>post-process-javadoc</goal>
</goals>
<configuration>
<javadocDirectory>${project.reporting.outputDirectory}/apidocs</javadocDirectory>
diff --git a/buildutils/javadoc-postprocessor-plugin/pom.xml b/buildutils/buildutils-maven-plugin/pom.xml
similarity index 92%
rename from buildutils/javadoc-postprocessor-plugin/pom.xml
rename to buildutils/buildutils-maven-plugin/pom.xml
index d562f8d..ed298c3 100644
--- a/buildutils/javadoc-postprocessor-plugin/pom.xml
+++ b/buildutils/buildutils-maven-plugin/pom.xml
@@ -26,13 +26,12 @@
<version>1.2.23-SNAPSHOT</version>
</parent>
- <artifactId>javadoc-postprocessor-plugin</artifactId>
+ <artifactId>buildutils-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<url>http://ws.apache.org/axiom/</url>
<properties>
- <maven.version>3.0</maven.version>
<doxia.version>1.7</doxia.version>
</properties>
@@ -49,31 +48,32 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
- <version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-integration-tools</artifactId>
<version>${doxia.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>5.2</version>
+ </dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>3.3</version>
<executions>
<execution>
<!-- See MNG-5346 -->
diff --git a/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/classes/AspectJCodeRemover.java b/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/classes/AspectJCodeRemover.java
new file mode 100644
index 0000000..aaea9c3
--- /dev/null
+++ b/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/classes/AspectJCodeRemover.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.buildutils.classes;
+
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+final class AspectJCodeRemover extends ClassVisitor {
+ public AspectJCodeRemover(ClassVisitor cv) {
+ super(Opcodes.ASM5, cv);
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ if (access == (Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC)
+ && (name.equals("aspectOf") || name.equals("hasAspect"))) {
+ return null;
+ } else {
+ return super.visitMethod(access, name, desc, signature, exceptions);
+ }
+ }
+}
diff --git a/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/classes/PostProcessMojo.java b/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/classes/PostProcessMojo.java
new file mode 100644
index 0000000..5137257
--- /dev/null
+++ b/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/classes/PostProcessMojo.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.buildutils.classes;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+
+@Mojo(name="post-process-classes", defaultPhase=LifecyclePhase.PROCESS_CLASSES)
+public class PostProcessMojo extends AbstractMojo {
+ @Parameter(defaultValue="${project.build.outputDirectory}", required=true, readonly=true)
+ private File classesDir;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (!classesDir.exists()) {
+ return;
+ }
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(new String[] { "**/*.class" });
+ ds.setBasedir(classesDir);
+ ds.scan();
+ for (String relativePath : ds.getIncludedFiles()) {
+ File file = new File(classesDir, relativePath);
+ ClassWriter classWriter;
+ try {
+ InputStream in = new FileInputStream(file);
+ try {
+ ClassReader classReader = new ClassReader(in);
+ classWriter = new ClassWriter(classReader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
+ ClassVisitor classVisitor = classWriter;
+ classVisitor = new AspectJCodeRemover(classVisitor);
+ classReader.accept(classVisitor, 0);
+ } finally {
+ in.close();
+ }
+ } catch (IOException ex) {
+ throw new MojoExecutionException("Failed to read " + relativePath + ": " + ex.getMessage(), ex);
+ }
+ try {
+ OutputStream out = new FileOutputStream(file);
+ try {
+ out.write(classWriter.toByteArray());
+ } finally {
+ out.close();
+ }
+ } catch (IOException ex) {
+ throw new MojoExecutionException("Failed to write " + relativePath + ": " + ex.getMessage(), ex);
+ }
+ }
+ }
+}
diff --git a/buildutils/javadoc-postprocessor-plugin/src/main/java/org/apache/axiom/buildutils/javadoc/PostProcessMojo.java b/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/javadoc/PostProcessMojo.java
similarity index 99%
rename from buildutils/javadoc-postprocessor-plugin/src/main/java/org/apache/axiom/buildutils/javadoc/PostProcessMojo.java
rename to buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/javadoc/PostProcessMojo.java
index 7898503..c2894f6 100644
--- a/buildutils/javadoc-postprocessor-plugin/src/main/java/org/apache/axiom/buildutils/javadoc/PostProcessMojo.java
+++ b/buildutils/buildutils-maven-plugin/src/main/java/org/apache/axiom/buildutils/javadoc/PostProcessMojo.java
@@ -41,7 +41,7 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
-@Mojo(name="post-process")
+@Mojo(name="post-process-javadoc")
public class PostProcessMojo extends AbstractMojo {
@Component
private SiteTool siteTool;
diff --git a/buildutils/pom.xml b/buildutils/pom.xml
index 17a60a3..8b3f40a 100644
--- a/buildutils/pom.xml
+++ b/buildutils/pom.xml
@@ -33,14 +33,46 @@
<url>http://ws.apache.org/axiom/</url>
<modules>
+ <module>buildutils-maven-plugin</module>
<module>jar-resource-bundle</module>
<module>shade-axiom-xml</module>
<module>shade-osgi</module>
- <module>javadoc-postprocessor-plugin</module>
<module>no-package-cycles-enforcer-rule</module>
</modules>
+ <properties>
+ <maven.version>3.0</maven.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.2</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.3</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<!-- The build requires Java 1.6; therefore we can use that version for the build utils as well -->
<plugin>
diff --git a/testing/xml-truth/pom.xml b/testing/xml-truth/pom.xml
index 67a5fbd..9248933 100644
--- a/testing/xml-truth/pom.xml
+++ b/testing/xml-truth/pom.xml
@@ -57,13 +57,13 @@
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
- <artifactId>javadoc-postprocessor-plugin</artifactId>
+ <artifactId>buildutils-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<phase>site</phase>
<goals>
- <goal>post-process</goal>
+ <goal>post-process-javadoc</goal>
</goals>
<configuration>
<javadocDirectory>${project.reporting.outputDirectory}/apidocs</javadocDirectory>