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 5610ef061..025b8d2a7 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -1936,12 +1936,6 @@ protected void executeReport(Locale unusedLocale) throws MavenReportException { } javadocOutputDirectory.mkdirs(); - // ---------------------------------------------------------------------- - // Copy all resources - // ---------------------------------------------------------------------- - - copyAllResources(javadocOutputDirectory); - // ---------------------------------------------------------------------- // Create command line for Javadoc // ---------------------------------------------------------------------- @@ -4971,12 +4965,17 @@ private void addTagletsFromTagletArtifacts(List arguments) throws MavenR * @throws MavenReportException if any errors occur */ private void executeJavadocCommandLine(Commandline cmd, File javadocOutputDirectory) throws MavenReportException { + // Resources must be copied only when Javadoc is actually (re)generated. copyAllResources removes + // excluded doc-file subdirectories from the output directory; if it ran while generation was skipped + // as up to date, those files would be deleted without being regenerated, leaving the output incomplete. if (staleDataPath != null) { if (!isUpToDate(cmd)) { + copyAllResources(javadocOutputDirectory); doExecuteJavadocCommandLine(cmd, javadocOutputDirectory); StaleHelper.writeStaleData(cmd, staleDataPath.toPath()); } } else { + copyAllResources(javadocOutputDirectory); doExecuteJavadocCommandLine(cmd, javadocOutputDirectory); } }