Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build deprecation error

Tags:

java

maven

I try to build a java project with maven. I use java 7 but maven source is 1.6. I can't change it. When I run "mvn clean install" it fails with a strange error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project search: Compilation failure
[ERROR] could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.6
[ERROR] /someClassName.java:114: warning: [deprecation] LUCENE_36 in Version has been deprecated
[ERROR] out = new ICUCollationKeyAnalyzer(Version.LUCENE_36, l);
[ERROR] ^
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project search: Compilation failure
could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.6
/someClassName.java:114: warning: [deprecation] LUCENE_36 in Version has been deprecated
                    out = new ICUCollationKeyAnalyzer(Version.LUCENE_36, l);

Currently, I am not going to change a lucene version as maven recommends.. So, I wonder why maven cares about deprecated things in the code and how to avoid these errors? Thanks.

Apache Maven 3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
like image 446
kikulikov Avatar asked Oct 03 '22 16:10

kikulikov


3 Answers

The error message is misleading - it's only a compilation warning, not a failure. This might be related to http://jira.codehaus.org/browse/MCOMPILER-179. Try upgrading to Maven 3.0.5 (or the latest 3.1.x) or updating the version of the maven compiler plugin in the POM.

like image 61
artbristol Avatar answered Oct 11 '22 12:10

artbristol


Ok. Thank you all. I resolved the problem adding SuppressWarning("deprecation") to the problem class. But still not sure what difference it makes for maven..

like image 34
kikulikov Avatar answered Oct 11 '22 13:10

kikulikov


To elaborate on this topic a bit, you can use showWarnings configuration to force showing compilation warnings on/off.

Set it to false (if it suits you) to hide the warning in the first place.

<plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <showWarnings>false</showWarnings>
        </configuration>
    </plugin>
</plugins>
like image 30
Johnny Avatar answered Oct 11 '22 13:10

Johnny