Maven Build Failure (generics are not supported in -source 1.3 [ERROR] (use -source 5 or higher to enable generics))
When you try to build a maven project by mvn clean package
and you got "generics are not supported in -source 1.3 [ERROR] (use -source 5 or higher to enable generics)"
user@localhost:~/workspace1/sparkProject$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Building SparkSample 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sparkProject ---
[INFO] Deleting /home/jeba/workspace1/sparkProject/target
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ sparkProject ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ sparkProject ---
[INFO] Compiling 1 source file to /home/jeba/workspace1/sparkProject/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.337s
[INFO] Finished at: Mon Jun 22 16:05:58 IST 2015
[INFO] Final Memory: 12M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project sparkProject: Compilation failure
[ERROR] /home/user/workspace1/sparkProject/src/main/java/sparkProject/JavaWordCount.java:[36,9] generics are not supported in -source 1.3
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] JavaRDD<String> lines = ctx.textFile(args[0], 1);
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
and you got "generics are not supported in -source 1.3 [ERROR] (use -source 5 or higher to enable generics)"
user@localhost:~/workspace1/sparkProject$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Building SparkSample 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sparkProject ---
[INFO] Deleting /home/jeba/workspace1/sparkProject/target
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ sparkProject ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ sparkProject ---
[INFO] Compiling 1 source file to /home/jeba/workspace1/sparkProject/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.337s
[INFO] Finished at: Mon Jun 22 16:05:58 IST 2015
[INFO] Final Memory: 12M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project sparkProject: Compilation failure
[ERROR] /home/user/workspace1/sparkProject/src/main/java/sparkProject/JavaWordCount.java:[36,9] generics are not supported in -source 1.3
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] JavaRDD<String> lines = ctx.textFile(args[0], 1);
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
It means your pom.xml doesn't have the which java this maven should refer. If you don't specify, it will take Java 1.3
You can modify the pom.xml to point out the Java compiler version.
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Then if you execute "mvn clean package". This error will not appear.
No comments