我尝试将AspectJ与Maven一起用于Amazon SWF。我已经添加了插件来生成客户端代码和编织方面。我还添加了maven-compiler-plugin
来禁用注释处理。
当我运行mvn compile
时,我发现客户端代码是在target/generated-sources/annotation
中生成的。但它也会引发以下错误。我还在此处添加了pom.xml
文件。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building read-book 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- apt-maven-plugin:1.1.3:process (default) @ read-book ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ read-book ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ read-book ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 13 source files to /Users/cnadig-cc/read-book/target/classes
[INFO]
[INFO] --- aspectj-maven-plugin:1.4:compile (default) @ read-book ---
[WARNING] AsynchronyDeciderAnnotationProcessor.process() invoked.
[WARNING] Processing @Workflow for ReadBookWorkflow
[WARNING] AsynchronyDeciderAnnotationProcessor.process() invoked.
[WARNING] Processing finished
[ERROR] The type ReadBookWorkflowClient is already defined
[ERROR] The type ReadBookWorkflowClientImpl is already defined
[ERROR] The type ReadBookWorkflowClientFactory is already defined
[ERROR] The type ReadBookWorkflowClientFactoryImpl is already defined
[ERROR] The type ReadBookWorkflowClientExternal is already defined
[ERROR] The type ReadBookWorkflowClientExternalImpl is already defined
[ERROR] The type ReadBookWorkflowClientExternalFactory is already defined
[ERROR] The type ReadBookWorkflowClientExternalFactoryImpl is already defined
[ERROR] The type ReadBookWorkflowSelfClient is already defined
[ERROR] The type ReadBookWorkflowSelfClientImpl is already defined
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.475 s
[INFO] Finished at: 2015-09-15T17:22:00-07:00
[INFO] Final Memory: 27M/384M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project read-book: Compiler errors:
[ERROR] error at public interface ReadBookWorkflowClient extends WorkflowClient
[ERROR] ^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClient.java:21:0::0 The type ReadBookWorkflowClient is already defined
[ERROR] error at class ReadBookWorkflowClientImpl extends WorkflowClientBase implements ReadBookWorkflowClient {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientImpl.java:18:0::0 The type ReadBookWorkflowClientImpl is already defined
[ERROR] error at public interface ReadBookWorkflowClientFactory extends WorkflowClientFactory<ReadBookWorkflowClient> {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientFactory.java:18:0::0 The type ReadBookWorkflowClientFactory is already defined
[ERROR] error at public class ReadBookWorkflowClientFactoryImpl extends WorkflowClientFactoryBase<ReadBookWorkflowClient> implements ReadBookWorkflowClientFactory {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientFactoryImpl.java:17:0::0 The type ReadBookWorkflowClientFactoryImpl is already defined
[ERROR] error at public interface ReadBookWorkflowClientExternal extends WorkflowClientExternal
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientExternal.java:20:0::0 The type ReadBookWorkflowClientExternal is already defined
[ERROR] error at class ReadBookWorkflowClientExternalImpl extends WorkflowClientExternalBase implements ReadBookWorkflowClientExternal {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientExternalImpl.java:17:0::0 The type ReadBookWorkflowClientExternalImpl is already defined
[ERROR] error at public interface ReadBookWorkflowClientExternalFactory extends WorkflowClientFactoryExternal<ReadBookWorkflowClientExternal> {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientExternalFactory.java:18:0::0 The type ReadBookWorkflowClientExternalFactory is already defined
[ERROR] error at public class ReadBookWorkflowClientExternalFactoryImpl extends WorkflowClientFactoryExternalBase<ReadBookWorkflowClientExternal> implements ReadBookWorkflowClientExternalFactory {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowClientExternalFactoryImpl.java:18:0::0 The type ReadBookWorkflowClientExternalFactoryImpl is already defined
[ERROR] error at public interface ReadBookWorkflowSelfClient extends WorkflowSelfClient
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowSelfClient.java:19:0::0 The type ReadBookWorkflowSelfClient is already defined
[ERROR] error at public class ReadBookWorkflowSelfClientImpl extends WorkflowSelfClientBase implements ReadBookWorkflowSelfClient {
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] /Users/cnadig-cc/read-book/read/book/ReadBookWorkflowSelfClientImpl.java:18:0::0 The type ReadBookWorkflowSelfClientImpl is already defined
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException`enter code here`
的pom.xml
<?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>
<groupId>read-book</groupId>
<artifactId>read-book</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<aspectjrt.version>1.8.2</aspectjrt.version>
<aws.version>1.10.17</aws.version>
<freemarker.version>2.3.23</freemarker.version>
<aspectj-maven-plugin.version>1.4</aspectj-maven-plugin.version>
<aspectj-runtime.version>1.8.2</aspectj-runtime.version>
<compliance.level>1.8</compliance.level>
<target.dir>target</target.dir>
</properties>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectjrt.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-flow-build-tools</artifactId>
<version>1.10.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>${target.dir}/generated-sources/annotations</outputDirectory>
<processor>com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-swf-libraries</artifactId>
<version>1.9.18</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-flow-build-tools</artifactId>
<version>${aws.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
</plugin>
<!-- This disables annotation processing in the compiling phase -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
<source>${compliance.level}</source>
<target>${compliance.level}</target>
</configuration>
</plugin>
<!-- This does the actual weaving of aspects -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${aspectj-maven-plugin.version}</version>
<dependencies>
<!-- include this in order to keep aspectjrt consistent across all dependencies -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj-runtime.version}</version>
</dependency>
</dependencies>
<configuration>
<complianceLevel>${compliance.level}</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<source>${compliance.level}</source>
<target>${compliance.level}</target>
<aspectLibraries>
<!-- include this to ensure @Asynchronous and @ExponentialRetry annotations work -->
<aspectLibrary>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
</aspectLibrary>
</aspectLibraries>
<sources>
<source>
<basedir>${target.dir}/generated-sources/annotations</basedir>
</source>
<source>
<basedir>src/main/java</basedir>
</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:1)
使用swf构建工具jar的更高版本,如果您使用maven编译器插件并在类路径上使用构建工具jar,它会自动尝试生成客户端代码。 因此,您无需在Pom中专门定义任何注释处理。