And*_*erg 26 maven maven-compiler-plugin
我有一个使用aspectj-compiler-plugin的maven项目.我使用intertype声明,因此在我的Java代码中引用了Aspect代码.因此,maven-compiler-plugin无法编译,因为它不编译方面代码.
我的问题是:如何禁止maven-compiler-plugin运行,因为它没有做任何有用的事情?
我有几种方法可以让这个项目编译,但它们是次优的:
小智 30
您可以通过将插件的阶段设置为none来禁用插件.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
Sim*_*ane 27
在Maven 3中,以下内容将执行此操作,例如禁用clean插件:
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
相同的技术可用于在超级POM,包装类型或父POM中定义的任何其他插件.关键点是您必须复制<id>显示的help:effective-pom,并将其更改<phase>为无效值(例如"无").如果你没有<id>(例如在金田邓的原始答案 - 它已被编辑添加一个),它将无法正常工作,正如你所发现的那样.
要么配置skipMain参数:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<skipMain>true</skipMain>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
或者传递maven.main.skip属性:
mvn install -Dmaven.main.skip=true
Run Code Online (Sandbox Code Playgroud)
maven-compiler-plugin 首先执行的原因是因为您触发了默认生命周期绑定之一。例如,如果您使用mvn package打包 jar ,它将在编译阶段触发compile:compile。
也许尝试不使用默认生命周期,而是使用mvnspectj:compile代替。
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html有关于 maven 默认生命周期绑定的更多信息
| 归档时间: |
|
| 查看次数: |
10448 次 |
| 最近记录: |