Implement isolated Build and Refresh with immutable leased snapshots

This commit is contained in:
2026-11-12 09:28:25 +01:00
parent 85a75383a0
commit e97af99412
27 changed files with 2066 additions and 15 deletions
@@ -0,0 +1,49 @@
package de.neitzel.fxdesigner.maven;
import java.nio.file.*;
import java.util.*;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.*;
/** Validates Maven's selected effective projects before any application lifecycle phase. */
@Mojo(name = "plan", aggregator = true, threadSafe = true)
public final class PlanMojo extends AbstractMojo {
@Parameter(defaultValue = "${session}", readonly = true, required = true)
private MavenSession session;
@Parameter(property = "designer.workspace", required = true)
private java.io.File workspace;
public void execute() throws MojoExecutionException {
try {
Path root = workspace.toPath().toRealPath();
var activeProfiles = new HashSet<String>();
for (var project : session.getProjects()) {
Path base = project.getBasedir().toPath().toRealPath();
if (!base.startsWith(root))
throw new IllegalArgumentException("Module outside isolated reactor");
var paths = new ArrayList<String>();
paths.add(project.getBuild().getDirectory());
paths.add(project.getBuild().getOutputDirectory());
paths.add(project.getBuild().getTestOutputDirectory());
paths.addAll(project.getCompileSourceRoots());
paths.addAll(project.getTestCompileSourceRoots());
project.getResources().forEach(r -> paths.add(r.getDirectory()));
project.getTestResources().forEach(r -> paths.add(r.getDirectory()));
for (String path : paths)
if (!Path.of(path).toAbsolutePath().normalize().startsWith(base))
throw new IllegalArgumentException(
"Effective source/output path outside module: " + path);
project.getActiveProfiles().forEach(p -> activeProfiles.add(p.getId()));
project.getInjectedProfileIds().values().forEach(activeProfiles::addAll);
getLog().info("Designer scope: " + root.relativize(base) + " (" + project.getId() + ")");
}
if (!activeProfiles.containsAll(session.getRequest().getActiveProfiles()))
throw new IllegalArgumentException("Requested Maven profile did not activate");
} catch (Exception e) {
throw new MojoExecutionException("Unsupported effective Maven build plan", e);
}
}
}