From 93877645ee12392e413d552cc749e05292f79a69 Mon Sep 17 00:00:00 2001 From: Delany Date: Tue, 21 Jul 2026 15:38:03 +0200 Subject: [PATCH] Fix incremental build losing output under excludedocfilessubdir When docfilessubdirs is enabled together with excludedocfilessubdir, an incremental build (re-run without a clean) could leave the excluded subdirectory's generated files missing from the output. copyAllResources() removes the excluded doc-file subdirectories from the output directory before Javadoc runs, relying on Javadoc to regenerate them. However, the staleDataPath up-to-date check (enabled by default) skips the Javadoc invocation when the command line is unchanged, so on a second run the files were deleted but never regenerated. Move the copyAllResources() call so it runs only when Javadoc is actually (re)generated. When the output is up to date, generation and resource copying are both skipped and the previous output is left intact. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../maven/plugins/javadoc/AbstractJavadocMojo.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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); } }