apache / apache/maven-source-plugin

[MSOURCES-144] Include sources for multi-release jars

Open
#215 8 comments 4 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
37
Forks
38
Avg merge
18h 47m
Merged PRs (30d)
5

Description

**[Tagir Valeev](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=lany)** opened **[MSOURCES-144](https://issues.apache.org/jira/browse/MSOURCES-144?redirect=false)** and commented

Java 9 introduced multi-release JARs seven years ago (see [JEP 238](https://openjdk.org/jeps/238)). Since then, Maven support for multi-release JARs was gradually improved, and now it's quite easy to create and deploy such a project. However, I see a significant unresolved problem: the source files for alternative versions of class-files are not automatically added to the source jar, and I see no easy way to fix this.

Consider the attached example. It contains two versions of com.example.DefaultVersion class, one for Java 8, and one for Java 9. Execute `mvn verify`. The resulting multi-release-sample-1.0.jar properly contains com/example/DefaultVersion.class as Java 8 compiled version and META-INF/versions/9/com/example/DefaultVersion.class as Java 9 compiled version. However, the source JAR multi-release-sample-1.0-sources.jar contains no Java 9-specific version. I expect that the source jar should add Java 9 source version under the path META-INF/versions/9/com/example/DefaultVersion.java

This has an unpleasant effect: the library sources are incomplete, so the library user cannot easily browse them without using decompiler or looking for the source repository. This complicates navigation and debugging in IDEs. In fact, I've checked dozens of multi-release JARs in Maven Central, and none of them contain version-specific sources. It would be great to solve this on the maven-source-plugin side, so the library maintainers need only to bump source-plugin version to publish the sources properly.

Thank you in advance,
Tagir Valeev.

---

**Affects:** 3.3.0

**Attachments:**
- [multirelease.zip](https://issues.apache.org/jira/secure/attachment/13067152/multirelease.zip) (_2.59 kB_)

1 votes, 3 watchers

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.