@@ -695,6 +695,18 @@ public abstract class AbstractInvokerMojo extends AbstractMojo {
695
695
@ Parameter (defaultValue = "false" , property = "invoker.updateSnapshots" )
696
696
private boolean updateSnapshots ;
697
697
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
+
698
710
// internal state variables
699
711
700
712
/**
@@ -802,11 +814,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
802
814
803
815
handleScriptRunnerWithScriptClassPath ();
804
816
805
- Collection <String > collectedProjects = new LinkedHashSet <>();
806
- for (BuildJob buildJob : buildJobs ) {
807
- collectProjects (projectsDirectory , buildJob .getProject (), collectedProjects , true );
808
- }
809
-
810
817
File projectsDir = projectsDirectory ;
811
818
812
819
if (cloneProjectsTo == null && "maven-plugin" .equals (project .getPackaging ())) {
@@ -826,6 +833,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
826
833
}
827
834
828
835
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
+ }
829
843
cloneProjects (collectedProjects );
830
844
addMissingDotMvnDirectory (cloneProjectsTo , buildJobs );
831
845
projectsDir = cloneProjectsTo ;
@@ -1088,7 +1102,7 @@ private boolean isNotEmpty(String s) {
1088
1102
*
1089
1103
* @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be
1090
1104
* <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.
1092
1106
*/
1093
1107
private void cloneProjects (Collection <String > projectPaths ) throws MojoExecutionException {
1094
1108
if (!cloneProjectsTo .mkdirs () && cloneClean ) {
0 commit comments