Saturday Aug 31

Key Concepts

Maven Compile

PDFPrintE-mail
Monday, 11 April 2011 09:25
AddThis Social Bookmark Button

Maven compile plugin example

Maven Compiler Plugin Configuration

The fist step to build a java application is to be able to compile a maven projet. According to the dependencies created in the POM file (Project object model) Maven is able to define the classpath and compile using the default jdk using the following command :

Maven compile plugin configuration

mvn compile

Maven compile incrementally. An incremental build reuses the results of a previous build to perform an optimized build based on the changes since the last build. If your code has been compiled by Eclipse you can have some surprises due to some tips and tricks used by the Eclipse compiler. To ensure a full compilation by the default Sun JDK you should make a cleanup before compiling. It will delete the previously compiled classes contained in the {project directory}/target/classes

Maven Apache compile plugin tutorial

mvn clean compile

If you want to compile without your Unit test defined in {project directory}/src/test/java your can ask maven to skip the test

Apache Maven compile plugin

mvn compile -DskipTest=true

Compiler version

If you need to define the compiler version you can set the source and target parameter in the Compiler Plugin :

Maven compiler plugin configuration

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>

Maven Tutorial related articles

Tags: compile, maven, build, default, eclipse, plugin, compiler

Add comment


Security code
Refresh

Java Tutorial on Facebook