Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINVOKER-374] Ability to skip project collection #265

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading