Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - use -source 5 or higher to enable... while building the project

I downloaded one project from our svn and now I am trying to build this using Maven (mvn clean install... my maven is Apache Maven 3.0.4). Unfortunately, when I try to build, the following error occurs. It is strange that it reports something (I think) about Java version 1.3, which of course I dont have installed in my laptop. I have JAVA_HOME setted to JDK 1.7, my javac is also in version 1.7 ...

Please do you know where is the problem?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project irapi: Compilation failure: Compilation failure:
[ERROR] /home/jan/nutch/src/plugin/irapi/src/main/java/cz/cvut/fit/linkedtv/irapi/rest/MediaServer.java:[21,1] error: **annotations are not supported in -source 1.3**
[ERROR] 
[ERROR] (use -source 5 or higher to enable annotations)
[ERROR] /home/jan/nutch/src/plugin/irapi/src/main/java/cz/cvut/fit/linkedtv/irapi/solr/SolrQueryResponseConvertor.java:[35,26] error: **for-each loops are not supported in -source 1.3**
like image 602
Jan Bouchner Avatar asked May 29 '13 19:05

Jan Bouchner


People also ask

What is the Maven command to build the project?

mvn install. This command builds the maven project and installs the project files (JAR, WAR, pom. xml, etc) to the local repository.

What are the 3 build life cycle of Maven?

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.

What is the use of Maven and explain how is it used to take build?

Maven is written in Java and is used to build projects written in C#, Scala, Ruby, etc. Based on the Project Object Model (POM), this tool has made the lives of Java developers easier while developing reports, checks build and testing automation setups.

What happens when we build a Maven project?

Validates if the project is correct and if all necessary information is available. Source code compilation is done in this phase. Tests the compiled source code suitable for testing framework. This phase creates the JAR/WAR package as mentioned in the packaging in POM.


1 Answers

You must specify the source configuration parameter to the maven-compiler-plugin like this:

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

See also Setting the -source and -target of the Java Compiler in the maven documentation for further details.

like image 123
Torsten Avatar answered Oct 25 '22 18:10

Torsten