Is there “skip weaving flag” in Maven? (exclude AspectJ)

你离开我真会死。 提交于 2019-12-23 02:13:48

问题


I build our multi-project application with Maven(lots of pom.xml-s). We recently introduced AspectJ, however I suspect AspectJ contributes to performance problems. In order to be sure, I'd like to build the application this time without AspectJ and see how it performs. But I would not really like to remove all AspectJ related stuff from pom.xml, so it would be handy if there was some kind of flag or something that could exclude AspectJ from build. Is there any?
Update: this does not seem to have any effect: -Dmaven.aspectj.skip=true


回答1:


If you want to disable the aspectj-maven-plugin temporarily, you could add a profile to the parent pom.xml which deregisters the executions of the plugin (by assigning them to phase none). Could look like this (add your own execution IDs if you have some):

<profile>
    <id>noAspectJ</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

A simple maven cmd activates this:

mvn clean install -PnoAspectJ


来源:https://stackoverflow.com/questions/21597681/is-there-skip-weaving-flag-in-maven-exclude-aspectj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!