8

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

Naman
  • 27,789
  • 26
  • 218
  • 353
  • How did you make the connection from your error message to Log4J being an MR-JAR and that that's causing the problem? – Nicolai Parlog Oct 10 '17 at 09:51
  • @Nicolai Complete logs in the question now, and to add to it `INFO` is the level where its reading that `Error`!! (something is messed for sure) – Naman Oct 10 '17 at 09:57
  • Ah, that looks as if JDeps creates an error message that the plugin picks up and accidentally logs as INFO. Maybe. Try to get the message by simply executing JDeps on the Log4J-JAR. – Nicolai Parlog Oct 10 '17 at 10:01

3 Answers3

6

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>
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
5

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
rgoers
  • 8,696
  • 1
  • 22
  • 24
  • "jdeps" is the command being executed. "-?" displays the help text for the command including all the options. You can also do "jdeps --help" – rgoers Oct 28 '17 at 06:58
  • Though I am letting the maven related bug open. Since the logging seems mixed up in maven for this. And if you can update `-?` to `--help` would be good in the answer. – Naman Oct 28 '17 at 07:06
  • 2
    This answer would be better if you explained what the suggested solution does and why it solves the problem! – Lii Nov 09 '20 at 10:36
  • This answer assumes `jdeps` is being executed directly, rather than from the `maven-jdeps-plugin` (as clearly stated in the beginning of the question). – MikeOnline Jun 08 '21 at 21:36
0

We can pass the multi-release property via command line (since version 3.1.1), eg:

mvn jdeps:jdkinternals -Djdeps.multiRelease=9
JuanMoreno
  • 2,498
  • 1
  • 25
  • 34