我们有一个基于maven的多模块项目(确切地说是tycho),使用aspectj。
我们遇到一个奇怪的问题,如果我们单独构建每个模块,就不会出现问题。
当尝试将所有模块组合在一起时,我们会发生随机故障(不一定每次都在同一模块中),其中构建失败的情况通常是“无法确定缺失类型的修饰符......”。有时甚至,如果我们多次重复构建,我们甚至可能会幸运并且没有错误。
有人知道问题可能是什么吗?
我们使用的是aspectj-maven-plugin的1.8版本和aspectj的1.8.9
我们的项目结构如下:
parentpom.xml
---------> moduleA
---------> moduleAspect
---------> moduleB
---------> moduleC
ModuleA 位于 moduleAspect的 Inpath
moduleB 和 ModuleC 在 AspectPath moduleAspect
中这是 moduleAspect 中某个方面的示例。 (Class Incoming 在 moduleA 中定义)
public aspect SecurityAspect {
public interface Security {
String getRole();
}
declare parents: Incoming extends IncomingSecurity;
public String IncomingImpl.getRole() {
return getEditor();
};
pointcut privilegedAccess(Incoming inc):
//;
before(Incoming inc): privilegedAccess(inc){
//;
}
}
moduleAspect
中的 pom.xml<artifactId>moduleAspect</artifactId>
<parent>
<groupId>myproject</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>myproject</groupId>
<artifactId>moduleA</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<weaveDependencies>
<weaveDependency>
<groupId>myproject</groupId>
<artifactId>moduleA</artifactId>
</weaveDependency>
</weaveDependencies>
<aspectDirectory>src</aspectDirectory>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<id>weave-classes</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj-version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj-version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
这就是模块中pom的样子。
<artifactId>moduleC</artifactId>
<parent>
<groupId>myProject</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>myProject</groupId>
<artifactId>moduleAspect</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<XaddSerialVersionUID>true</XaddSerialVersionUID>
<showWeaveInfo>true</showWeaveInfo>
<aspectDirectory>src</aspectDirectory>
<aspectLibraries>
<aspectLibrary>
<groupId>myProject</groupId>
<artifactId>moduleAspect</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<id>compile_with_aspectj</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>