0

A = 我写的 maven 插件

B = 使用 A 作为其构建过程的一部分的 maven 项目


当我使用 maven 构建 A 时,aspectj 按预期工作,并且我在单元测试期间达到了我的切入点。我使用 aspectj-maven-plugin 来构建它,因为我使用 maven 构建了 A。

问题是当我使用 maven 构建 B 并将 A 作为插件依赖项包含时,在构建过程中执行 A 时我没有命中我的切入点。

我尝试在 B 中包含 aspectj-maven-plugin 来解决这个问题,但没有运气。我还在 B 中尝试了各种形式的配置以尝试解决此问题。目前,我对 B 的配置如下:

                   <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>aspectj-maven-plugin</artifactId>
                        <version>1.4</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>compile</goal>
                                    <goal>test-compile</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.aspectj</groupId>
                                <artifactId>aspectjrt</artifactId>
                                <version>${aspectj.version}</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <source>${maven.compiler.source}</source>
                            <target>${maven.compiler.target}</target>
                            <complianceLevel>${maven.compiler.target}</complianceLevel>
                            <forceAjcCompile>true</forceAjcCompile>
                            <showWeaveInfo>true</showWeaveInfo>
                            <weaveWithAspectsInMainSourceFolder>true</weaveWithAspectsInMainSourceFolder>
                            <encoding>UTF-8</encoding>
                            <aspectLibraries>
                                <aspectLibrary>
                                    <groupId>com</groupId>
                                    <artifactId>A</artifactId>
                                </aspectLibrary>
                            </aspectLibraries>
                            <weaveDependencies>
                                <weaveDependency>
                                    <groupId>com</groupId>
                                    <artifactId>A</artifactId>
                                </weaveDependency>
                            </weaveDependencies>
                        </configuration>
                    </plugin>
4

0 回答 0