Skip to content

Commit 10be81a

Browse files
authored
Issue #369 Support --no-fonts option per default for jdk 23+ (#375)
Signed-off-by: Olivier Lamy <[email protected]>
1 parent 28ab2ac commit 10be81a

File tree

8 files changed

+152
-0
lines changed

8 files changed

+152
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals=javadoc:javadoc
19+
invoker.java.version = 22+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
26+
<artifactId>mjavadoc450-jdk-23-no-fonts</artifactId>
27+
<version>1.0.0-SNAPSHOT</version>
28+
29+
<url>https://github.com/apache/maven-javadoc-plugin/issues/369</url>
30+
31+
<properties>
32+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33+
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
34+
<maven.compiler.target>@maven.compiler.target@</maven.compiler.target>
35+
</properties>
36+
37+
<build>
38+
<pluginManagement>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-javadoc-plugin</artifactId>
43+
<version>@project.version@</version>
44+
<configuration>
45+
<debug>true</debug>
46+
<stylesheetfile>custom.css</stylesheetfile>
47+
</configuration>
48+
<dependencies>
49+
<dependency>
50+
<groupId>org.apache.maven.plugins.javadoc.its</groupId>
51+
<artifactId>mjavadoc450</artifactId>
52+
<version>1.0</version>
53+
<classifier>static</classifier>
54+
</dependency>
55+
</dependencies>
56+
</plugin>
57+
</plugins>
58+
</pluginManagement>
59+
</build>
60+
61+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.foo;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import java.util.Arrays;
23+
24+
public class MyClass
25+
{
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
def buildLog = new File( basedir, 'build.log' );
21+
assert buildLog.text.contains('custom.css found in javadoc plugin dependencies')
22+
23+
def stylesheetCss = new File( basedir, 'target/reports/apidocs/resource-files/stylesheet.css' );
24+
assert stylesheetCss.text.containsIgnoreCase('dejavu')
25+
26+
assert !(new File( basedir, 'target/reports/apidocs/resource-files/fonts/dejavu.css' ).exists());

src/it/projects/MJAVADOC-450_classifier-jdk-23/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<artifactId>maven-javadoc-plugin</artifactId>
4343
<version>@project.version@</version>
4444
<configuration>
45+
<debug>true</debug>
46+
<disableNoFonts>true</disableNoFonts>
4547
<stylesheetfile>custom.css</stylesheetfile>
4648
</configuration>
4749
<dependencies>

src/it/projects/MJAVADOC-450_classifier-jdk-23/verify.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ assert buildLog.text.contains('custom.css found in javadoc plugin dependencies')
2222

2323
def stylesheetCss = new File( basedir, 'target/reports/apidocs/resource-files/stylesheet.css' );
2424
assert stylesheetCss.text.containsIgnoreCase('dejavu')
25+
26+
27+
assert new File( basedir, 'target/reports/apidocs/resource-files/fonts/dejavu.css' ).exists();

src/it/projects/MJAVADOC-450_classifier/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<artifactId>maven-javadoc-plugin</artifactId>
4343
<version>@project.version@</version>
4444
<configuration>
45+
<debug>true</debug>
4546
<stylesheetfile>custom.css</stylesheetfile>
4647
</configuration>
4748
<dependencies>

src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,16 @@ public AbstractJavadocMojo(
16971697
@Parameter(property = "forceRootLocale", defaultValue = "true")
16981698
private boolean forceRootLocale;
16991699

1700+
/**
1701+
* From jdk 23, javadoc now include some extra css, files which can increase the size of javadoc jar.
1702+
* This can be disabled using the option {@code --no-fonts}
1703+
* The javadoc plugin will add this option to diable extra files to be added per default.
1704+
* If you prefer the new font you must set to {@code true} the option {@code disableNoFonts}
1705+
* @since 3.11.3
1706+
*/
1707+
@Parameter(property = "maven.javadoc.disableNoFonts", defaultValue = "false")
1708+
private boolean disableNoFonts;
1709+
17001710
// ----------------------------------------------------------------------
17011711
// protected methods
17021712
// ----------------------------------------------------------------------
@@ -2018,6 +2028,10 @@ protected void executeReport(Locale unusedLocale) throws MavenReportException {
20182028
// ----------------------------------------------------------------------
20192029
List<String> javadocArguments = new ArrayList<>();
20202030

2031+
if (JavaVersion.JAVA_VERSION.isAtLeast("23") && !disableNoFonts) {
2032+
javadocArguments.add("--no-fonts");
2033+
}
2034+
20212035
addJavadocOptions(javadocOutputDirectory, javadocArguments, sourcePaths, offlineLinks);
20222036

20232037
// ----------------------------------------------------------------------

0 commit comments

Comments
 (0)