7

使用以下最小值探索maven-jdeps-plugin:3.1.0Java9 pom.xml:-

<dependencies>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.9.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
               <source>1.9</source>
               <target>1.9</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jdeps-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>jdkinternals</goal> <!-- verify main classes -->
                        <goal>test-jdkinternals</goal> <!-- verify test classes -->
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

执行时

mvn install

我最终得到一个详细的错误,内容如下: -

[INFO] Error: log4j-api-2.9.0.jar is a multi-release jar file but --multi-release option is not set
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.389 s
[INFO] Finished at: ...
[INFO] Final Memory: 12M/41M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jdeps-plugin:3.1.0:jdkinternals (default) on project maven-jigsaw: 
[ERROR] Exit code: 2
[ERROR] Command line was: /bin/sh -c '/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/jdeps' '-cp' '.../.m2/repository/org/apache/logging/log4j/log4j-api/2.9.0/log4j-api-2.9.0.jar' '../maven/target/classes'

在 Maven 官方网站上详述的任何一个目标中,甚至在Oracle 帮助中心记录的工具中,我都找不到与--multi-release标志相关的太多相关性。jdeps:jdkinternalsjdeps

有人可以对这个实现有所了解maven-jdeps-plugin吗?有没有办法解决这个问题(设置--multi-release选项)?

4

3 回答 3

5

关于插件本身,以下配置有效。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jdeps-plugin</artifactId>
    <version>3.1.1</version>
    <executions>
      <execution>
        <goals>
          <goal>jdkinternals</goal> <!-- verify main classes -->
          <goal>test-jdkinternals</goal> <!-- verify test classes -->
        </goals>
      </execution>
    </executions>
    <configuration>
      <multiRelease>9</multiRelease> <!-- Check this out -->
    </configuration>
  </plugin>
于 2019-05-31T15:30:28.480 回答
4

这是用户错误。请输入 jdeps -? 在命令行上。你会看到你需要输入

jdeps --multi-release 9 ~/.m2/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar
于 2017-10-28T06:52:13.133 回答
0

我们可以通过命令行(从3.1.1 版本开始)传递 multi-release 属性,例如:

mvn jdeps:jdkinternals -Djdeps.multiRelease=9
于 2022-01-17T00:38:02.953 回答