Skip to content

Commit 26ddc2f

Browse files
authored
Issue #373 Fix JDK 23 build (#374)
* Fix build with jdk23 Signed-off-by: Olivier Lamy <[email protected]>
1 parent ca7a770 commit 26ddc2f

File tree

9 files changed

+165
-9
lines changed

9 files changed

+165
-9
lines changed

.github/workflows/maven.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ jobs:
2727
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
2828
with:
2929
jdk-distribution-matrix: '[ "temurin", "zulu", "microsoft", "liberica", "adopt-openj9" ]'
30+
jdk-matrix: '[ "17", "21", "8", "23" ]'
3031
matrix-exclude: '[
3132
{ "jdk": "8", "distribution": "microsoft"},
3233
{ "jdk": "8", "distribution": "temurin", "os": "macos-latest" },
33-
{ "jdk": "8", "distribution": "adopt-openj9", "os": "macos-latest" }
34+
{ "jdk": "8", "distribution": "adopt-openj9", "os": "macos-latest" },
35+
{ "jdk": "23", "distribution": "adopt-openj9" },
36+
{ "jdk": "23", "distribution": "microsoft"},
3437
]'
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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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</artifactId>
27+
<version>1.0.0-SNAPSHOT</version>
28+
29+
<url>https://issues.apache.org/jira/browse/MJAVADOC-450</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+
<stylesheetfile>custom.css</stylesheetfile>
46+
</configuration>
47+
<dependencies>
48+
<dependency>
49+
<groupId>org.apache.maven.plugins.javadoc.its</groupId>
50+
<artifactId>mjavadoc450</artifactId>
51+
<version>1.0</version>
52+
<classifier>static</classifier>
53+
</dependency>
54+
</dependencies>
55+
</plugin>
56+
</plugins>
57+
</pluginManagement>
58+
</build>
59+
60+
</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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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')

src/it/projects/MJAVADOC-450_classifier/invoker.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
# under the License.
1717

1818
invoker.goals=javadoc:javadoc
19+
invoker.java.version = 23-

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2774,7 +2774,10 @@ private Optional<File> getStylesheetFile(final File javadocOutputDirectory) {
27742774
if (new File(stylesheetfile).exists()) {
27752775
return Optional.of(new File(stylesheetfile));
27762776
}
2777-
2777+
if (JavaVersion.JAVA_VERSION.isAtLeast("23")) {
2778+
return getResource(
2779+
new File(new File(javadocOutputDirectory, "resource-files"), DEFAULT_CSS_NAME), stylesheetfile);
2780+
}
27782781
return getResource(new File(javadocOutputDirectory, DEFAULT_CSS_NAME), stylesheetfile);
27792782
}
27802783

src/test/java/org/apache/maven/plugins/javadoc/JavadocJarMojoTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ public void testDefaultConfig() throws Exception {
9595
set.add(entry.getName());
9696
}
9797
}
98-
99-
assertTrue(set.contains("stylesheet.css"));
98+
if (JavaVersion.JAVA_VERSION.isAtLeast("23")) {
99+
assertTrue(set.contains("resource-files/stylesheet.css"));
100+
} else {
101+
assertTrue(set.contains("stylesheet.css"));
102+
}
100103
JavaVersion javadocVersion = (JavaVersion) getVariableValueFromObject(mojo, "javadocRuntimeVersion");
101104
if (javadocVersion.isBefore("1.7")) {
102105
assertTrue(set.contains("resources/inherit.gif"));

src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,12 @@ public void testDefaultConfiguration() throws Exception {
315315
assertThat(apidocs.resolve("index-all.html")).exists();
316316
assertThat(apidocs.resolve("index.html")).exists();
317317
assertThat(apidocs.resolve("overview-tree.html")).exists();
318-
assertThat(apidocs.resolve("stylesheet.css")).exists();
318+
if (JavaVersion.JAVA_VERSION.isAtLeast("23")) {
319+
assertThat(apidocs.resolve("resource-files/stylesheet.css")).exists();
320+
} else {
321+
322+
assertThat(apidocs.resolve("stylesheet.css")).exists();
323+
}
319324

320325
if (JavaVersion.JAVA_VERSION.isAtLeast("10")) {
321326
assertThat(apidocs.resolve("element-list")).exists();
@@ -556,7 +561,11 @@ public void testQuotedPath() throws Exception {
556561
assertThat(apidocs.resolve("index-all.html")).exists();
557562
assertThat(apidocs.resolve("index.html")).exists();
558563
assertThat(apidocs.resolve("overview-tree.html")).exists();
559-
assertThat(apidocs.resolve("stylesheet.css")).exists();
564+
if (JavaVersion.JAVA_VERSION.isAtLeast("23")) {
565+
assertThat(apidocs.resolve("resource-files/stylesheet.css")).exists();
566+
} else {
567+
assertThat(apidocs.resolve("stylesheet.css")).exists();
568+
}
560569

561570
if (JavaVersion.JAVA_VERSION.isBefore("10")) {
562571
assertThat(apidocs.resolve("package-list")).exists();
@@ -602,7 +611,11 @@ public void testOptionsUmlautEncoding() throws Exception {
602611
assertThat(apidocs.resolve("index-all.html")).exists();
603612
assertThat(apidocs.resolve("index.html")).exists();
604613
assertThat(apidocs.resolve("overview-tree.html")).exists();
605-
assertThat(apidocs.resolve("stylesheet.css")).exists();
614+
if (JavaVersion.JAVA_VERSION.isAtLeast("23")) {
615+
assertThat(apidocs.resolve("resource-files/stylesheet.css")).exists();
616+
} else {
617+
assertThat(apidocs.resolve("stylesheet.css")).exists();
618+
}
606619

607620
if (JavaVersion.JAVA_VERSION.isBefore("10")) {
608621
assertThat(apidocs.resolve("package-list")).exists();
@@ -1140,6 +1153,9 @@ public void testStylesheetfile() throws Exception {
11401153
Path apidocs = new File(getBasedir(), "target/test/unit/stylesheetfile-test/target/site/apidocs").toPath();
11411154

11421155
Path stylesheetfile = apidocs.resolve("stylesheet.css");
1156+
if (JavaVersion.JAVA_VERSION.isAtLeast("23")) {
1157+
stylesheetfile = apidocs.resolve("resource-files/stylesheet.css");
1158+
}
11431159
Path options = apidocs.resolve("options");
11441160

11451161
// stylesheet == maven OR java
@@ -1191,8 +1207,9 @@ public void testStylesheetfile() throws Exception {
11911207

11921208
optionsContent = readFile(options);
11931209
assertTrue(optionsContent.contains("-stylesheetfile"));
1194-
assertTrue(optionsContent.contains(
1195-
"'" + stylesheetfile.toFile().getAbsolutePath().replaceAll("\\\\", "/") + "'"));
1210+
1211+
assertThat(optionsContent)
1212+
.contains("'" + stylesheetfile.toFile().getAbsolutePath().replaceAll("\\\\", "/") + "'");
11961213

11971214
// stylesheetfile defined as file
11981215
Path css = unit.resolve("stylesheetfile-test/src/main/resources/com/mycompany/app/javadoc/css3/stylesheet.css");

0 commit comments

Comments
 (0)