Reputation: 2673
I've imported a maven project to intellij IDEA. Dependencies were successfully resolved. But when running the
sudo mvn install
from terminal it gives this error.
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorFactory.java:[24,5] error: annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorType.java:[40,5] error: annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorType.java:[46,18] error: generics are not supported in -source 1.3
Earlier I've imported this project into eclipse also. Then running mvn install from eclipse it gave a diffrent type of error.
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
error: error reading /home/asiri/.m2/repository/com/hazelcast/hazelcast/3.0.1/hazelcast-3.0.1.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/eclipse/equinox/org.eclipse.equinox.http.helper/1.1.0.wso2v1/org.eclipse.equinox.http.helper-1.1.0.wso2v1.jar; zip file is empty
error: error reading /home/asiri/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.11/axiom-api-1.2.11.jar; invalid CEN header (bad signature)
error: error reading /home/asiri/.m2/repository/commons-io/commons-io/2.0/commons-io-2.0.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/wso2/carbon/org.wso2.carbon.user.core/4.2.0/org.wso2.carbon.user.core-4.2.0.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/org/apache/poi/poi-scratchpad/3.9/poi-scratchpad-3.9.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/poi/poi/3.9/poi-3.9.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/commons-pool/commons-pool/1.5/commons-pool-1.5.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/tomcat/tomcat-tribes/7.0.34/tomcat-tribes-7.0.34.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/tomcat/tomcat-catalina/7.0.34/tomcat-catalina-7.0.34.jar; invalid CEN header (bad signature)
error: error reading /home/asiri/.m2/repository/org/wso2/carbon/org.wso2.carbon.authenticator.stub/4.2.0/org.wso2.carbon.authenticator.stub-4.2.0.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/httpcomponents/wso2/httpclient/4.1.1-wso2v1/httpclient-4.1.1-wso2v1.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/com/google/guava/guava/12.0/guava-12.0.jar; invalid CEN header (bad signature)
right after that running the
sudo mvn install
from the terminal could get build successful. I don't understand the reason for this behavior. If there's a way to resolve the error getting in the first part of the question it would really help.
Upvotes: 3
Views: 3531
Reputation: 4225
Sound like Your compiler plugin configuration is not complete
Your Jdk level should be greater than 1.5
example pom.xml configuration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Upvotes: 2
Reputation: 163
Search for "source" in pom.xml.
There are must be wrong value.
Source means version of Java to compile the code.
If there is annotation in the Java code, you need to set version >= 1.5
Upvotes: 1
Reputation: 97389
Just define the compiler target/source like this:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Annotation need at least 1.5.
Upvotes: 1
Reputation: 3584
Please see Maven Compiler Plugin Documentation. Set the correct source and target levels. That should fix it.
Upvotes: 3