From 6ab7d6ed54690543817ff9f9a3b1bbb2837e0323 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 27 Nov 2024 17:21:12 +0100 Subject: [PATCH 1/2] Ability to skip project collection --- .../plugins/invoker/AbstractInvokerMojo.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 5644fe2a..4dfac9de 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -217,6 +217,9 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { @Parameter(defaultValue = "true") private boolean cloneClean; + @Parameter + private List collectedProjects; + /** * A single POM to build, skipping any scanning parameters and behavior. * @@ -802,11 +805,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { handleScriptRunnerWithScriptClassPath(); - Collection collectedProjects = new LinkedHashSet<>(); - for (BuildJob buildJob : buildJobs) { - collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true); - } - File projectsDir = projectsDirectory; if (cloneProjectsTo == null && "maven-plugin".equals(project.getPackaging())) { @@ -826,6 +824,13 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (cloneProjectsTo != null) { + Collection collectedProjects = this.collectedProjects; + if (collectedProjects == null) { + collectedProjects = new LinkedHashSet<>(); + for (BuildJob buildJob : buildJobs) { + collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true); + } + } cloneProjects(collectedProjects); addMissingDotMvnDirectory(cloneProjectsTo, buildJobs); projectsDir = cloneProjectsTo; @@ -1088,7 +1093,7 @@ private boolean isNotEmpty(String s) { * * @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be * null nor contain null elements. - * @throws org.apache.maven.plugin.MojoExecutionException If the the projects could not be copied/filtered. + * @throws org.apache.maven.plugin.MojoExecutionException If the projects could not be copied/filtered. */ private void cloneProjects(Collection projectPaths) throws MojoExecutionException { if (!cloneProjectsTo.mkdirs() && cloneClean) { From 79098a241b52e07eeaeb5468c97b788364874fc3 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 5 Dec 2024 18:26:11 +0100 Subject: [PATCH 2/2] Add comment/since --- .../plugins/invoker/AbstractInvokerMojo.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 4dfac9de..2b06cf6d 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -217,9 +217,6 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { @Parameter(defaultValue = "true") private boolean cloneClean; - @Parameter - private List collectedProjects; - /** * A single POM to build, skipping any scanning parameters and behavior. * @@ -698,6 +695,18 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { @Parameter(defaultValue = "false", property = "invoker.updateSnapshots") private boolean updateSnapshots; + /** + * Projects that are cloned undergo some filtering. In order to grab all projects and make sure + * they are all filtered, projects are read and parsed. In some cases, this may not be a desired + * behavior (especially when some pom.xml cannot be parsed by Maven directly). In such cases, + * the exact list of projects can be set using this field, avoiding the parsing of all pom.xml + * files found. + * + * @since 3.9.0 + */ + @Parameter + private List collectedProjects; + // internal state variables /**