Skip to content

Conversation

desruisseaux
Copy link
Contributor

By default, java.util.jar.JarFile does not search for resources in META-INF/versions/ sub-directories. For enabling this feature, we need to specify a version greater than Java 8 to the constructor. The core change of this pull request is this line:

try (JarFile jar = new JarFile(path.toFile(), false, JarFile.OPEN_READ, target)) {
    // ...
}

The rest is for answering the question: "which target Java version"? An easy approach would have been to set target unconditionally to Runtime.version(), i.e. the Java version on which Maven is running. This pull request rather allows configuration, with the intend to set the target version to the value of the --release target option. This value can determine whether a dependency will be placed on the class-path or on the module-path. For example, if the module-info.class entry of a JAR file exists only in the META-INF/versions/17/ sub-directory, then the default location of that dependency will be the module-path only if the --release option is equal or greater than 17.

This pull request fixes the initial topic of apache/maven-compiler-plugin#966.

…ons/` sub-directories of a JAR file.

If the project specifies a target Java release, only the directories for versions equal to lower to the target version will be scanned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant