设置maven for jdk10

时间:2018-05-09 06:46:03

标签: maven maven-jdeps-plugin

[INFO] Scanning for projects...
[INFO] ---------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] test.master
[INFO] test.generator
[INFO] test.model
[INFO] test.dal
[INFO] test.service
[INFO] test.web
[INFO]                                                                         
[INFO] ---------------------------------------------
[INFO] Building test.master 0.0.1-SNAPSHOT
[INFO] ---------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test.master ---
[INFO] 
[INFO] --- maven-jdeps-plugin:3.1.1:jdkinternals (default) @ test.master ---
[INFO] 
[INFO] --- maven-jdeps-plugin:3.1.1:test-jdkinternals (default) @ test.master ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ test.master ---
[INFO] Installing C:\Users\cora_kwok\git\backend2\pom.xml to   C:\Users\cora_kwok\.m2\repository\com\kinetix\test.master\0.0.1-SNAPSHOT\test.master-0.0.1-SNAPSHOT.pom
[INFO]                                                                         
[INFO] ----------------------------------------------------------
[INFO] Building test.generator 1.0.0
[INFO] -------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test.generator ---
[INFO] Deleting C:\Users\cora_kwok\git\backend2\test.generator\target
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ test.generator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\cora_kwok\git\backend2\test.generator\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test.generator ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\cora_kwok\git\backend2\test.generator\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] -----------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] test.master ............................. SUCCESS [  0.703 s]
[INFO] test.generator ............................ FAILURE [  0.790 s]
[INFO] test.model ......................................... SKIPPED
[INFO] test.dal ........................................... SKIPPED
[INFO] test.service ....................................... SKIPPED
[INFO] test.web ........................................... SKIPPED
[INFO] ---------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------
[INFO] Total time: 1.715 s
[INFO] Finished at: 2018-05-09T14:14:05+08:00
[INFO] Final Memory: 11M/40M
[INFO] ---------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test.generator: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :test.generator

下面是模块test.generator的pom.xml。我想使用jdeps检查jdk10的第三方依赖关系,并准备jdk10升级,但是,当我尝试运行并导致上述错误时。

我删除了我的m2.repository文件夹,但仍然存在相同的错误。 我已经安装了jdk10和jre10。但是,它似乎在maven构建期间无法识别jdk10。

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.kinetix</groupId>
    <artifactId>test.master</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>com.kinetix.test</groupId>
  <artifactId>test.generator</artifactId>
  <version>1.0.0</version>
  <name>test.generator</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <java-version>10.0.1</java-version>
  </properties>
  <dependencies>
    <dependency>
        <groupId>org.jasypt</groupId>
        <artifactId>jasypt</artifactId>
        <version>1.9.2</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

我不知道为什么它无法识别版本10.0.1的jdk10小于版本1.7的版本。

1 个答案:

答案 0 :(得分:5)

您必须通过pluginManagement定义maven-compiler插件,如下所示:

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  ..
  </build>

此外,您应该像这样定义属性:

  <properties>
    <maven.compiler.source>10</maven.compiler.source>
    <maven.compiler.target>10</maven.compiler.target>
    <maven.compiler.release>10</maven.compiler.release>
  </properties>

您有多模块构建,其中您有一个父级,您应该在其中定义上述内容。此外,我强烈建议您定义所有使用的插件,如maven-resources-plugin等,如上面的maven-compiler-plugin ...以及最新版本,而不是这些古老的版本......