Error: log4j-api-2.9.0.jar is a multi-release jar file but --multi-release option is not set

醉酒当歌 提交于 2019-12-01 21:55:52

问题


Exploring the maven-jdeps-plugin:3.1.0 with Java9 using the following minimal 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>

On executing

mvn install

I end up getting a detailed error that reads the following:-

[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'

I couldn't find much relevance related to --multi-release flag in either jdeps:jdkinternals goal detailed on Maven's official site or even in the jdeps tool documented at Oracle help center.

Can someone throw some light on this implementation in maven-jdeps-plugin? Is there a way to fix this(set the --multi-release option)?


回答1:


This is user error. Please enter jdeps -? on the command line. You will see you need to enter

jdeps --multi-release 9 ~/.m2/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar



回答2:


Regarding the plugin itself, following configuration works.

  <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>



回答3:


Eventually with the help of a comment from Nicolai. I could conclude separating out this into two different issues:-

  1. Minor issue on the part of maven-jdeps-plugin that I have raise to their tracker, where its Logging jdeps Errors as INFO.

  2. The root cause of the above error on the other hand, when I try and execute the command jdeps on the log4j-api-2.9.1.jar as-

    ➜ jdeps ~/.m2/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar
    

    I end up getting the following error:-

    Error: log4j-api-2.9.1.jar is a multi-release jar file but --multi-release option is not set

    This can be tracked at --multi-release option not set for the multi-release jar.

Edit:- The correct way to use the command line tool is answered by @rgoers

Update:- The linked maven plugin bug is converted to a new feature request and shall probably be included in future releases of the plugin.



来源:https://stackoverflow.com/questions/46662286/error-log4j-api-2-9-0-jar-is-a-multi-release-jar-file-but-multi-release-optio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!