Compiler plugin in Maven

Maven compiler plugin is used to compile the source code files in a project. It has 2 goals.
  • compiler:compile
  • compiler:testCompile
We can execute these goals by issuing below commands.
  • mvn compile
  • mvn test-compile
By default, it uses source and destination compatibility as JDK 1.5 But you can change these settings by configuring the plugin as shown below. In below configuration, we have instructed maven to use source and destination JDK compatibility level as 1.8
 
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Complex problems, Simple Solutions