ascopes commented on code in PR #1030:
URL: 
https://github.com/apache/maven-plugin-tools/pull/1030#discussion_r2649563543


##########
maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java:
##########
@@ -372,7 +373,12 @@ public void generate() throws MojoExecutionException {
             mojoScanner.populatePluginDescriptor(request);
             request.setPluginDescriptor(extendPluginDescriptor(request));
 
-            outputDirectory.mkdirs();
+            if (!outputDirectory.exists()) {

Review Comment:
   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:
   
   ```java
   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
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to