arturobernalg commented on code in PR #283:
URL: 
https://github.com/apache/maven-artifact-plugin/pull/283#discussion_r4480165297


##########
src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java:
##########
@@ -174,29 +174,35 @@ void printArtifacts(MavenProject project) throws 
MojoExecutionException {
         int n = 0;
         Artifact pomArtifact =
                 new DefaultArtifact(project.getGroupId(), 
project.getArtifactId(), null, "pom", project.getVersion());
+        Path consumerPomFile = null;
         if (consumerPom != null) {
             // Maven 4 transient consumer POM attachment is published as the 
POM, overrides build POM, see
             // 
https://github.com/apache/maven/blob/c79a7a02721f0f9fd7e202e99f60b593461ba8cc/maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java#L130-L155
             try {
-                Path pomFile = 
Files.createTempFile(Paths.get(project.getBuild().getDirectory()), "consumer-", 
".pom");
-                Files.copy(consumerPom.getFile().toPath(), pomFile, 
StandardCopyOption.REPLACE_EXISTING);
-                pomArtifact = pomArtifact.setFile(pomFile.toFile());
+                consumerPomFile =
+                        
Files.createTempFile(Paths.get(project.getBuild().getDirectory()), "consumer-", 
".pom");
+                Files.copy(consumerPom.getFile().toPath(), consumerPomFile, 
StandardCopyOption.REPLACE_EXISTING);
+                pomArtifact = pomArtifact.setFile(consumerPomFile.toFile());
             } catch (IOException e) {
-                p.println("Error processing consumer POM: " + e);
+                throw new MojoExecutionException("Error processing consumer 
POM", e);
             }
         } else {
             pomArtifact = pomArtifact.setFile(project.getFile());
         }
 
-        artifacts.put(pomArtifact, prefix + n);
-        if (isIgnore(pomArtifact)) {
-            p.println("# ignored " + getArtifactFilename(pomArtifact));
-        } else {
-            printFile(
-                    prefix + n++,
-                    pomArtifact.getGroupId(),
-                    pomArtifact.getFile(),
-                    project.getArtifactId() + '-' + project.getVersion() + 
".pom");
+        try {

Review Comment:
   Good call. Merged it into one try/catch/finally in 834ef60, matching how 
DescribeBuildOutputMojo already handles the same temp file.



-- 
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