Skip to content

Commit 8d83f0e

Browse files
Copilotlaeubi
andcommitted
Add Multi-Release JAR compilation support N&N entry for JDT
Co-authored-by: laeubi <[email protected]>
1 parent 08956f9 commit 8d83f0e

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
113 KB
Loading

news/4.38/jdt.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,47 @@ A special thanks to everyone who [contributed to JDT](acknowledgements.md#java-d
2222
## Java Views and Dialogs
2323
-->
2424

25-
<!--
2625
---
2726
## Java Compiler
28-
-->
27+
28+
### Multi-Release JAR Compilation Support
29+
<!-- https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3900 -->
30+
<!-- https://github.com/eclipse-jdt/eclipse.jdt.ui/pull/2260 -->
31+
<!-- https://github.com/eclipse-jdt/eclipse.jdt.debug/pull/753 -->
32+
<!-- https://github.com/eclipse-m2e/m2e-core/pull/2058 -->
33+
<details>
34+
<summary>Contributors</summary>
35+
36+
- [Christoph Laeubrich](https://github.com/laeubi)
37+
- [Stephan Herrmann](https://github.com/stephan-herrmann)
38+
</details>
39+
40+
JDT now supports native compilation of Multi-Release JARs.
41+
[Multi-Release JARs](https://openjdk.org/jeps/238) are a feature introduced in Java 9 that allows a single JAR file to contain multiple versions of the same class,
42+
each compiled for a specific Java release.
43+
This enables libraries to take advantage of newer Java features while maintaining backward compatibility with older Java versions.
44+
45+
With this new feature, you can now compile Multi-Release Types directly within Eclipse.
46+
Multi-Release Types are classes that exist in different variants with the same name across different source folders,
47+
where each variant is automatically compiled with the appropriate Java release settings and placed in the correct output folder.
48+
49+
This implementation follows the "Pattern 3: Single Project" approach described in the [Maven Compiler Plugin documentation](https://maven.apache.org/plugins/maven-compiler-plugin/multirelease.html).
50+
Previously, this pattern had limited IDE support, but Eclipse now provides a simple and elegant solution by compiling individual class files with the corresponding release option.
51+
52+
To enable Multi-Release compilation for a source folder, open the source folder properties in the Build Path configuration and specify the target Java release:
53+
54+
![Multi-Release JAR configuration dialog](images/multi-release-jar-config.png)
55+
56+
Once configured, you can:
57+
- Edit and compile Multi-Release Types simultaneously across different Java versions
58+
- Run Multi-Release compiled projects directly from the Eclipse IDE
59+
- Use m2eclipse's built-in support to automatically map `maven-compiler-plugin` executions for Multi-Release JARs into JDT configuration
60+
61+
This feature significantly simplifies the development workflow for libraries that need to support multiple Java versions.
62+
We welcome your feedback and testing of this new capability.
63+
For known issues and to report problems, please visit the [JDT Core issue tracker](https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4275).
64+
65+
For more details on m2eclipse integration, see the [m2e-core release notes](https://github.com/eclipse-m2e/m2e-core/blob/main/RELEASE_NOTES.md#multi-release-jar-support).
2966

3067
<!--
3168
---

0 commit comments

Comments
 (0)