Skip to content
Open
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 @@ -29,6 +29,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -196,7 +197,7 @@ public class DescriptorGeneratorMojo extends AbstractGeneratorMojo {
* @since 3.5
*/
@Parameter
private List<String> mojoDependencies = null;
private final List<String> mojoDependencies = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can not be a final ... Maven need a possibility to set this filed during plugin configuration


/**
* Creates links to existing external javadoc-generated documentation.
Expand Down Expand Up @@ -372,7 +373,12 @@ public void generate() throws MojoExecutionException {
mojoScanner.populatePluginDescriptor(request);
request.setPluginDescriptor(extendPluginDescriptor(request));

outputDirectory.mkdirs();
if (!outputDirectory.exists()) {
Copy link

@ascopes ascopes Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createDirectories-java.nio.file.Path-java.nio.file.attribute.FileAttribute be more sensible to use here? It handles the case that the directory already exists, throwing appropriate exceptions for any other kinds of issue, so will likely be more descriptive than handling this manually. There is use of java.nio.file.Path further down this file as well, so the NIO API appears to already be in use.

I believe the whole snippet here would just become:

Files.createDirectories(outputDirectory.toPath());

In Maven 4, I believe the outputDirectories parameter could itself be replaced with a java.nio.file.Path, since the latest version of Sisu supports both the URI and nio Path APIs out of the box... that'd remove the need to convert back from the old APIs at all.

https://github.com/eclipse-sisu/sisu-project/blob/e86e5005ff03b57aab8c7eb7f54f41e85914e2dd/org.eclipse.sisu.plexus/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/PathConverter.java#L33

if (!outputDirectory.mkdirs()) {
throw new MojoExecutionException(
"Could not create output directory: " + outputDirectory.getAbsolutePath());
}
}

PluginDescriptorFilesGenerator pluginDescriptorGenerator = new PluginDescriptorFilesGenerator();
pluginDescriptorGenerator.execute(outputDirectory, request);
Expand Down Expand Up @@ -459,7 +465,7 @@ public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
w.write(content);
}
}
} catch (Exception e) {
} catch (IOException e) {
throw new GeneratorException("Unable to generate index for v4 beans", e);
}
}
Expand Down