1

I'm trying to attach the Java 9 or Java 11 source for some projects released as MRJARs, namely jersey-container-jetty-http-3.0.2 and junit-platform-commons-1.4.0.

Looking at the jersey-container-jetty-http-3.0.2-sources.jar file in my ~/.m2/repository there is no META-INF/versions directory and the .java files in standard package locations are for Java 8 (pre module system). This is also the case if I unpack https://repo1.maven.org/maven2/org/glassfish/jersey/containers/jersey-container-jetty-http/3.0.2/jersey-container-jetty-http-3.0.2-sources.jar

This is a big bummer for my debugger :(

I was able to download the full source code from https://github.com/eclipse-ee4j/jersey/releases/tag/3.0.2, and it contains the following directories, with source:

containers/jetty-http/src/main/java11

containers/jetty-http/src/main/java8

I thought maybe this was just a Jersey problem, but looking at junit-platform-commons-1.4.0 I see a similar issue. Neither my ~/.m2/repository nor https://repo1.maven.org/maven2/org/junit/platform/junit-platform-commons/1.4.0/junit-platform-commons-1.4.0-sources.jar contain code for any java 9+ version but the release JAR contains /META-INF/versions/9/org/junit/platform/commons/util/ModuleUtils.class.

So my question: Is including source for multiple Java versions supported by Maven? If so, where are the Java 9+ source files be located?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Loren_
  • 2,597
  • 3
  • 20
  • 29

1 Answers1

-1

The maven-source-plugin:jar goal which:

[...] bundles all the sources into a jar archive.

doesn't mention MRJAR explicitely but it has the parameter:

Name Description
<includes> List of files to include. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • @perilandmishap 1. This is not a feature of the `javac` compiler tool (which creates `.class` files, not `.jar` files) but a feature of a Maven plugin which probably uses the [`jar` tool](https://docs.oracle.com/javase/9/tools/jar.htm) behind the scenes. 2. It's not just theoretical. 3. If this is the only way (yet) how Maven supports this (and it is, AFAIK) it is the only way (atm). Downvoting a workaround – and I agree, it's just that – doesn't change that fact. 4. Not even the Java 9 `jar` tool doc page mentions MRJAR and a search for it there yields "**No Matching Results**". – Gerold Broser Aug 23 '21 at 15:46
  • FYI: The [`maven-source-plugin`](https://github.com/apache/maven-source-plugin/blob/maven-source-plugin-3.2.0/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java) doesn't use the `jar` tool, but as well as the [`maven-jar-plugin`](https://github.com/apache/maven-jar-plugin/blob/maven-jar-plugin-3.2.0/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java) the `import org.codehaus.plexus.archiver.jar.JarArchiver;` – Gerold Broser Aug 24 '21 at 02:06