Skip to content

Commit 3ca7ae3

Browse files
committed
restore
Signed-off-by: Olivier Lamy <[email protected]>
1 parent e058360 commit 3ca7ae3

File tree

1 file changed

+48
-51
lines changed

1 file changed

+48
-51
lines changed

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

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter;
101101
import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter;
102102
import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
103+
import org.apache.maven.shared.invoker.MavenInvocationException;
103104
import org.apache.maven.toolchain.Toolchain;
104105
import org.apache.maven.toolchain.ToolchainManager;
105106
import org.apache.maven.wagon.PathUtils;
@@ -5363,57 +5364,53 @@ private List<OfflineLink> getModulesLinks() throws MavenReportException {
53635364

53645365
File location = new File(p.getBasedir(), javadocDirRelative);
53655366

5366-
// if (!location.exists()) {
5367-
// String javadocGoal = getFullJavadocGoal();
5368-
// if (getLog().isDebugEnabled()) {
5369-
// getLog().debug("Javadoc directory not found: " + location);
5370-
// getLog().debug("The goal '" + javadocGoal + "' has not been previously called for the
5371-
// module: '"
5372-
// + p.getId() + "'. Trying to invoke it...");
5373-
// }
5374-
//
5375-
// File invokerDir = new File(project.getBuild().getDirectory(), "invoker");
5376-
// invokerDir.mkdirs();
5377-
// File invokerLogFile = FileUtils.createTempFile("maven-javadoc-plugin", ".txt",
5378-
// invokerDir);
5379-
// try {
5380-
// JavadocUtil.invokeMaven(
5381-
// getLog(),
5382-
// session.getRepositorySession().getLocalRepository().getBasedir(),
5383-
// p.getFile(),
5384-
// Collections.singletonList(javadocGoal),
5385-
// null,
5386-
// invokerLogFile,
5387-
// session.getRequest().getGlobalSettingsFile(),
5388-
// session.getRequest().getUserSettingsFile(),
5389-
// session.getRequest().getGlobalToolchainsFile(),
5390-
// session.getRequest().getUserToolchainsFile());
5391-
// } catch (MavenInvocationException e) {
5392-
// logError("MavenInvocationException: " + e.getMessage(), e);
5393-
//
5394-
// try {
5395-
// String invokerLogContent =
5396-
// new String(Files.readAllBytes(invokerLogFile.toPath()),
5397-
// StandardCharsets.UTF_8);
5398-
// // TODO: Why are we only interested in cases where the JVM won't start?
5399-
// // probably we should throw an error in all cases
5400-
// // [MJAVADOC-275][jdcasey] I changed the logic here to only throw an error WHEN
5401-
// // the JVM won't start (opposite of what it was).
5402-
// if (invokerLogContent.contains(JavadocUtil.ERROR_INIT_VM)) {
5403-
// throw new MavenReportException(e.getMessage(), e);
5404-
// }
5405-
// } catch (IOException ex) {
5406-
// // ignore
5407-
// }
5408-
// } finally {
5409-
// // just create the directory to prevent repeated invocations.
5410-
// if (!location.exists()) {
5411-
// getLog().warn("Creating fake javadoc directory to prevent repeated invocations: "
5412-
// + location);
5413-
// location.mkdirs();
5414-
// }
5415-
// }
5416-
// }
5367+
if (!location.exists()) {
5368+
String javadocGoal = getFullJavadocGoal();
5369+
if (getLog().isDebugEnabled()) {
5370+
getLog().debug("Javadoc directory not found: " + location);
5371+
getLog().debug("The goal '" + javadocGoal + "' has not been previously called for the module: '"
5372+
+ p.getId() + "'. Trying to invoke it...");
5373+
}
5374+
5375+
File invokerDir = new File(project.getBuild().getDirectory(), "invoker");
5376+
invokerDir.mkdirs();
5377+
File invokerLogFile = FileUtils.createTempFile("maven-javadoc-plugin", ".txt", invokerDir);
5378+
try {
5379+
JavadocUtil.invokeMaven(
5380+
getLog(),
5381+
session.getRepositorySession().getLocalRepository().getBasedir(),
5382+
p.getFile(),
5383+
Collections.singletonList(javadocGoal),
5384+
null,
5385+
invokerLogFile,
5386+
session.getRequest().getGlobalSettingsFile(),
5387+
session.getRequest().getUserSettingsFile(),
5388+
session.getRequest().getGlobalToolchainsFile(),
5389+
session.getRequest().getUserToolchainsFile());
5390+
} catch (MavenInvocationException e) {
5391+
logError("MavenInvocationException: " + e.getMessage(), e);
5392+
5393+
try {
5394+
String invokerLogContent =
5395+
new String(Files.readAllBytes(invokerLogFile.toPath()), StandardCharsets.UTF_8);
5396+
// TODO: Why are we only interested in cases where the JVM won't start?
5397+
// probably we should throw an error in all cases
5398+
// [MJAVADOC-275][jdcasey] I changed the logic here to only throw an error WHEN
5399+
// the JVM won't start (opposite of what it was).
5400+
if (invokerLogContent.contains(JavadocUtil.ERROR_INIT_VM)) {
5401+
throw new MavenReportException(e.getMessage(), e);
5402+
}
5403+
} catch (IOException ex) {
5404+
// ignore
5405+
}
5406+
} finally {
5407+
// just create the directory to prevent repeated invocations.
5408+
if (!location.exists()) {
5409+
getLog().warn("Creating fake javadoc directory to prevent repeated invocations: " + location);
5410+
location.mkdirs();
5411+
}
5412+
}
5413+
}
54175414

54185415
if (location.exists()) {
54195416
String url = getJavadocLink(p);

0 commit comments

Comments
 (0)