You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2023/05/22 19:30:25 UTC

[GitHub] [maven] gnodet commented on a diff in pull request #1117: [MNG-7740] Remove old temporary consumer*pom files from buildDir

gnodet commented on code in PR #1117:
URL: https://github.com/apache/maven/pull/1117#discussion_r1200954771


##########
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##########
@@ -77,13 +82,29 @@ public void injectTransformedArtifacts(MavenProject project, RepositorySystemSes
                 Files.createDirectories(buildDir);
                 generatedFile = Files.createTempFile(buildDir, CONSUMER_POM_CLASSIFIER, "pom");
             }
+            deferDeleteFile(generatedFile);
             project.addAttachedArtifact(new ConsumerPomArtifact(project, generatedFile, session));
         } else if (project.getModel().isRoot()) {
             throw new IllegalStateException(
                     "The use of the root attribute on the model requires the buildconsumer feature to be active");
         }
     }
 
+    private void deferDeleteFile(Path generatedFile) {
+        toDelete.add(generatedFile.toAbsolutePath().toString());

Review Comment:
   I didn't want to hold references to the objects such as the `FileSystem`, I've modelled it to be in line with the `File#deleteOnExit` implementation of openjdk which was using `String` instead of `File` to keep those. But I don't foresee any real problem keeping references to `Path`, provided that we do use the `toAbsolutePath()`.



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org