Skip to content

Commit

Permalink
[MINVOKER-374] Ability to skip project collection (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored Dec 5, 2024
1 parent 30731f1 commit 7a95d4f
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -695,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<String> collectedProjects;

// internal state variables

/**
Expand Down Expand Up @@ -802,11 +814,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {

handleScriptRunnerWithScriptClassPath();

Collection<String> collectedProjects = new LinkedHashSet<>();
for (BuildJob buildJob : buildJobs) {
collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true);
}

File projectsDir = projectsDirectory;

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

if (cloneProjectsTo != null) {
Collection<String> 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;
Expand Down Expand Up @@ -1088,7 +1102,7 @@ private boolean isNotEmpty(String s) {
*
* @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be
* <code>null</code> nor contain <code>null</code> 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<String> projectPaths) throws MojoExecutionException {
if (!cloneProjectsTo.mkdirs() && cloneClean) {
Expand Down

0 comments on commit 7a95d4f

Please sign in to comment.