• [gentoo-dev] [PATCH v2 1/4] java-pkg-simple.eclass: support Multi-Relea

    From Volkmar W. Pogatzki@21:1/5 to All on Mon Mar 17 23:10:02 2025
    See https://openjdk.org/jeps/238

    This commit adds basic support for building multi-release jar files.
    A multi-release jar file has release-specific classes in directories
    under META-INF/versions/ and its MANIFEST.MF contains a line with 'Multi-Release: true'.

    The probably most common case of a multi-release jar file has only one
    single such class which is 'META-INF/versions/9/module-info.class'.

    To do so, we add JAVA_RELEASE_SRC_DIRS as a new eclass variable which
    is also used as the condition to trigger the new functionality. A new
    local variable 'multi_release' is added to the packaging section (the
    part using the 'jar -create' command). Only when JAVA_RELEASE_SRC_DIRS
    is set, additional actions take place:

    - Compilation (those are the parts with 'ejavac') will additionally loop
    over the release-specific directories listed in JAVA_RELEASE_SRC_DIRS
    and compile the release-specific classes into corresponding directories
    under target/versions/.

    - Packaging (the part using the 'jar -create' command) will add the
    details to the 'multi_release' variable so that the release-specific
    directories under target/versions/ can be packaged into the jar file.

    This commit also adds funtionality to generate 'module-info.java' files.
    It is useful for packages where module-info.java is not provided in the
    sources but needs to be generated by the build system. We use the built-in jdeps function with the --generate-module-info option which became available with Java 11.

    It generates the module-info.java file based on an intermediate jar file
    and places it in the "${JAVA_MODULE_INFO_OUT}/${JAVA_INTERMEDIATE_JAR_NAME}/" directory.

    For this purpose we add three new eclass variables:
    - JAVA_INTERMEDIATE_JAR_NAME
    - JAVA_MODULE_INFO_OUT
    - JAVA_MODULE_INFO_RELEASE

    When both JAVA_MODULE_INFO_OUT and JAVA_INTERMEDIATE_JAR_NAME are defined in the
    ebuild we
    - compile the sources still without module-info
    - package them as an intermediate {JAVA_INTERMEDIATE_JAR_NAME}.jar
    - let java-pkg-simple_generate-module-info generate the module-info
    - compile module-info.java with the --patch-module option
    - package the final jar file including the module-info.class

    When the JAVA_MODULE_INFO_RELEASE variable is set, module-info.java is generated into a release specific directory "${JAVA_MODULE_INFO_OUT}/${JAVA_INTERMEDIATE_JAR_NAME}/versions/{JAVA_MODULE_INFO_RELEASE}".

    Bug: https://bugs.gentoo.org/900433
    Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
    ---
    eclass/java-pkg-simple.eclass | 269 +++++++++++++++++++++++++++++++++-
    1 file changed, 264 insertions(+), 5 deletions(-)

    diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index ce4a62f048da..84384116af99 100644
    --- a/eclass/java-pkg-simple.eclass
    +++ b/eclass/java-pkg-simple.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2004-2024 Gentoo Authors
    +# Copyright 2004-2025 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: java-pkg-simple.eclass
    @@ -11,7 +11,9 @@
    # @DESCRIPTION:
    # This class is intended to build pure Java packages from Java sources
    # without the use of any build instructions shipped with the sources.
    -# There is no support for generating source files, or for controlling
    +# It can generate module-info.java files and supports adding the Main-Class
    +# and the Automatic-Module-Name attributes to MANIFEST.MF. There is no
    +# further support for generating source files, or for controlling
    # the META-INF of the res
  • From Volkmar W. Pogatzki@21:1/5 to All on Mon Mar 17 23:10:02 2025
    Simplifies ebuild by generating module-info with eclass functionality.

    Switches to dev-java/jna:0 (from dev-java/jna:4)

    Restricted to asm-9 since bytecode 69 starts from Java 25. Also
    restricted to presently stable Java versions because with Java 25,
    there are still too many test failures.

    Closes: https://bugs.gentoo.org/837233
    Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
    ---
    dev-java/byte-buddy/Manifest | 1 +
    dev-java/byte-buddy/byte-buddy-1.17.2.ebuild | 123 +++++++++++++++++++
    2 files changed, 124 insertions(+)
    create mode 100644 dev-java/byte-buddy/byte-buddy-1.17.2.ebuild

    diff --git a/dev-java/byte-buddy/Manifest b/dev-java/byte-buddy/Manifest
    index 450d00e8c659..0ea20d1905ec 100644
    --- a/dev-java/byte-buddy/Manifest
    +++ b/dev-java/byte-buddy/Manifest
    @@ -1 +1,2 @@
    DIST byte-buddy-1.15.11.tar.gz 2059994 BLAKE2B b5b11de938d2b96518c01cf1bcebb0f34ca6ccdb81e519e0177fa371f438da9ca5aba5749d1a7af0f42a2359c55228f3cbfbfe32f158d4a18fe7f02a5d5bf4f2 SHA512
    9e663dfee80e6ae9e4983a39177a94f160e52e3ef1dec54b8f6a90e32c18ae5b36c9e791fd605b43754b2667f6efd7e15a1f7b0ce6c5034945567aef8a6b8aa8
    +DIST byte-buddy-1.17.2.tar.gz 2084935 BLAKE2B b705464bdf1f4b07af21a143729e9098ce398103a0168a4d9146b3fe75671699684f6fdd1203ed48d7dddd5e1c29a2c3b01a6c779c81498a66c30c603c892088 SHA512
    77f53a6829be905d7abaaef1628ed05425be301b3f8762556f1d37ac358a59f0c3a3422bac8729608d9