Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1618,8 +1618,10 @@ public AbstractJavadocMojo(
* This is used to skip the generation if nothing has changed.
* </p>
*
* @deprecated this mechanism was broken and has been removed
* @since 3.2.0
*/
@Deprecated
@Parameter(
property = "staleDataPath",
defaultValue = "${project.build.directory}/maven-javadoc-plugin-stale-data.txt")
Expand Down Expand Up @@ -4971,70 +4973,6 @@ private void addTagletsFromTagletArtifacts(List<String> arguments) throws MavenR
* @throws MavenReportException if any errors occur
*/
private void executeJavadocCommandLine(Commandline cmd, File javadocOutputDirectory) throws MavenReportException {
if (staleDataPath != null) {
if (!isUpToDate(cmd)) {
doExecuteJavadocCommandLine(cmd, javadocOutputDirectory);
StaleHelper.writeStaleData(cmd, staleDataPath.toPath());
}
} else {
doExecuteJavadocCommandLine(cmd, javadocOutputDirectory);
}
}

/**
* Check if the javadoc is uptodate or not
*
* @param cmd not null
* @return <code>true</code> is the javadoc is uptodate, <code>false</code> otherwise
* @throws MavenReportException if any error occur
*/
private boolean isUpToDate(Commandline cmd) throws MavenReportException {
try {
List<String> curdata = StaleHelper.getStaleData(cmd);
Path cacheData = staleDataPath.toPath();
List<String> prvdata;
if (Files.isRegularFile(cacheData)) {
prvdata = Files.lines(cacheData, EncodingUtils.getExpectedEncoding())
.collect(Collectors.toList());
} else {
prvdata = null;
}
if (curdata.equals(prvdata)) {
getLog().debug("Skipping javadoc generation, everything is up to date.");
return true;
} else {
if (prvdata == null) {
getLog().debug("No previous run data found, generating javadoc.");
} else {
getLog().debug("Configuration changed, re-generating javadoc.");
if (getLog().isDebugEnabled()) {
List<String> newStrings = new ArrayList<>(curdata);
List<String> remStrings = new ArrayList<>(prvdata);
newStrings.removeAll(prvdata);
remStrings.removeAll(curdata);
if (!remStrings.isEmpty()) {
getLog().debug(" Removed: " + String.join(", ", remStrings));
}
if (!newStrings.isEmpty()) {
getLog().debug(" Added: " + String.join(", ", newStrings));
}
}
}
}
} catch (IOException e) {
throw new MavenReportException("Error checking uptodate status", e);
}
return false;
}

/**
* Execute the Javadoc command line
*
* @param cmd not null
* @param javadocOutputDirectory not null
* @throws MavenReportException if any errors occur
*/
private void doExecuteJavadocCommandLine(Commandline cmd, File javadocOutputDirectory) throws MavenReportException {
if (getLog().isDebugEnabled()) {
// no quoted arguments
getLog().debug(CommandLineUtils.toString(cmd.getCommandline()).replaceAll("'", ""));
Expand Down
142 changes: 0 additions & 142 deletions src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.verify;

/**
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
Expand Down Expand Up @@ -175,20 +173,4 @@ void testIncludeMavenDescriptorWhenExplicitlyConfigured(JavadocJarMojo mojo) thr
"META-INF/maven/org.apache.maven.plugins.maven-javadoc-plugin.unit/javadocjar-archive-config/pom.xml",
"META-INF/maven/org.apache.maven.plugins.maven-javadoc-plugin.unit/javadocjar-archive-config/pom.properties");
}

@Test
@InjectMojo(goal = "jar", pom = "stale-test-plugin-config.xml")
@Basedir("/unit/stale-test")
void testStale(JavadocJarMojo mojo) throws Exception {

new File(getBasedir(), "/target/maven-javadoc-plugin-stale-data.txt").delete();

mojo.execute();
verify(log).debug("No previous run data found, generating javadoc.");

clearInvocations(log);

mojo.execute();
verify(log).debug("Skipping javadoc generation, everything is up to date.");
}
}
31 changes: 0 additions & 31 deletions src/test/resources/unit/stale-test/src/main/java/maven/App.java

This file was deleted.

54 changes: 0 additions & 54 deletions src/test/resources/unit/stale-test/stale-test-plugin-config.xml

This file was deleted.