[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-06-05 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17729244#comment-17729244
 ] 

ASF GitHub Bot commented on MNG-7740:
-

gnodet merged PR #1117:
URL: https://github.com/apache/maven/pull/1117




> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Assignee: Guillaume Nodet
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725098#comment-17725098
 ] 

ASF GitHub Bot commented on MNG-7740:
-

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`. But I don't foresee any 
real problem keeping references to `Path`, provided that we do use the 
`toAbsolutePath()`.





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725092#comment-17725092
 ] 

ASF GitHub Bot commented on MNG-7740:
-

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()`.





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725086#comment-17725086
 ] 

ASF GitHub Bot commented on MNG-7740:
-

michael-o commented on code in PR #1117:
URL: https://github.com/apache/maven/pull/1117#discussion_r1200938258


##
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:
   Why not retain `Path`?





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725085#comment-17725085
 ] 

ASF GitHub Bot commented on MNG-7740:
-

gnodet closed pull request #1105: [MNG-7740] Remove old temporary consumer*pom 
files from buildDir
URL: https://github.com/apache/maven/pull/1105




> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725084#comment-17725084
 ] 

ASF GitHub Bot commented on MNG-7740:
-

gnodet commented on PR #1105:
URL: https://github.com/apache/maven/pull/1105#issuecomment-1557791393

   Closing this PR in favour of #1117 




> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725082#comment-17725082
 ] 

ASF GitHub Bot commented on MNG-7740:
-

gnodet opened a new pull request, #1117:
URL: https://github.com/apache/maven/pull/1117

   Supersedes #1105 




> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725081#comment-17725081
 ] 

ASF GitHub Bot commented on MNG-7740:
-

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


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");
 }
+
+removeOldConsumerPomFiles(generatedFile);

Review Comment:
   > > @Giovds have a look at 
[gnodet@11009e9](https://github.com/gnodet/maven/commit/11009e9f6921657e31384bd9838d5ab1edb1aacc),
 could you double check that it works for you ?
   > 
   > Cool, TIL! Just verified it and it does work for me. The files are cleaned 
up.
   > 
   > Do note that the final result means there will be no consumer*pom file in 
the build dir whatsoever. I don't know if it was kept for a reason. Perhaps the 
file is/will be (re)used for build-consumer features beyond a single run? If 
it's not and it's a temp file, why not always use the temp dir e.g.?
   > 
   > * Without to much research: * Seems like (in this class at least) the 
`CONSUMER_POM_CLASSIFIER` is private so not used by other classes and the build 
dir is never queried for the file, only in-memory artifact lists?
   
   Yes, I think it was written to disk because it was needed as a file and 
there was no easy way to delete it at the end of the process, but they're not 
supposed to outlive the session.





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-12 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17722089#comment-17722089
 ] 

ASF GitHub Bot commented on MNG-7740:
-

mthmulders commented on code in PR #1105:
URL: https://github.com/apache/maven/pull/1105#discussion_r1192132236


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");
 }
+
+removeOldConsumerPomFiles(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 removeOldConsumerPomFiles(Path generatedFile) throws 
IOException {
+List oldConsumerPomFiles;

Review Comment:
   That makes perfect sense to me. Thanks for commenting on this!





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-11 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721900#comment-17721900
 ] 

ASF GitHub Bot commented on MNG-7740:
-

Giovds commented on code in PR #1105:
URL: https://github.com/apache/maven/pull/1105#discussion_r1191651779


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");
 }
+
+removeOldConsumerPomFiles(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 removeOldConsumerPomFiles(Path generatedFile) throws 
IOException {
+List oldConsumerPomFiles;

Review Comment:
   I had a couple of reasons for it. The first reason for me is readability (as 
I'll show down below). 
   
   The second is that I don't think its a good practice to wrap the checked 
exception into a runtime exception (also introducing more code or a wrapper 
'delete' method). Especially since `injectTransformedArtifacts()` already 
throws a checked exception which is probably accounted for somewhere at some 
point.
   
   As far as I know when you rewrite the stream to something like 
`stream.filter(path -> /*filter*/ }).forEach(Files::delete);` you either have 
to wrap the checked exception thrown by `Files.delete(path)` into a runtime 
exception:
   ```java
   private void delete( Path path ) {
   try { Files.delete( path ); }
   catch ( IOException e ) { throw new RuntimeException("", e); }
   }
   
   /* obfuscated*/
   
   stream.filter(path -> /*filter*/ })
  .forEach(this::delete);
   ```
   Or handle it:
   ```java
   stream.filter(path -> /*filter*/ })
  .forEach(path -> {
   try { Files.delete(path); }
   catch (IOException ex) { /*handle the exception*/ }
  });
   ```





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-11 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721826#comment-17721826
 ] 

ASF GitHub Bot commented on MNG-7740:
-

mthmulders commented on code in PR #1105:
URL: https://github.com/apache/maven/pull/1105#discussion_r1191343803


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");
 }
+
+removeOldConsumerPomFiles(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 removeOldConsumerPomFiles(Path generatedFile) throws 
IOException {
+List oldConsumerPomFiles;

Review Comment:
   Why does the code collect all the files in a list if it could as well remove 
them in the terminal operation of the `j.u.s.Stream`?





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-10 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721457#comment-17721457
 ] 

ASF GitHub Bot commented on MNG-7740:
-

michael-o commented on code in PR #1105:
URL: https://github.com/apache/maven/pull/1105#discussion_r1190121304


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");

Review Comment:
   That's different issue. Just noticed.





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-10 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721453#comment-17721453
 ] 

ASF GitHub Bot commented on MNG-7740:
-

Giovds commented on code in PR #1105:
URL: https://github.com/apache/maven/pull/1105#discussion_r1190114383


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");

Review Comment:
   This was added in [MNG-7622](https://issues.apache.org/jira/browse/MNG-7622) 
at [this 
line](https://github.com/apache/maven/pull/907/files#diff-b0e0e02760045bbda4d9839297d968b0218de307f1c4a35a3262d8cb406e0ea3R70).
 The newly created files currently are extensionless and suffixed `pom` (see 
screenshot 1). 
   
   If I suffix the newly created files with `.pom` it will be seen as a `POM` 
extension in my file explorer (screenshot 2).
   Would this not be a different ticket to change that behaviour? I'm happy to 
change it here if not, but I'll have to check if it impacts other places.
   
   [1]
   https://github.com/apache/maven/assets/27761321/9e64036a-ff9e-482f-9122-71412b113aa1";>
   [2]
   https://github.com/apache/maven/assets/27761321/eeb2b124-a48c-44d0-b81d-5631814a5a25";>
   https://github.com/apache/maven/assets/27761321/809f2d4a-a041-4095-8f3e-30881a36dda5";>
   





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-10 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721401#comment-17721401
 ] 

ASF GitHub Bot commented on MNG-7740:
-

michael-o commented on code in PR #1105:
URL: https://github.com/apache/maven/pull/1105#discussion_r1190060397


##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");

Review Comment:
   The suffix should be `.pom`, look at the Javadoc of this method.
   It is *not* the extension.



##
maven-core/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java:
##
@@ -77,13 +80,34 @@ public void injectTransformedArtifacts(MavenProject 
project, RepositorySystemSes
 Files.createDirectories(buildDir);
 generatedFile = Files.createTempFile(buildDir, 
CONSUMER_POM_CLASSIFIER, "pom");
 }
+
+removeOldConsumerPomFiles(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 removeOldConsumerPomFiles(Path generatedFile) throws 
IOException {
+List oldConsumerPomFiles;
+String newestFileName = generatedFile.getFileName().toString();
+try (Stream stream = Files.walk(generatedFile.getParent(), 1)) {
+oldConsumerPomFiles = stream.filter(path -> {
+String fileName = path.getFileName().toString();
+return !fileName.equals(newestFileName)
+&& fileName.startsWith(CONSUMER_POM_CLASSIFIER)
+&& fileName.endsWith("pom");

Review Comment:
   Ditto.





> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-10 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721394#comment-17721394
 ] 

ASF GitHub Bot commented on MNG-7740:
-

Giovds opened a new pull request, #1105:
URL: https://github.com/apache/maven/pull/1105

   This PR removes consumer*pom files from previous runs when the new consumer 
pom file is created. This way the build directory is not flooded with lots of 
`consumer*pom` files after a couple of runs.
   
   ---
   
   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
- [x] Make sure there is a 
[MNG-7740](https://issues.apache.org/jira/browse/MNG-7740) filed
  for the change (usually before you start working on it).  Trivial 
changes like typos do not
  require a JIRA issue. Your pull request should address just this 
issue, without
  pulling in other changes.
- [x] Each commit in the pull request should have a meaningful subject line 
and body.
- [x] Format the pull request title like `[MNG-XXX] SUMMARY`,
 where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA 
issue.
- [x] Also format the first line of the commit message like `[MNG-XXX] 
SUMMARY`.
  Best practice is to use the JIRA issue title in both the pull request 
title and in the first line of the commit message.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [x] Run `mvn clean verify` to make sure basic checks pass. A more 
thorough check will
  be performed on your pull request automatically.
- [x] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
- [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
- [x] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   




> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-05-10 Thread Giovanni van der Schelde (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721278#comment-17721278
 ] 

Giovanni van der Schelde commented on MNG-7740:
---

{quote}Not sure, I'll have to check...
{quote}
This is not fixed with MNG-7707.
I've tested it with the latest master 
(a8319821a95c8fdb4d99189db527fe6daf845cf0) and the files are still being 
created.

> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-04-13 Thread Maarten Mulders (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17711845#comment-17711845
 ] 

Maarten Mulders commented on MNG-7740:
--

{quote}Fixed by PR in MNG-7707?{quote}

Not sure, I'll have to check...

> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-04-13 Thread Tamas Cservenak (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17711819#comment-17711819
 ] 

Tamas Cservenak commented on MNG-7740:
--

Fixed by PR in MNG-7707?

> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MNG-7740) Target directory is flooded with consumer*pom files

2023-03-16 Thread Michael Osipov (Jira)


[ 
https://issues.apache.org/jira/browse/MNG-7740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17701057#comment-17701057
 ] 

Michael Osipov commented on MNG-7740:
-

Credits go to [~cstamas], but who doesn't like XXX?

> Target directory is flooded with consumer*pom files
> ---
>
> Key: MNG-7740
> URL: https://issues.apache.org/jira/browse/MNG-7740
> Project: Maven
>  Issue Type: Improvement
>  Components: build/consumer, Core
>Affects Versions: 4.0.0-alpha-4
> Environment: Apache Maven 4.0.0-alpha-4 
> (009cf4a7213aead8a7946a2397e2396c5927f30f)
> Maven home: /Users/maarten/Tools/apache-maven-4.0.0-alpha-4
> Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
> Default locale: en_NL, platform encoding: UTF-8
> OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"
>Reporter: Maarten Mulders
>Priority: Minor
>  Labels: up-for-grabs
>
> After invoking Mavens {{validate}} or later lifecycle phase, there is a 
> *consumerXXXpom* file left in the build directory. Here, XXX is a bunch of 
> numbers.
> It is not harmful, but I dislike the fact that for every invocation of Maven, 
> the file gets generated again and again. This can quickly lead to tens of 
> files that are never used again anymore. I feel we should clean those files 
> when we're done using them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)