The Maven Compile Plugin is used to compile all the source code for your project.
Goals:
- compiler:compile is bound to the compile phase and is used to compile the main source files.
- compiler:testCompile is bound to the test-compile phase and is used to compile the test source files.
Configurations:
1. Compile using a different JDK: Following configuration sets the version of the compiler to 1.8.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <verbose>true</verbose> <fork>true</fork> <executable>C:\Program Files\Java\jdk1.8.0\bin\javac</executable> <compilerVersion>1.3</compilerVersion> </configuration> </plugin> </plugins> </build>
2. Compile using different source and target versions of java compiler: Following configuration sets the source and target version to 1.8.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
3. Compile using enhanced memory allocation: Following configuration sets the initial memory size to 256MB and maximum memory size to 1084MB.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <fork>true</fork> <meminitial>256m</meminitial> <maxmem>1084m</maxmem> </configuration> </plugin> </plugins> </build>