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

Hack for reactor reduction #1406

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 @@ -141,7 +141,11 @@ private Result<ProjectDependencyGraph> reactorDependencyGraph(MavenSession sessi
activeProjects = trimExcludedProjects(activeProjects, projectDependencyGraph, session.getRequest());

if (activeProjects.size() != projectDependencyGraph.getSortedProjects().size()) {
projectDependencyGraph = new FilteredProjectDependencyGraph(projectDependencyGraph, activeProjects);
for (MavenProject mavenProject : projectDependencyGraph.getSortedProjects()) {
if (!activeProjects.contains(mavenProject)) {
mavenProject.skipProjectBuild();
}
}
}

return Result.success(projectDependencyGraph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public void buildProject(

try {

if (reactorContext.getReactorBuildStatus().isHaltedOrBlacklisted(currentProject)) {
if (reactorContext.getReactorBuildStatus().isHaltedOrBlacklisted(currentProject)
|| !currentProject.isProjectNeedsBuild()) {
eventCatapult.fire(ExecutionEvent.Type.ProjectSkipped, session, null);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
Expand Down Expand Up @@ -182,6 +183,18 @@ public class MavenProject implements Cloneable {

private final Set<String> lifecyclePhases = Collections.synchronizedSet(new LinkedHashSet<>());

private final AtomicBoolean projectNeedsBuild = new AtomicBoolean(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should only be set at the beginning, why using an AtomicBoolean ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted just to ensure that "transition" from true->false can happen only once, and there is no way to "reset" it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is just a hack to prove my theory, this flag is omitted from clone etc...


public boolean isProjectNeedsBuild() {
return projectNeedsBuild.get();
}

public void skipProjectBuild() {
if (projectNeedsBuild.compareAndSet(true, false)) {
LOGGER.info("Project {} is skipped from build", getId());
}
}

public MavenProject() {
Model model = new Model();

Expand Down Expand Up @@ -1109,6 +1122,10 @@ private void deepCopy(MavenProject project) {
}

lifecyclePhases.addAll(project.lifecyclePhases);

if (!project.isProjectNeedsBuild()) {
skipProjectBuild();
}
}

private void addArtifactPath(Artifact artifact, List<String> classpath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.maven.project.collector.ProjectsSelector;
import org.apache.maven.project.collector.RequestPomCollectionStrategy;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -70,6 +71,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@Disabled
class DefaultGraphBuilderTest {
/*
The multi-module structure in this project is displayed as follows:
Expand Down
Loading