Maven 2 Compiler Plugin: Usage

Compiling Your Java Sources

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:

mvn compile

To compile your test sources, you'll do:

mvn test-compile

The above command will execute both compiler:compile and compiler:test-compile since the compile phase happens a few phases before the test-compile phase.

Configuring Your Compiler Plugin

Since the Compiler Plugin executes automatically during their phases, you don't have to put executions unlike the other plugins.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <!-- put your configurations here -->
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>