使用
同步滚动:
原文地址:http://maven.apache.org/plugins/maven-compiler-plugin/usage.html
使用
编译 Java 源码
The goals for the Compiler Plugin are bound to their respective phases in the build lifecycle. So to compile your sources, you need only to tell maven until which lifecycle to execute. The following will compile your sources:
编译器插件的目标绑定到构建生命周期中各自的阶段。所以要编译源代码,只需告诉maven要执行哪个生命周期。以下内容将编译您的源代码:
1. mvn compile
编译器插件的目标绑定到构建生命周期中各自的阶段。没看懂?如何解释?
To compile your test sources, you'll do:
<pre class="prettyprint linenums">
- mvn test-compile
</pre>
The above command will execute both <tt>compiler:compile</tt> and <tt>compiler:testCompile</tt> since the <tt>compile</tt> phase happens a few phases before the <tt>test-compile</tt> phase.
Configuring Your Compiler Plugin
Since the Compiler Plugin executes automatically during their phases, you don't have to put <tt>executions</tt> unlike many other plugins. However, you should specify the version of the Compiler Plugin.
<pre class="prettyprint linenums">
- <project>
- ...
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.1</version>
- <configuration>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- ...
- </project>
</pre>
Note: Maven 3.0 will issue warnings if you do not specify the version of a plugin.