Skip to content

Commit 7a95d4f

Browse files
authored
[MINVOKER-374] Ability to skip project collection (#265)
1 parent 30731f1 commit 7a95d4f

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Diff for: src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java

+20-6
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,18 @@ public abstract class AbstractInvokerMojo extends AbstractMojo {
695695
@Parameter(defaultValue = "false", property = "invoker.updateSnapshots")
696696
private boolean updateSnapshots;
697697

698+
/**
699+
* Projects that are cloned undergo some filtering. In order to grab all projects and make sure
700+
* they are all filtered, projects are read and parsed. In some cases, this may not be a desired
701+
* behavior (especially when some pom.xml cannot be parsed by Maven directly). In such cases,
702+
* the exact list of projects can be set using this field, avoiding the parsing of all pom.xml
703+
* files found.
704+
*
705+
* @since 3.9.0
706+
*/
707+
@Parameter
708+
private List<String> collectedProjects;
709+
698710
// internal state variables
699711

700712
/**
@@ -802,11 +814,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
802814

803815
handleScriptRunnerWithScriptClassPath();
804816

805-
Collection<String> collectedProjects = new LinkedHashSet<>();
806-
for (BuildJob buildJob : buildJobs) {
807-
collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true);
808-
}
809-
810817
File projectsDir = projectsDirectory;
811818

812819
if (cloneProjectsTo == null && "maven-plugin".equals(project.getPackaging())) {
@@ -826,6 +833,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
826833
}
827834

828835
if (cloneProjectsTo != null) {
836+
Collection<String> collectedProjects = this.collectedProjects;
837+
if (collectedProjects == null) {
838+
collectedProjects = new LinkedHashSet<>();
839+
for (BuildJob buildJob : buildJobs) {
840+
collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true);
841+
}
842+
}
829843
cloneProjects(collectedProjects);
830844
addMissingDotMvnDirectory(cloneProjectsTo, buildJobs);
831845
projectsDir = cloneProjectsTo;
@@ -1088,7 +1102,7 @@ private boolean isNotEmpty(String s) {
10881102
*
10891103
* @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be
10901104
* <code>null</code> nor contain <code>null</code> elements.
1091-
* @throws org.apache.maven.plugin.MojoExecutionException If the the projects could not be copied/filtered.
1105+
* @throws org.apache.maven.plugin.MojoExecutionException If the projects could not be copied/filtered.
10921106
*/
10931107
private void cloneProjects(Collection<String> projectPaths) throws MojoExecutionException {
10941108
if (!cloneProjectsTo.mkdirs() && cloneClean) {

0 commit comments

Comments
 (0)