Bug#1040374: maven-javadoc-plugin: Please support Java 21

Vladimir Petko vladimir.petko at canonical.com
Wed Jul 5 07:30:53 BST 2023


Package: maven-javadoc-plugin
Severity: wishlist
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu mantic ubuntu-patch
X-Debbugs-Cc: vladimir.petko at canonical.com

Dear Maintainer,

Java 21 no longer supports release level 7. The attached patch updates auto-
adjust-language-level.patch to use release level 8 for Java 21 and keeps the
release level 7 otherwise.

Changes:
  * d/p/auto-adjust-language-level.patch: use release 8 for Java 21.

Thanks for considering the patch.


-- System Information:
Debian Release: bookworm/sid
  APT prefers lunar-updates
  APT policy: (500, 'lunar-updates'), (500, 'lunar-security'), (500, 'lunar'), (100, 'lunar-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.2.0-24-generic (SMP w/32 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
-------------- next part --------------
diff -Nru maven-javadoc-plugin-3.4.1/debian/patches/auto-adjust-language-level.patch maven-javadoc-plugin-3.4.1/debian/patches/auto-adjust-language-level.patch
--- maven-javadoc-plugin-3.4.1/debian/patches/auto-adjust-language-level.patch	2023-01-16 21:27:53.000000000 +1300
+++ maven-javadoc-plugin-3.4.1/debian/patches/auto-adjust-language-level.patch	2023-07-05 16:35:05.000000000 +1200
@@ -3,20 +3,44 @@
 Forwarded: not-needed
 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
 +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
-@@ -158,6 +158,8 @@
+@@ -158,6 +158,32 @@
  public abstract class AbstractJavadocMojo
      extends AbstractMojo
  {
-+    private List<String> unsupportedLanguageLevels = java.util.Arrays.asList(new String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5", "1.6", "6"});
++    private List<String> unsupportedLanguageLevels = getUnsupportedLanguageLevels();
++
++    private static List<String> getUnsupportedLanguageLevels() {
++         if ( isAtLeastJava21() ) {
++            return java.util.Arrays.asList( new String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5", "1.6", "6", "1.7", "7"} );
++         }
++         return java.util.Arrays.asList( new String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5", "1.6", "6"} );
++    }
++
++    private static boolean isAtLeastJava21()
++    {
++        try
++        {
++            return Integer.parseInt( System.getProperty( "java.specification.version" ) ) >= 21;
++        }
++        catch ( Exception e )
++        {
++            return false;
++        }
++    }
++
++    private String getMinRelease()
++    {
++        return isAtLeastJava21() ? "8" : "7";
++    }
 +
      /**
       * Classifier used in the name of the javadoc-options XML file, and in the resources bundle
       * artifact that gets attached to the project. This one is used for non-test javadocs.
-@@ -2028,6 +2030,19 @@
+@@ -2028,6 +2054,19 @@
      public void execute()
          throws MojoExecutionException, MojoFailureException
      {
-+	String defaultLevel = "7";
++	    String defaultLevel = getMinRelease();
 +        if ( unsupportedLanguageLevels.contains( release ) )
 +        {
 +            System.err.println( "Use of release " + release + " is no longer supported, switching to " + defaultLevel );


More information about the pkg-java-maintainers mailing list