Skip to content

Commit

Permalink
[MJAVADOC-812] [REGRESSION] maven-javadoc-plugin 3.10.0 creates empty…
Browse files Browse the repository at this point in the history
… JARs

This closes #320
  • Loading branch information
michael-o committed Sep 21, 2024
1 parent ff52cff commit fdb3b17
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,28 @@ protected void doExecute() throws MojoExecutionException {
failOnError("RuntimeException: Error while generating Javadoc", e);
}

try {
File outputFile = generateArchive(
new File(getPluginReportOutputDirectory()), finalName + "-" + getClassifier() + ".jar");

if (!attach) {
getLog().info("NOT adding javadoc to attached artifacts list.");
} else {
// TODO: these introduced dependencies on the project are going to become problematic - can we
// export it
// through metadata instead?
projectHelper.attachArtifact(project, "javadoc", getClassifier(), outputFile);
File javadocOutputDirectory = new File(getPluginReportOutputDirectory());
if (javadocOutputDirectory.exists()) {
try {
File outputFile = generateArchive(javadocOutputDirectory, finalName + "-" + getClassifier() + ".jar");

if (!attach) {
getLog().info("NOT adding javadoc to attached artifacts list.");
} else {
// TODO: these introduced dependencies on the project are going to become problematic - can we
// export it
// through metadata instead?
projectHelper.attachArtifact(project, "javadoc", getClassifier(), outputFile);
}
} catch (ArchiverException e) {
failOnError("ArchiverException: Error while creating archive", e);
} catch (IOException e) {
failOnError("IOException: Error while creating archive", e);
} catch (RuntimeException e) {
failOnError("RuntimeException: Error while creating archive", e);
}
} catch (ArchiverException e) {
failOnError("ArchiverException: Error while creating archive", e);
} catch (IOException e) {
failOnError("IOException: Error while creating archive", e);
} catch (RuntimeException e) {
failOnError("RuntimeException: Error while creating archive", e);
} else {
getLog().info("No Javadoc in project. Archive not created.");
}
}

Expand Down

0 comments on commit fdb3b17

Please sign in to comment.