使用
同步滾動:
原文地址: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:
編譯器插件的目標綁定到構(gòu)建生命周期中各自的階段拾稳。所以要編譯源代碼,只需告訴maven要執(zhí)行哪個生命周期腊脱。以下內(nèi)容將編譯您的源代碼:
1. mvn compile
編譯器插件的目標綁定到構(gòu)建生命周期中各自的階段访得。沒看懂?如何解釋陕凹?
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.