javamavenjava-9jdepsmaven-jdeps-plugin

Error: unknown option: -M while using module option of maven-jdeps-plugin


I found the module attribute on the official documentation of the maven-jdeps-plugin which states that

Show module containing the package

  • Type: boolean
  • Since: JDK 1.9.0
  • Required: No
  • User Property: jdeps.module
  • Default: false

Trying to make use of it with the current minimal pom.xml as follows:-

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>9</source>
                <target>9</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jdeps-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <apiOnly>false</apiOnly>
                <failOnWarning>true</failOnWarning>
                <module>true</module>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>jdkinternals</goal> <!-- verify main classes -->
                        <goal>test-jdkinternals</goal> <!-- verify test classes -->
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The build of my project(named sparkjdk9) on executing

mvn clean install

results into these logs:-

[INFO] --- maven-jdeps-plugin:3.1.0:jdkinternals (default) @ sparkjdk9 ---
[INFO] 
Error: unknown option: -M
Usage: jdeps <options> <path ...>]
use -h, -?, -help, or --help for a list of possible options
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.649 s
[INFO] Finished at: ...
[INFO] Final Memory: 13M/44M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jdeps-plugin:3.1.0:jdkinternals (default) on project sparkjdk9: 
[ERROR] Exit code: 2
[ERROR] Command line was: /bin/sh -c '/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/jdeps' '-M' '.../sparkjdk9/target/classes'

Looking further for similar flag in jdeps tool, I could see the error is justified since there is no such flag -M in its usage.

Q. What is the use of this attribute and how can it be used?


Solution

  • See https://github.com/apache/maven-plugins/blob/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java#L322

    The -M used to be the module parameter, but it seems like it has been renamed to -m/--module in the meantime.

    Update : This should be resolved with 3.1.1 release of the Maven JDeps Plugin as followed by the tracker](See https://github.com/apache/maven-plugins/blob/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java#L322

    The -M used to be the module parameter, but it seems like it has been renamed to -m/--module in the meantime.

    Update : This should be resolved with 3.1.1 release of the Maven JDeps Plugin as followed by the tracker.