You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2025/05/29 20:44:36 UTC

(maven-javadoc-plugin) branch master updated: Issue #369 Support --no-fonts option per default for jdk 23+ (#375)

This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 10be81a1 Issue #369 Support --no-fonts option per default for jdk 23+ (#375)
10be81a1 is described below

commit 10be81a1e4466fee4dabfc367b358e3a175b6108
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Fri May 30 06:44:31 2025 +1000

    Issue #369 Support --no-fonts option per default for jdk 23+ (#375)
    
    Signed-off-by: Olivier Lamy <ol...@apache.org>
---
 .../invoker.properties                                | 19 +++++++++++++++++++
 .../pom.xml                                           |  5 +++--
 .../src/main/java/com/foo/MyClass.java}               | 16 +++++++++-------
 .../verify.groovy                                     |  2 ++
 .../projects/MJAVADOC-450_classifier-jdk-23/pom.xml   |  2 ++
 .../MJAVADOC-450_classifier-jdk-23/verify.groovy      |  3 +++
 src/it/projects/MJAVADOC-450_classifier/pom.xml       |  1 +
 .../maven/plugins/javadoc/AbstractJavadocMojo.java    | 14 ++++++++++++++
 8 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/invoker.properties b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/invoker.properties
new file mode 100644
index 00000000..e65ebddd
--- /dev/null
+++ b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/invoker.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.goals=javadoc:javadoc
+invoker.java.version = 22+
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/pom.xml
similarity index 93%
copy from src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml
copy to src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/pom.xml
index 799e970c..2416f18e 100644
--- a/src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml
+++ b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/pom.xml
@@ -23,10 +23,10 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
-  <artifactId>mjavadoc450-jdk-23</artifactId>
+  <artifactId>mjavadoc450-jdk-23-no-fonts</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   
-  <url>https://issues.apache.org/jira/browse/MJAVADOC-450</url>
+  <url>https://github.com/apache/maven-javadoc-plugin/issues/369</url>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -42,6 +42,7 @@
           <artifactId>maven-javadoc-plugin</artifactId>
           <version>@project.version@</version>
           <configuration>
+            <debug>true</debug>
             <stylesheetfile>custom.css</stylesheetfile>
           </configuration>
           <dependencies>
diff --git a/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/src/main/java/com/foo/MyClass.java
similarity index 73%
copy from src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
copy to src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/src/main/java/com/foo/MyClass.java
index 321fe1d1..385265d9 100644
--- a/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
+++ b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/src/main/java/com/foo/MyClass.java
@@ -1,3 +1,5 @@
+package com.foo;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -6,9 +8,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
+ * 
  *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,9 +18,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
-def buildLog = new File( basedir, 'build.log' );
-assert buildLog.text.contains('custom.css found in javadoc plugin dependencies')
 
-def stylesheetCss = new File( basedir, 'target/reports/apidocs/resource-files/stylesheet.css' );
-assert stylesheetCss.text.containsIgnoreCase('dejavu')
+import java.util.Arrays;
+
+public class MyClass
+{
+}
diff --git a/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/verify.groovy
similarity index 91%
copy from src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
copy to src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/verify.groovy
index 321fe1d1..1fd991c8 100644
--- a/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
+++ b/src/it/projects/MJAVADOC-450_classifier-jdk-23-no-fonts/verify.groovy
@@ -22,3 +22,5 @@ assert buildLog.text.contains('custom.css found in javadoc plugin dependencies')
 
 def stylesheetCss = new File( basedir, 'target/reports/apidocs/resource-files/stylesheet.css' );
 assert stylesheetCss.text.containsIgnoreCase('dejavu')
+
+assert !(new File( basedir, 'target/reports/apidocs/resource-files/fonts/dejavu.css'  ).exists());
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml b/src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml
index 799e970c..cc4ef9cb 100644
--- a/src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml
+++ b/src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml
@@ -42,6 +42,8 @@
           <artifactId>maven-javadoc-plugin</artifactId>
           <version>@project.version@</version>
           <configuration>
+            <debug>true</debug>
+            <disableNoFonts>true</disableNoFonts>
             <stylesheetfile>custom.css</stylesheetfile>
           </configuration>
           <dependencies>
diff --git a/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy b/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
index 321fe1d1..233f21fb 100644
--- a/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
+++ b/src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy
@@ -22,3 +22,6 @@ assert buildLog.text.contains('custom.css found in javadoc plugin dependencies')
 
 def stylesheetCss = new File( basedir, 'target/reports/apidocs/resource-files/stylesheet.css' );
 assert stylesheetCss.text.containsIgnoreCase('dejavu')
+
+
+assert new File( basedir, 'target/reports/apidocs/resource-files/fonts/dejavu.css' ).exists();
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-450_classifier/pom.xml b/src/it/projects/MJAVADOC-450_classifier/pom.xml
index c0f324e0..90e9d088 100644
--- a/src/it/projects/MJAVADOC-450_classifier/pom.xml
+++ b/src/it/projects/MJAVADOC-450_classifier/pom.xml
@@ -42,6 +42,7 @@
           <artifactId>maven-javadoc-plugin</artifactId>
           <version>@project.version@</version>
           <configuration>
+            <debug>true</debug>
             <stylesheetfile>custom.css</stylesheetfile>
           </configuration>
           <dependencies>
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index a6526ab3..d3d2b42d 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -1697,6 +1697,16 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
     @Parameter(property = "forceRootLocale", defaultValue = "true")
     private boolean forceRootLocale;
 
+    /**
+     * From jdk 23, javadoc now include some extra css, files which can increase the size of javadoc jar.
+     * This can be disabled using the option {@code --no-fonts}
+     * The javadoc plugin will add this option to diable extra files to be added per default.
+     * If you prefer the new font you must set to {@code true} the option {@code disableNoFonts}
+     * @since 3.11.3
+     */
+    @Parameter(property = "maven.javadoc.disableNoFonts", defaultValue = "false")
+    private boolean disableNoFonts;
+
     // ----------------------------------------------------------------------
     // protected methods
     // ----------------------------------------------------------------------
@@ -2018,6 +2028,10 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
         // ----------------------------------------------------------------------
         List<String> javadocArguments = new ArrayList<>();
 
+        if (JavaVersion.JAVA_VERSION.isAtLeast("23") && !disableNoFonts) {
+            javadocArguments.add("--no-fonts");
+        }
+
         addJavadocOptions(javadocOutputDirectory, javadocArguments, sourcePaths, offlineLinks);
 
         // ----------------------------------------------------------------------