diff --git a/pom.xml b/pom.xml index 7ce196867..fbe6deb8f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-javadoc-plugin - 3.10.1 + 3.11.1 maven-plugin Apache Maven Javadoc Plugin @@ -91,7 +91,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git - maven-javadoc-plugin-3.10.1 + maven-javadoc-plugin-3.11.1 https://github.com/apache/maven-javadoc-plugin/tree/${project.scm.tag} @@ -112,22 +112,22 @@ under the License. 8 3.6.3 - 2.0.0-M19 + 2.0.0 3.5.3 1.4.1 - 1.2.0 + 1.3.0 9.4.55.v20240627 4.0.2 - 3.11.0 + 3.13.0 3.3.0 3.4.1 - 3.14.0 + 3.15.0 3.3.0 3.20.0 3.7.0 - 2024-09-26T08:13:55Z + 2024-10-30T16:49:47Z 1.7.36 @@ -201,13 +201,13 @@ under the License. org.apache.maven.reporting maven-reporting-api - 4.0.0-M12 + 4.0.0 org.apache.maven.reporting maven-reporting-impl - 4.0.0-M15 + 4.0.0 provided @@ -228,14 +228,14 @@ under the License. org.apache.maven.shared maven-common-artifact-filters - + 3.4.0 org.apache.maven.doxia doxia-sink-api - 2.0.0-M12 + 2.0.0 diff --git a/src/it/projects/MJAVADOC-437/module2/pom.xml b/src/it/projects/MJAVADOC-437/module2/pom.xml index e07a7aa48..89f521f6a 100644 --- a/src/it/projects/MJAVADOC-437/module2/pom.xml +++ b/src/it/projects/MJAVADOC-437/module2/pom.xml @@ -43,7 +43,7 @@ commons-io commons-io - 2.7 + 2.14.0 diff --git a/src/it/projects/MJAVADOC-787/invoker.properties b/src/it/projects/MJAVADOC-787/invoker.properties new file mode 100644 index 000000000..965ea1bf1 --- /dev/null +++ b/src/it/projects/MJAVADOC-787/invoker.properties @@ -0,0 +1,18 @@ +# 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.toolchain.jdk.version = 1.8 diff --git a/src/it/projects/MJAVADOC-787/pom.xml b/src/it/projects/MJAVADOC-787/pom.xml new file mode 100644 index 000000000..df18867c6 --- /dev/null +++ b/src/it/projects/MJAVADOC-787/pom.xml @@ -0,0 +1,78 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.javadoc.it + mjavadoc787 + 1.0-SNAPSHOT + + https://issues.apache.org/jira/browse/MJAVADOC-787 + + + UTF-8 + + + + + org.apache.commons + commons-lang3 + 3.6 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @compilerPluginVersion@ + + 8 + + 1.8 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + @project.version@ + + + + jar + + + + + 8 + + 1.8 + + + + + + + diff --git a/src/it/projects/MJAVADOC-787/src/main/java/com/foo/MyClass.java b/src/it/projects/MJAVADOC-787/src/main/java/com/foo/MyClass.java new file mode 100644 index 000000000..7370ac086 --- /dev/null +++ b/src/it/projects/MJAVADOC-787/src/main/java/com/foo/MyClass.java @@ -0,0 +1,25 @@ +package com.foo; + +/* + * 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. + */ + +public class MyClass +{ + +} 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 c5d9ce293..5c545aa32 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.Writer; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; @@ -2615,27 +2614,13 @@ public Artifact resolveDependency(Dependency dependency) throws MavenReportExcep } } - // TODO remove the part with ToolchainManager lookup once we depend on - // 3.0.9 (have it as prerequisite). Define as regular component field then. protected final Toolchain getToolchain() { Toolchain tc = null; if (jdkToolchain != null) { - // Maven 3.3.1 has plugin execution scoped Toolchain Support - try { - Method getToolchainsMethod = toolchainManager - .getClass() - .getMethod("getToolchains", MavenSession.class, String.class, Map.class); - - @SuppressWarnings("unchecked") - List tcs = - (List) getToolchainsMethod.invoke(toolchainManager, session, "jdk", jdkToolchain); - - if (tcs != null && tcs.size() > 0) { - tc = tcs.get(0); - } - } catch (SecurityException | ReflectiveOperationException e) { - // ignore + List tcs = toolchainManager.getToolchains(session, "jdk", jdkToolchain); + if (tcs != null && !tcs.isEmpty()) { + tc = tcs.get(0); } } @@ -4625,7 +4610,7 @@ private void addJavadocOptions( addArgIf(arguments, quiet, "-quiet", SINCE_JAVADOC_1_5); } - if (release != null) { + if (javadocRuntimeVersion.isAtLeast("9") && release != null) { arguments.add("--release"); arguments.add(release); } else { diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java index f8ec11629..02a1ff99e 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java @@ -221,23 +221,14 @@ protected String getClassifier() { * @throws IOException {@link IOException} */ private File generateArchive(File javadocFiles, String jarFileName) throws ArchiverException, IOException { - File javadocJar = new File(jarOutputDirectory, jarFileName); - - if (javadocJar.exists()) { - javadocJar.delete(); - } - MavenArchiver archiver = new MavenArchiver(); - archiver.setCreatedBy("Maven Javadoc Plugin", "org.apache.maven.plugins", "maven-javadoc-plugin"); archiver.setArchiver(jarArchiver); - archiver.setOutputFile(javadocJar); + archiver.setCreatedBy("Maven Javadoc Plugin", "org.apache.maven.plugins", "maven-javadoc-plugin"); // configure for Reproducible Builds based on outputTimestamp value archiver.configureReproducibleBuild(outputTimestamp); - if (!javadocFiles.exists()) { - getLog().warn("JAR will be empty - no content was marked for inclusion!"); - } else { + if (javadocFiles.exists()) { archiver.getArchiver().addDirectory(javadocFiles, DEFAULT_INCLUDES, DEFAULT_EXCLUDES); } @@ -254,14 +245,20 @@ private File generateArchive(File javadocFiles, String jarFileName) throws Archi archive.setManifestFile(defaultManifestFile); } + File outputFile = new File(jarOutputDirectory, jarFileName); + + // Why do we do this? + if (outputFile.exists()) { + outputFile.delete(); + } + archiver.setOutputFile(outputFile); + try { archiver.createArchive(session, project, archive); - } catch (ManifestException e) { - throw new ArchiverException("ManifestException: " + e.getMessage(), e); - } catch (DependencyResolutionRequiredException e) { - throw new ArchiverException("DependencyResolutionRequiredException: " + e.getMessage(), e); + } catch (ManifestException | DependencyResolutionRequiredException e) { + throw new ArchiverException("Error creating Javadoc archive: " + e.getMessage(), e); } - return javadocJar; + return outputFile; } }