在Ubuntu Java 8上缺少apt-maven-plugin的tools.jar

时间:2015-10-01 10:34:21

标签: maven java-8

我正在升级maven项目,以便使用Java 7中的Java 8进行编译。

我机器上安装的java版本是

pauloconnell@pauloconnell-HP-ZBook-15:~/$ update-java-alternatives -l
java-7-oracle 1076 /usr/lib/jvm/java-7-oracle
java-8-oracle 1077 /usr/lib/jvm/java-8-oracle

我的JAVA_HOME已设置

pauloconnell@pauloconnell-HP-ZBook-15:~/$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

任何这些都是我的.bashrc文件中的详细信息

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export MAVEN_HOME=/usr/share/maven/bin
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin

当我跑“编译”时在具有此插件的模块上

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <configuration>
        <factory>com.infonova.om.il.apt.Factory</factory>
        <showWarnings>true</showWarnings>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>process</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我得到了

[ERROR] Failed to execute goal org.codehaus.mojo:apt-maven-plugin:1.0-alpha-5:process (default) on project om-interface-eircom: Unable to locate the apt compiler in:
[ERROR] /usr/lib/jvm/java-8-oracle/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.5 or above and
[ERROR] not a JRE (the com.sun.tools.apt.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.

我发现了这些现有问题

http://stackoverflow.com/questions/8375423/missing-artifact-com-suntoolsjar
https://github.com/thickpaddy/jenkins_campfire_plugin/issues/12
http://stackoverflow.com/questions/10812668/unable-to-locate-the-javac-compiler
http://stackoverflow.com/questions/5730815/unable-to-locate-tools-jar

并更新了我的插件配置,将工具包含为systemPath依赖

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <configuration>
        <factory>com.infonova.om.il.apt.Factory</factory>
        <showWarnings>true</showWarnings>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>process</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.8</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
    </dependencies>
</plugin>

但问题仍然存在。我的maven版本细节是

pauloconnell@pauloconnell-HP-ZBook-15:~/$ mvn -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IE, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-63-generic", arch: "amd64", family: "unix"

我相信我会使用正确的JAVA_HOME和PATHS设置。有什么想法吗?

0 个答案:

没有答案