Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Implements support for Eclipse JDT's release classpath attribute (introduced in Eclipse 4.38) to enable multi-release JAR compilation with flexible source folder naming and without requiring supplemental manifests.

Changes

Core Implementation

  • SourceFolderClasspathEntry: Added getMultiReleaseVersion() method returning OptionalInt to extract Java version from release classpath attribute
  • AbstractOsgiCompilerMojo: Enhanced doCompile() to check for Multi-Release: true manifest header first, then detect classpath entries with release attributes, compile them with appropriate --release flags, and output to META-INF/versions/N/ directories. Falls back to directory-based approach for backward compatibility.
  • Manifest Requirement: The Multi-Release: true header must be explicitly set in the manifest as a prerequisite to enable the feature

Example

.classpath file marking source folders for specific Java versions:

<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="src9">
        <attributes>
            <attribute name="release" value="9"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src11">
        <attributes>
            <attribute name="release" value="11"/>
        </attributes>
    </classpathentry>
</classpath>

Note: Source folders can be named flexibly (e.g., src_java9, java11-src). The version is determined by the release attribute value, not the folder name.

Required manifest configuration:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: my.bundle
Multi-Release: true
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

Resulting JAR structure:

jar root
├── com/example/MyClass.class (Java 8)
└── META-INF/
    ├── MANIFEST.MF (Multi-Release: true - required)
    └── versions/
        ├── 9/com/example/MyClass.class
        └── 11/com/example/MyClass.class

Key Features

  • Manifest-First: Multi-Release: true header is required as the primary trigger
  • Flexible Naming: Source folders can be named anything, version determined by release attribute
  • No Supplemental Manifests: Unlike the legacy approach, no supplemental manifests in META-INF/versions/N/OSGI-INF/ are required
  • Backward Compatible: Falls back to directory-based approach (srcN naming) if no classpath attributes found

Demo & Documentation

  • demo/multi-release-jar-classpath/: Reference implementation using classpath attribute approach
  • BuildingMultiReleaseBundles.md: Comprehensive guide covering JEP 238, OSGi R8 spec, both approaches (classpath vs manifest-first), and best practices
  • DemoTest: Added integration test for classpath-based demo

References

Original prompt

Enhance Multi-Release jar support

JDT since this release supports an additional attribute in the classpath see https://github.com/eclipse-pde/eclipse.pde/pull/2138/files#diff-94c43945b1beca74bb258b7502839b468019013d2f00a33cab2fc751f11c5df7R12
and teh release notes here https://eclipse.dev/eclipse/markdown/?f=news/4.38/jdt.md#multi-release-jar-compilation-support

Tycho already contains multi-release jar support since a while see https://github.com/eclipse-tycho/tycho/tree/main/demo/multi-release-jar but it requires a certain structur to be recognized.

This should now be enhance to also bein triggered by the flag in the classpath, and Tycho contains already classes for reading claspath here https://github.com/eclipse-tycho/tycho/tree/main/tycho-metadata-model/src/main/java/org/eclipse/tycho/model/classpath

So we need:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Enhance multi-release jar support in Tycho Add JDT classpath attribute support for multi-release JAR compilation Nov 18, 2025
Copilot AI requested a review from laeubi November 18, 2025 19:58
Copy link
Member

@laeubi laeubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please look at the review comments some things have to be adjusted here.

Copy link
Contributor Author

Copilot AI commented Nov 19, 2025

@copilot please look at the review comments some things have to be adjusted here.

All review comments have been addressed in commit 866687c. The changes include:

  • Corrected attribute name to release
  • Used OptionalInt for return type
  • Made Multi-Release header a requirement (not automatic)
  • Manifest check is primary trigger
  • Updated all documentation and demo files

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/tycho/tycho/demo org.codehaus.plexus.classworlds.launcher.Launcher clean verify -Dtycho-version=6.0.0-SNAPSHOT (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from laeubi November 19, 2025 05:58
@laeubi laeubi marked this pull request as ready for review November 19, 2025 09:59
@laeubi laeubi force-pushed the copilot/enhance-multi-release-jar-support branch from 866687c to 8ae7d26 Compare November 19, 2025 10:11
@laeubi laeubi enabled auto-merge (rebase) November 19, 2025 10:11
@laeubi laeubi force-pushed the copilot/enhance-multi-release-jar-support branch from 8ae7d26 to 3102a55 Compare November 19, 2025 10:13
@laeubi laeubi merged commit 3f7e097 into main Nov 19, 2025
15 checks passed
@laeubi laeubi deleted the copilot/enhance-multi-release-jar-support branch November 19, 2025 12:44
@eclipse-tycho-bot
Copy link

💚 All backports created successfully

Status Branch Result
tycho-5.0.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants