build: 템플릿 밖에서 혼자 빌드·배포되는 Gradle 루트를 만든다
옮겨 온 gRPC 모듈은 템플릿의 두 번째 빌드(optional build)였다. 그 빌드는 템플릿 build-logic·카탈로그·registry·config를 상대 경로로 읽었고, grpc-operation-ledger-jpa는 템플릿 persistence-jpa의 testFixtures 파일 셋을 빌드 때 복사해 왔다. 별도 repo에는 그 경로가 없다. repo 루트를 Gradle 루트로 둔다. - build-logic: 템플릿 22df3525의 src/build-logic을 복사하고 쓰지 않는 플러그인(bootrun-dotenv, redis topology, config contract, spring-library, optional registry, purity 태스크)을 뺐다. 출처와 고친 곳은 build-logic/UPSTREAM.md에 적었다(설계 10.3절 L1). - registry config/architecture/modules.json: 템플릿의 optional-grpc 9행, source_path는 Gradle 루트 기준. - 카탈로그·config: 이 repo가 쓰는 항목만. SpotBugs 제외는 이 repo 클래스와 일반 규칙만 남겼다. - group은 gradle.properties의 libraryGroup(com.hyeonworks.grpc)에서 읽는다. 버전은 -PreleaseVersion 말고 RELEASE_TAG(vX.Y.Z)에서도 읽고, 다른 모양의 태그는 빌드 전에 거부한다. - 배포: 새 ca.library-publishing이 모듈마다 Maven publication(sources· javadoc jar, versionMapping으로 해석된 버전)과 저장소 gitea·staging, SIGNING_KEY가 있으면 PGP 서명을 단다. 루트는 SBOM artifact grpc-library와 단계 태스크 ci·mainCheck·releaseCheck·release· releaseRehearsal을 가진다. Trivy·Buf는 scripts/tool.sh가 SHA-256으로 고정해 받는다. - testFixtures 결합(설계 4.6절 2번)은 integrationTest 안 사본으로 끊었다. - Buf lint·breaking은 Gradle 태스크(scripts/buf.sh)로 ci에 넣었다. 버린 대안: build-logic을 템플릿이 배포(L2, 순환), 공통 repo(L3, repo가 하나 더), 표준 플러그인만으로 새로 쓰기(L4, strict lane과 방향 검사를 잃음). SBOM은 CycloneDX Gradle 플러그인 대신 이미 고정해 쓰는 Trivy로 만든다(도구를 늘리지 않는다). 위험: strictlane 단계 검사는 included build 태스크를 따라가다 실패해서 그 태스크를 건너뛰게 고쳤다(UPSTREAM.md). Gitea에 실제로 올리는 경로는 비밀 값이 없어 이 커밋에서는 시험하지 못했다. 검증(desktop, 이 트리): ./gradlew ci rc=0, 테스트 739개(build-logic 포함) 중 첫 실행 실패 1개(템플릿 경로를 찾던 GrpcPackageOwnershipTest)를 고친 뒤 통과. ./gradlew verifyStrictLaneStages --dry-run rc=0. Refs: design-docs repo-structure/05-library-repos.md 4.6·7·10절
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** Declarative configuration for one committed public API surface. */
|
||||
public class ApiSurfaceExtension {
|
||||
private String label;
|
||||
private File baseline;
|
||||
private String description;
|
||||
private List<String> rationale = new ArrayList<>();
|
||||
private String sourceRoot = "src/main/java";
|
||||
private List<String> additionalSourceRoots = new ArrayList<>();
|
||||
private File adopterBaseline;
|
||||
private Object adopterSources;
|
||||
|
||||
public String getLabel() { return label; }
|
||||
public void setLabel(String label) { this.label = label; }
|
||||
public File getBaseline() { return baseline; }
|
||||
public void setBaseline(File baseline) { this.baseline = baseline; }
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
public List<String> getRationale() { return rationale; }
|
||||
public void setRationale(List<String> rationale) {
|
||||
this.rationale = rationale == null ? new ArrayList<>() : new ArrayList<>(rationale);
|
||||
}
|
||||
public String getSourceRoot() { return sourceRoot; }
|
||||
public void setSourceRoot(String sourceRoot) { this.sourceRoot = sourceRoot; }
|
||||
public List<String> getAdditionalSourceRoots() { return additionalSourceRoots; }
|
||||
public void setAdditionalSourceRoots(List<String> additionalSourceRoots) {
|
||||
this.additionalSourceRoots =
|
||||
additionalSourceRoots == null ? new ArrayList<>() : new ArrayList<>(additionalSourceRoots);
|
||||
}
|
||||
|
||||
/**
|
||||
* The reviewed subset of the surface other leaves' production code may import. Optional: without
|
||||
* it, every public type is fair game to an adopter, which is what the surface alone says.
|
||||
*/
|
||||
public File getAdopterBaseline() { return adopterBaseline; }
|
||||
public void setAdopterBaseline(File adopterBaseline) { this.adopterBaseline = adopterBaseline; }
|
||||
/** The adopter sources whose imports are held to {@link #getAdopterBaseline()}; any {@code files()} notation. */
|
||||
public Object getAdopterSources() { return adopterSources; }
|
||||
public void setAdopterSources(Object adopterSources) { this.adopterSources = adopterSources; }
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** Policy and rendering semantics for committed public Java API surfaces. */
|
||||
public final class ApiSurfacePolicy {
|
||||
private ApiSurfacePolicy() {}
|
||||
|
||||
public static String render(
|
||||
Collection<File> roots,
|
||||
String label,
|
||||
String description,
|
||||
Collection<String> rationale,
|
||||
String owningProjectPath,
|
||||
String updateTaskName,
|
||||
String approvalProperty) {
|
||||
List<String> types;
|
||||
try {
|
||||
types = JavaPublicTypes.render(roots);
|
||||
} catch (IllegalStateException unparseable) {
|
||||
throw new IllegalStateException(
|
||||
owningProjectPath + " " + label + " API surface: " + unparseable.getMessage(),
|
||||
unparseable);
|
||||
}
|
||||
if (types.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
owningProjectPath
|
||||
+ ": found no public types under "
|
||||
+ String.join(", ", roots.stream().map(File::toString).toList())
|
||||
+ ". The source roots moved; fix the paths rather than accepting an empty surface.");
|
||||
}
|
||||
StringBuilder header = new StringBuilder();
|
||||
header.append("# ").append(description).append('\n');
|
||||
if (rationale != null) {
|
||||
rationale.forEach(line -> header.append("# ").append(line).append('\n'));
|
||||
}
|
||||
header.append("# Update only after review with:\n");
|
||||
header
|
||||
.append("# ./gradlew ")
|
||||
.append(owningProjectPath)
|
||||
.append(':')
|
||||
.append(updateTaskName)
|
||||
.append(" -P")
|
||||
.append(approvalProperty)
|
||||
.append('\n');
|
||||
header.append("# types: ").append(types.size()).append('\n');
|
||||
return header + String.join("\n", types) + "\n";
|
||||
}
|
||||
|
||||
public static void verify(
|
||||
String verifyTaskName,
|
||||
String updateTaskName,
|
||||
String owningProjectPath,
|
||||
String approvalProperty,
|
||||
File baseline,
|
||||
String rendered) {
|
||||
if (!baseline.isFile()) {
|
||||
throw new IllegalStateException(
|
||||
verifyTaskName + ": missing committed baseline " + baseline);
|
||||
}
|
||||
String committed = read(baseline);
|
||||
if (committed.equals(rendered)) {
|
||||
return;
|
||||
}
|
||||
List<String> committedTypes = surfaceLines(committed);
|
||||
List<String> renderedTypes = surfaceLines(rendered);
|
||||
List<String> added = difference(renderedTypes, committedTypes);
|
||||
List<String> removed = difference(committedTypes, renderedTypes);
|
||||
throw new IllegalStateException(
|
||||
verifyTaskName
|
||||
+ ": the public API surface changed.\n"
|
||||
+ (added.isEmpty() ? "" : " added:\n " + String.join("\n ", added) + "\n")
|
||||
+ (removed.isEmpty() ? "" : " removed:\n " + String.join("\n ", removed) + "\n")
|
||||
+ "Review the change, then record it with:\n"
|
||||
+ " ./gradlew "
|
||||
+ owningProjectPath
|
||||
+ ":"
|
||||
+ updateTaskName
|
||||
+ " -P"
|
||||
+ approvalProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds other leaves' imports of this surface to the reviewed adopter subset.
|
||||
*
|
||||
* <p>The surface says what is public; the adopter baseline says which of those public types other
|
||||
* leaves' production code may depend on. An import of a surface type the adopter baseline does not
|
||||
* list fails, and so does an adopter entry the surface no longer has.
|
||||
*/
|
||||
public static void verifyAdopters(
|
||||
String verifyTaskName, String rendered, File adopterBaseline, List<String> adopterImports) {
|
||||
if (!adopterBaseline.isFile()) {
|
||||
throw new IllegalStateException(
|
||||
verifyTaskName + ": missing committed adopter baseline " + adopterBaseline);
|
||||
}
|
||||
java.util.Set<String> surface = new java.util.HashSet<>(surfaceLines(rendered));
|
||||
java.util.Set<String> allowed = new java.util.TreeSet<>();
|
||||
for (String line : read(adopterBaseline).lines().toList()) {
|
||||
if (!line.isBlank() && !line.startsWith("#")) {
|
||||
allowed.add(line.trim());
|
||||
}
|
||||
}
|
||||
List<String> stale = allowed.stream().filter(type -> !surface.contains(type)).toList();
|
||||
List<String> unreviewed =
|
||||
adopterImports.stream()
|
||||
.filter(entry -> {
|
||||
String type = entry.substring(entry.indexOf(": ") + 2);
|
||||
return surface.contains(type) && !allowed.contains(type);
|
||||
})
|
||||
.toList();
|
||||
if (stale.isEmpty() && unreviewed.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
verifyTaskName
|
||||
+ ": the adopter surface ("
|
||||
+ adopterBaseline.getName()
|
||||
+ ") does not match what other leaves import.\n"
|
||||
+ (unreviewed.isEmpty()
|
||||
? ""
|
||||
: " imported but not in the adopter baseline:\n "
|
||||
+ String.join("\n ", unreviewed)
|
||||
+ "\n")
|
||||
+ (stale.isEmpty()
|
||||
? ""
|
||||
: " in the adopter baseline but not in the public surface:\n "
|
||||
+ String.join("\n ", stale)
|
||||
+ "\n")
|
||||
+ "Add a reviewed type to the adopter baseline, or stop importing it.");
|
||||
}
|
||||
|
||||
public static void requireNoUnapprovedGrowth(
|
||||
String updateTaskName,
|
||||
String owningProjectPath,
|
||||
String approvalProperty,
|
||||
String ceilingProperty,
|
||||
int committedCount,
|
||||
String rendered,
|
||||
boolean ceilingRaiseApproved) {
|
||||
if (ceilingRaiseApproved) {
|
||||
return;
|
||||
}
|
||||
int renderedCount = countTypes(rendered);
|
||||
if (renderedCount > committedCount) {
|
||||
throw new IllegalStateException(
|
||||
updateTaskName
|
||||
+ ": the public surface would grow from "
|
||||
+ committedCount
|
||||
+ " to "
|
||||
+ renderedCount
|
||||
+ " types.\n"
|
||||
+ "Approving additions one at a time is how this leaf got too big to split without anybody deciding to make it so.\n"
|
||||
+ "Either land the addition together with a removal that pays for it, or raise the ceiling deliberately:\n"
|
||||
+ " ./gradlew "
|
||||
+ owningProjectPath
|
||||
+ ":"
|
||||
+ updateTaskName
|
||||
+ " -P"
|
||||
+ approvalProperty
|
||||
+ " -P"
|
||||
+ ceilingProperty);
|
||||
}
|
||||
}
|
||||
|
||||
public static int countTypes(String surface) {
|
||||
return (int)
|
||||
surface.lines()
|
||||
.filter(line -> !line.startsWith("#") && !line.trim().isEmpty())
|
||||
.count();
|
||||
}
|
||||
|
||||
private static List<String> surfaceLines(String surface) {
|
||||
return surface.lines().filter(line -> !line.startsWith("#")).toList();
|
||||
}
|
||||
|
||||
private static List<String> difference(List<String> left, List<String> right) {
|
||||
ArrayList<String> result = new ArrayList<>(left);
|
||||
result.removeAll(right);
|
||||
result.sort(String::compareTo);
|
||||
return List.copyOf(result);
|
||||
}
|
||||
|
||||
private static String read(File file) {
|
||||
try {
|
||||
return Files.readString(file.toPath(), StandardCharsets.UTF_8);
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to read " + file, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import com.sun.source.tree.ClassTree;
|
||||
import com.sun.source.tree.CompilationUnitTree;
|
||||
import com.sun.source.tree.ImportTree;
|
||||
import com.sun.source.tree.Tree;
|
||||
import com.sun.source.util.JavacTask;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
/** Public top-level Java types parsed with javac rather than regular expressions. */
|
||||
public final class JavaPublicTypes {
|
||||
private JavaPublicTypes() {}
|
||||
|
||||
public static List<String> render(Collection<File> sourceRoots) {
|
||||
List<File> sources = new ArrayList<>();
|
||||
if (sourceRoots != null) {
|
||||
for (File root : sourceRoots) {
|
||||
if (root == null || !root.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
try (var paths = Files.walk(root.toPath())) {
|
||||
paths.filter(Files::isRegularFile)
|
||||
.filter(path -> path.getFileName().toString().endsWith(".java"))
|
||||
.map(java.nio.file.Path::toFile)
|
||||
.forEach(sources::add);
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("Could not walk Java source root " + root, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> types = new TreeSet<>();
|
||||
for (CompilationUnitTree unit : parse(sources, "The public API surface")) {
|
||||
if (unit.getPackageName() == null) {
|
||||
continue;
|
||||
}
|
||||
String packageName = unit.getPackageName().toString();
|
||||
for (Tree declaration : unit.getTypeDecls()) {
|
||||
if (declaration instanceof ClassTree type
|
||||
&& type.getModifiers().getFlags().contains(Modifier.PUBLIC)) {
|
||||
types.add(packageName + "." + type.getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return List.copyOf(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Every single-type, non-static import in {@code sources}, as {@code "<file name>: <import>"}.
|
||||
* Wildcard and static imports are not listed; a leaf whose adopters need them is declaring a
|
||||
* surface this check does not model.
|
||||
*/
|
||||
public static List<String> imports(Collection<File> sources) {
|
||||
List<File> files =
|
||||
sources == null
|
||||
? List.of()
|
||||
: sources.stream().filter(file -> file.getName().endsWith(".java")).toList();
|
||||
Set<String> imports = new TreeSet<>();
|
||||
for (CompilationUnitTree unit : parse(files, "The adopter sources")) {
|
||||
String file = new File(unit.getSourceFile().toUri()).getName();
|
||||
for (ImportTree declaration : unit.getImports()) {
|
||||
String name = declaration.getQualifiedIdentifier().toString();
|
||||
if (!declaration.isStatic() && !name.endsWith(".*")) {
|
||||
imports.add(file + ": " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return List.copyOf(imports);
|
||||
}
|
||||
|
||||
private static List<CompilationUnitTree> parse(Collection<File> files, String subject) {
|
||||
List<File> sources = new ArrayList<>(files);
|
||||
if (sources.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
sources.sort(Comparator.comparing(File::getPath));
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (compiler == null) {
|
||||
throw new IllegalStateException(
|
||||
"No Java compiler on this JVM, so the public API surface cannot be parsed. "
|
||||
+ "Run the build on a JDK rather than a JRE — rendering an empty surface "
|
||||
+ "instead would report every public type as removed.");
|
||||
}
|
||||
|
||||
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
||||
try (StandardJavaFileManager fileManager =
|
||||
compiler.getStandardFileManager(diagnostics, null, StandardCharsets.UTF_8)) {
|
||||
JavacTask task =
|
||||
(JavacTask)
|
||||
compiler.getTask(
|
||||
new StringWriter(),
|
||||
fileManager,
|
||||
diagnostics,
|
||||
List.of("-proc:none"),
|
||||
null,
|
||||
fileManager.getJavaFileObjectsFromFiles(sources));
|
||||
List<CompilationUnitTree> units = new ArrayList<>();
|
||||
task.parse().forEach(units::add);
|
||||
List<Diagnostic<? extends JavaFileObject>> errors =
|
||||
diagnostics.getDiagnostics().stream()
|
||||
.filter(diagnostic -> diagnostic.getKind() == Diagnostic.Kind.ERROR)
|
||||
.toList();
|
||||
if (!errors.isEmpty()) {
|
||||
String first =
|
||||
errors.stream().limit(5).map(Object::toString).reduce((a, b) -> a + "\n " + b).orElse("");
|
||||
String more = errors.size() > 5 ? "\n (" + (errors.size() - 5) + " more)" : "";
|
||||
throw new IllegalStateException(subject + " could not be parsed:\n " + first + more);
|
||||
}
|
||||
return units;
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("Could not parse Java source files", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import tools.jackson.databind.JsonNode;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
import tools.jackson.databind.json.JsonMapper;
|
||||
|
||||
/** Typed representation of config/architecture/modules.json. */
|
||||
public record ModuleRegistry(List<Module> modules, File source) {
|
||||
private static final ObjectMapper JSON = JsonMapper.builder().build();
|
||||
private static final Set<String> REQUIRED_MODULE_FIELDS =
|
||||
Set.of("id", "gradle_path", "source_path", "allowed_dependencies");
|
||||
private static final Set<String> REQUIRED_ROOT_FIELDS = Set.of("modules");
|
||||
|
||||
public ModuleRegistry {
|
||||
modules = List.copyOf(modules);
|
||||
Objects.requireNonNull(source, "source");
|
||||
}
|
||||
|
||||
public record Module(
|
||||
String id,
|
||||
String gradlePath,
|
||||
String sourcePath,
|
||||
File sourceDirectory,
|
||||
String buildName,
|
||||
List<String> allowedDependencies) {
|
||||
public Module {
|
||||
Objects.requireNonNull(id, "id");
|
||||
Objects.requireNonNull(gradlePath, "gradlePath");
|
||||
Objects.requireNonNull(sourcePath, "sourcePath");
|
||||
Objects.requireNonNull(sourceDirectory, "sourceDirectory");
|
||||
Objects.requireNonNull(buildName, "buildName");
|
||||
allowedDependencies = List.copyOf(allowedDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
public static ModuleRegistry read(File registryFile, File repositoryRoot) {
|
||||
if (!registryFile.isFile()) {
|
||||
throw new IllegalStateException("Missing module registry: " + registryFile);
|
||||
}
|
||||
JsonNode root;
|
||||
try {
|
||||
root = JSON.readTree(Files.readString(registryFile.toPath(), StandardCharsets.UTF_8));
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to read " + registryFile, exception);
|
||||
}
|
||||
if (root == null || !root.isObject()) {
|
||||
throw new IllegalStateException("Module registry root must be a JSON object: " + registryFile);
|
||||
}
|
||||
Set<String> rootKeys = keys(root);
|
||||
Set<String> missingRootFields = new TreeSet<>(REQUIRED_ROOT_FIELDS);
|
||||
missingRootFields.removeAll(rootKeys);
|
||||
if (!missingRootFields.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry root is missing " + missingRootFields + ": " + registryFile);
|
||||
}
|
||||
|
||||
JsonNode modulesNode = root.get("modules");
|
||||
if (modulesNode == null || !modulesNode.isArray() || modulesNode.isEmpty()) {
|
||||
throw new IllegalStateException("Module registry has no modules: " + registryFile);
|
||||
}
|
||||
|
||||
File canonicalRoot;
|
||||
try {
|
||||
canonicalRoot = repositoryRoot.getCanonicalFile();
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to canonicalize " + repositoryRoot, exception);
|
||||
}
|
||||
String rootPrefix = canonicalRoot.getPath() + File.separator;
|
||||
Set<String> ids = new LinkedHashSet<>();
|
||||
Set<String> gradlePaths = new LinkedHashSet<>();
|
||||
Set<String> sourceDirectories = new LinkedHashSet<>();
|
||||
List<Module> modules = new ArrayList<>();
|
||||
|
||||
for (int index = 0; index < modulesNode.size(); index++) {
|
||||
JsonNode module = modulesNode.get(index);
|
||||
if (module == null || !module.isObject()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry " + index + " must be a JSON object.");
|
||||
}
|
||||
Set<String> missingFields = new TreeSet<>(REQUIRED_MODULE_FIELDS);
|
||||
missingFields.removeAll(keys(module));
|
||||
if (!missingFields.isEmpty()) {
|
||||
JsonNode rawId = module.get("id");
|
||||
String named =
|
||||
rawId != null && rawId.isString() && !rawId.asText().isBlank()
|
||||
? "'" + rawId.asText() + "'"
|
||||
: "at index " + index;
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry " + named + " is missing " + missingFields);
|
||||
}
|
||||
|
||||
String id = requireNonBlankText(module, "id", index);
|
||||
String gradlePath = requireNonBlankText(module, "gradle_path", index);
|
||||
String sourcePath = requireNonBlankText(module, "source_path", index);
|
||||
String buildName = module.has("build") ? requireNonBlankText(module, "build", id) : "main";
|
||||
List<String> allowedDependencies =
|
||||
requireStringList(module.get("allowed_dependencies"), id, "allowed_dependencies");
|
||||
|
||||
if (new HashSet<>(allowedDependencies).size() != allowedDependencies.size()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '" + id + "' contains duplicate allowed dependencies.");
|
||||
}
|
||||
if (!ids.add(id)) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry contains duplicate module id '" + id + "'.");
|
||||
}
|
||||
if (!gradlePath.startsWith(":")) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '"
|
||||
+ id
|
||||
+ "' has Gradle path '"
|
||||
+ gradlePath
|
||||
+ "' that does not start with ':'.");
|
||||
}
|
||||
if (!gradlePaths.add(gradlePath)) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry contains duplicate Gradle path '" + gradlePath + "'.");
|
||||
}
|
||||
if (new File(sourcePath).isAbsolute()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '"
|
||||
+ id
|
||||
+ "' source path must be repository-root-relative: '"
|
||||
+ sourcePath
|
||||
+ "'.");
|
||||
}
|
||||
|
||||
File sourceDirectory;
|
||||
try {
|
||||
sourceDirectory = new File(canonicalRoot, sourcePath).getCanonicalFile();
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to canonicalize " + sourcePath, exception);
|
||||
}
|
||||
if (!sourceDirectory.getPath().startsWith(rootPrefix)) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '"
|
||||
+ id
|
||||
+ "' source path escapes the repository root: '"
|
||||
+ sourcePath
|
||||
+ "'.");
|
||||
}
|
||||
if (!sourceDirectory.isDirectory()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '"
|
||||
+ id
|
||||
+ "' source path is not an existing directory: "
|
||||
+ sourceDirectory);
|
||||
}
|
||||
if (!sourceDirectories.add(sourceDirectory.getPath())) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '"
|
||||
+ id
|
||||
+ "' resolves to duplicate or aliased canonical source directory: "
|
||||
+ sourceDirectory);
|
||||
}
|
||||
modules.add(
|
||||
new Module(
|
||||
id,
|
||||
gradlePath,
|
||||
sourcePath,
|
||||
sourceDirectory,
|
||||
buildName,
|
||||
allowedDependencies));
|
||||
}
|
||||
|
||||
return new ModuleRegistry(modules, registryFile);
|
||||
}
|
||||
|
||||
public Module byId(String id) {
|
||||
return modules.stream().filter(module -> module.id().equals(id)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build scripts under {@code gradleRoot} that no registered module owns, relative to it.
|
||||
*
|
||||
* <p>The settings plugin includes only registered modules, so a leaf directory nobody registered
|
||||
* is not compiled, not tested and not compared by any gate, while {@code ci} stays green (review
|
||||
* 2026-11-01 08-05). The walk skips the root's own script, every directory with its own settings
|
||||
* script (a separate build, such as build-logic or optional-platforms), build output, and the
|
||||
* inside of a module's {@code src} tree, where a build script is a test fixture.
|
||||
*/
|
||||
public List<String> unregisteredBuildScripts(File gradleRoot) {
|
||||
Path root = canonical(gradleRoot).toPath();
|
||||
Set<Path> owned = new HashSet<>();
|
||||
for (Module module : modules) {
|
||||
owned.add(canonical(module.sourceDirectory()).toPath());
|
||||
}
|
||||
List<String> unregistered = new ArrayList<>();
|
||||
try {
|
||||
Files.walkFileTree(
|
||||
root,
|
||||
new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path directory, BasicFileAttributes attributes) {
|
||||
String name = directory.getFileName().toString();
|
||||
boolean otherBuild =
|
||||
!directory.equals(root)
|
||||
&& (Files.isRegularFile(directory.resolve("settings.gradle"))
|
||||
|| Files.isRegularFile(directory.resolve("settings.gradle.kts")));
|
||||
boolean moduleSources =
|
||||
name.equals("src") && owned.contains(directory.getParent());
|
||||
if (otherBuild
|
||||
|| moduleSources
|
||||
|| name.equals("build")
|
||||
// IDE compiler output (Eclipse/VS Code `bin/`, git-ignored as `src/**/bin/`) copies
|
||||
// resource build scripts such as grpc-codegen's consumer fixtures; it is not source.
|
||||
|| name.equals("bin")
|
||||
|| name.startsWith(".")) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
}
|
||||
if (!directory.equals(root)
|
||||
&& !owned.contains(directory)
|
||||
&& (Files.isRegularFile(directory.resolve("build.gradle"))
|
||||
|| Files.isRegularFile(directory.resolve("build.gradle.kts")))) {
|
||||
String script =
|
||||
Files.isRegularFile(directory.resolve("build.gradle"))
|
||||
? "build.gradle"
|
||||
: "build.gradle.kts";
|
||||
unregistered.add(
|
||||
root.relativize(directory.resolve(script)).toString().replace(File.separatorChar, '/'));
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to walk " + root, exception);
|
||||
}
|
||||
unregistered.sort(null);
|
||||
return List.copyOf(unregistered);
|
||||
}
|
||||
|
||||
private static File canonical(File file) {
|
||||
try {
|
||||
return file.getCanonicalFile();
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to canonicalize " + file, exception);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Module> modulesForBuild(String buildName) {
|
||||
return modules.stream().filter(module -> module.buildName().equals(buildName)).toList();
|
||||
}
|
||||
|
||||
private static Set<String> keys(JsonNode node) {
|
||||
Set<String> result = new LinkedHashSet<>();
|
||||
node.properties().forEach(entry -> result.add(entry.getKey()));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String requireNonBlankText(JsonNode node, String field, Object entry) {
|
||||
JsonNode value = node.get(field);
|
||||
if (value == null || !value.isString() || value.asText().isBlank()) {
|
||||
String prefix = entry instanceof Integer ? "entry " + entry : "entry '" + entry + "'";
|
||||
throw new IllegalStateException(
|
||||
"Module registry " + prefix + " needs a nonblank string '" + field + "'.");
|
||||
}
|
||||
return value.asText();
|
||||
}
|
||||
|
||||
private static List<String> requireStringList(JsonNode raw, String id, String field) {
|
||||
if (raw == null || !raw.isArray()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '" + id + "' needs a '" + field + "' list.");
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
for (int index = 0; index < raw.size(); index++) {
|
||||
JsonNode value = raw.get(index);
|
||||
if (value == null || !value.isString() || value.asText().isBlank()) {
|
||||
throw new IllegalStateException(
|
||||
"Module registry entry '"
|
||||
+ id
|
||||
+ "' has a non-string or blank "
|
||||
+ field
|
||||
+ " entry at index "
|
||||
+ index
|
||||
+ ".");
|
||||
}
|
||||
result.add(value.asText());
|
||||
}
|
||||
return List.copyOf(result);
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.initialization.Settings;
|
||||
|
||||
/** Settings-time adapter mapping one logical build from the shared module registry into Gradle. */
|
||||
public final class ModuleRegistrySettingsInstaller {
|
||||
private ModuleRegistrySettingsInstaller() {}
|
||||
|
||||
public static ModuleRegistry install(
|
||||
Settings settings, File registryFile, File repositoryRoot, String buildName) {
|
||||
ModuleRegistry registry;
|
||||
try {
|
||||
registry = ModuleRegistry.read(registryFile, repositoryRoot);
|
||||
} catch (IllegalStateException invalid) {
|
||||
throw new GradleException(invalid.getMessage(), invalid);
|
||||
}
|
||||
|
||||
List<ModuleRegistry.Module> selected = registry.modulesForBuild(buildName);
|
||||
if (selected.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"Module registry declares no modules for build '" + buildName + "': " + registryFile);
|
||||
}
|
||||
|
||||
Map<String, File> namespaceDirectories = new HashMap<>();
|
||||
for (ModuleRegistry.Module module : selected) {
|
||||
settings.include(module.gradlePath());
|
||||
settings.project(module.gradlePath()).setProjectDir(module.sourceDirectory());
|
||||
|
||||
String[] segments = module.gradlePath().substring(1).split(":");
|
||||
File directory = module.sourceDirectory();
|
||||
for (int size = segments.length - 1; size >= 1; size--) {
|
||||
directory = directory.getParentFile();
|
||||
String parentPath = ":" + String.join(":", java.util.Arrays.copyOf(segments, size));
|
||||
File canonical;
|
||||
try {
|
||||
canonical = directory.getCanonicalFile();
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to canonicalize " + directory, exception);
|
||||
}
|
||||
File existing = namespaceDirectories.putIfAbsent(parentPath, canonical);
|
||||
if (existing != null && !existing.equals(canonical)) {
|
||||
throw new GradleException(
|
||||
"Module registry maps namespace '"
|
||||
+ parentPath
|
||||
+ "' to both "
|
||||
+ existing
|
||||
+ " and "
|
||||
+ canonical
|
||||
+ ".");
|
||||
}
|
||||
settings.project(parentPath).setProjectDir(canonical);
|
||||
}
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/** One rule for proving that a named test selector actually executed. */
|
||||
public final class RequiredTestExecution {
|
||||
private static final List<String> SUB_IDENTITY_SEPARATORS = List.of("$", "(", "[");
|
||||
|
||||
private RequiredTestExecution() {}
|
||||
|
||||
public static boolean satisfies(String executed, String required) {
|
||||
if (executed == null || required == null) {
|
||||
return false;
|
||||
}
|
||||
if (executed.equals(required)) {
|
||||
return true;
|
||||
}
|
||||
return SUB_IDENTITY_SEPARATORS.stream()
|
||||
.anyMatch(separator -> executed.startsWith(required + separator));
|
||||
}
|
||||
|
||||
public static List<String> absent(
|
||||
Collection<String> required, Collection<String> executed) {
|
||||
if (required == null || required.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
Collection<String> observed = executed == null ? List.of() : executed;
|
||||
List<String> absent = new ArrayList<>();
|
||||
for (String requiredSelector : required) {
|
||||
boolean satisfied =
|
||||
observed.stream().anyMatch(executedSelector -> satisfies(executedSelector, requiredSelector));
|
||||
if (!satisfied) {
|
||||
absent.add(requiredSelector);
|
||||
}
|
||||
}
|
||||
return List.copyOf(absent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package dev.caskeleton.buildlogic;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult;
|
||||
import org.gradle.api.artifacts.result.ResolvedDependencyResult;
|
||||
|
||||
/**
|
||||
* Walks a resolution result from its root component.
|
||||
*
|
||||
* <p>The architecture tasks used to hold a {@link org.gradle.api.artifacts.Configuration} and call
|
||||
* {@code getIncoming().getResolutionResult().getAllComponents()} inside the task action. That is
|
||||
* live build state: Gradle cannot serialise it, so the configuration cache refused to store the
|
||||
* task, and it resolves a configuration at execution time from whatever project happens to run the
|
||||
* action. A {@code Provider<ResolvedComponentResult>} taken from {@code getRootComponent()} is the
|
||||
* supported carrier — it is resolved while the owning project is still configuring, and what the
|
||||
* task keeps is a value.
|
||||
*
|
||||
* <p>This walk therefore replaces {@code getAllComponents()}, which has no equivalent on the root
|
||||
* component. The visited set is not an optimisation: a dependency graph is a DAG only in intent,
|
||||
* and a cycle here would be an infinite loop rather than a diagnosis.
|
||||
*/
|
||||
public final class ResolvedComponents {
|
||||
|
||||
private ResolvedComponents() {}
|
||||
|
||||
/** Every component reachable from {@code root}, including {@code root} itself. */
|
||||
public static Set<ResolvedComponentResult> reachableFrom(ResolvedComponentResult root) {
|
||||
Set<ResolvedComponentResult> visited = new LinkedHashSet<>();
|
||||
Deque<ResolvedComponentResult> pending = new ArrayDeque<>();
|
||||
pending.add(root);
|
||||
while (!pending.isEmpty()) {
|
||||
ResolvedComponentResult component = pending.removeFirst();
|
||||
if (!visited.add(component)) {
|
||||
continue;
|
||||
}
|
||||
for (var dependency : component.getDependencies()) {
|
||||
if (dependency instanceof ResolvedDependencyResult resolved) {
|
||||
pending.add(resolved.getSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
return visited;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package dev.caskeleton.buildlogic.apisurface;
|
||||
|
||||
import dev.caskeleton.buildlogic.ApiSurfaceExtension;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
public final class ApiSurfacePlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
ApiSurfaceExtension extension =
|
||||
project.getExtensions().create("apiSurface", ApiSurfaceExtension.class);
|
||||
|
||||
project.afterEvaluate(
|
||||
ignored -> {
|
||||
String label = extension.getLabel();
|
||||
File baseline = extension.getBaseline();
|
||||
if ((label == null || label.isBlank()) && baseline == null) {
|
||||
return;
|
||||
}
|
||||
if (label == null || label.isBlank()) {
|
||||
throw new GradleException(
|
||||
project.getPath() + " declares an apiSurface baseline without a label");
|
||||
}
|
||||
if (baseline == null) {
|
||||
throw new GradleException(
|
||||
project.getPath() + " declares an apiSurface label without a baseline");
|
||||
}
|
||||
|
||||
List<String> sourcePaths = new ArrayList<>();
|
||||
if (extension.getSourceRoot() != null && !extension.getSourceRoot().isBlank()) {
|
||||
sourcePaths.add(extension.getSourceRoot());
|
||||
}
|
||||
extension.getAdditionalSourceRoots().stream()
|
||||
.filter(path -> path != null && !path.isBlank())
|
||||
.forEach(sourcePaths::add);
|
||||
List<File> roots = sourcePaths.stream().map(project::file).toList();
|
||||
String verifyTaskName = "verify" + label + "ApiSurface";
|
||||
String updateTaskName = "update" + label + "ApiSurface";
|
||||
String approvalProperty = "approve" + label + "ApiSurfaceChange";
|
||||
String ceilingProperty = "raise" + label + "ApiSurfaceCeiling";
|
||||
boolean approved = project.hasProperty(approvalProperty);
|
||||
boolean ceilingApproved = project.hasProperty(ceilingProperty);
|
||||
|
||||
var verify =
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
verifyTaskName,
|
||||
VerifyApiSurfaceTask.class,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Fails without mutation when the committed "
|
||||
+ label
|
||||
+ " public API surface drifts.");
|
||||
task.getSourceRoots().from(roots);
|
||||
task.getBaseline().fileValue(baseline);
|
||||
task.getLabel().set(label);
|
||||
task.getSurfaceDescription()
|
||||
.set(extension.getDescription() == null ? "" : extension.getDescription());
|
||||
task.getRationale().set(extension.getRationale());
|
||||
task.getOwningProjectPath().set(project.getPath());
|
||||
task.getUpdateTaskName().set(updateTaskName);
|
||||
task.getApprovalProperty().set(approvalProperty);
|
||||
task.getUpdateApproved().set(approved);
|
||||
if (extension.getAdopterBaseline() != null) {
|
||||
task.getAdopterBaseline().fileValue(extension.getAdopterBaseline());
|
||||
if (extension.getAdopterSources() != null) {
|
||||
task.getAdopterSources().from(extension.getAdopterSources());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
updateTaskName,
|
||||
UpdateApiSurfaceTask.class,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Rewrites the committed "
|
||||
+ label
|
||||
+ " public API surface baseline after review.");
|
||||
task.getSourceRoots().from(roots);
|
||||
task.getBaseline().fileValue(baseline);
|
||||
task.getLabel().set(label);
|
||||
task.getSurfaceDescription()
|
||||
.set(extension.getDescription() == null ? "" : extension.getDescription());
|
||||
task.getRationale().set(extension.getRationale());
|
||||
task.getOwningProjectPath().set(project.getPath());
|
||||
task.getApprovalProperty().set(approvalProperty);
|
||||
task.getCeilingProperty().set(ceilingProperty);
|
||||
task.getApproved().set(approved);
|
||||
task.getCeilingRaiseApproved().set(ceilingApproved);
|
||||
});
|
||||
|
||||
// The leaf's `check`, so a pull request that changes a public type fails there (owner
|
||||
// decision 20, 2026-09-25). It used to run only in `mainCheck`, which reported the change
|
||||
// after it had merged.
|
||||
project
|
||||
.getTasks()
|
||||
.matching(task -> task.getName().equals("check"))
|
||||
.configureEach(task -> task.dependsOn(verify));
|
||||
});
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package dev.caskeleton.buildlogic.apisurface;
|
||||
|
||||
import dev.caskeleton.buildlogic.ApiSurfacePolicy;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.OutputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.work.DisableCachingByDefault;
|
||||
|
||||
@DisableCachingByDefault(because = "This task intentionally updates a committed review baseline")
|
||||
public abstract class UpdateApiSurfaceTask extends DefaultTask {
|
||||
@InputFiles
|
||||
public abstract ConfigurableFileCollection getSourceRoots();
|
||||
|
||||
@OutputFile
|
||||
public abstract RegularFileProperty getBaseline();
|
||||
|
||||
@Input public abstract Property<String> getLabel();
|
||||
@Input public abstract Property<String> getSurfaceDescription();
|
||||
@Input public abstract ListProperty<String> getRationale();
|
||||
@Input public abstract Property<String> getOwningProjectPath();
|
||||
@Input public abstract Property<String> getApprovalProperty();
|
||||
@Input public abstract Property<String> getCeilingProperty();
|
||||
@Input public abstract Property<Boolean> getApproved();
|
||||
@Input public abstract Property<Boolean> getCeilingRaiseApproved();
|
||||
|
||||
@TaskAction
|
||||
public void updateSurface() {
|
||||
if (!getApproved().get()) {
|
||||
throw new GradleException(
|
||||
getName()
|
||||
+ " requires -P"
|
||||
+ getApprovalProperty().get()
|
||||
+ ": growing the public surface is a review decision, not a build step.");
|
||||
}
|
||||
List<File> roots = getSourceRoots().getFiles().stream().sorted().toList();
|
||||
String rendered;
|
||||
File baseline = getBaseline().get().getAsFile();
|
||||
try {
|
||||
rendered =
|
||||
ApiSurfacePolicy.render(
|
||||
roots,
|
||||
getLabel().get(),
|
||||
getSurfaceDescription().get(),
|
||||
getRationale().get(),
|
||||
getOwningProjectPath().get(),
|
||||
getName(),
|
||||
getApprovalProperty().get());
|
||||
if (baseline.isFile()) {
|
||||
ApiSurfacePolicy.requireNoUnapprovedGrowth(
|
||||
getName(),
|
||||
getOwningProjectPath().get(),
|
||||
getApprovalProperty().get(),
|
||||
getCeilingProperty().get(),
|
||||
ApiSurfacePolicy.countTypes(
|
||||
Files.readString(baseline.toPath(), StandardCharsets.UTF_8)),
|
||||
rendered,
|
||||
getCeilingRaiseApproved().get());
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to read " + baseline, exception);
|
||||
} catch (IllegalStateException invalidSurface) {
|
||||
throw new GradleException(invalidSurface.getMessage(), invalidSurface);
|
||||
}
|
||||
|
||||
File parent = baseline.getParentFile();
|
||||
if (!parent.isDirectory() && !parent.mkdirs()) {
|
||||
throw new GradleException("Could not create API surface baseline directory " + parent);
|
||||
}
|
||||
try {
|
||||
Files.writeString(baseline.toPath(), rendered, StandardCharsets.UTF_8);
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to write " + baseline, exception);
|
||||
}
|
||||
getLogger().lifecycle("{}: wrote {}", getName(), baseline);
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package dev.caskeleton.buildlogic.apisurface;
|
||||
|
||||
import dev.caskeleton.buildlogic.ApiSurfacePolicy;
|
||||
import dev.caskeleton.buildlogic.JavaPublicTypes;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFile;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.Optional;
|
||||
import org.gradle.api.tasks.PathSensitive;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.work.DisableCachingByDefault;
|
||||
|
||||
@DisableCachingByDefault(because = "Verification task has no reusable outputs")
|
||||
public abstract class VerifyApiSurfaceTask extends DefaultTask {
|
||||
@InputFiles
|
||||
public abstract ConfigurableFileCollection getSourceRoots();
|
||||
|
||||
@Internal
|
||||
public abstract RegularFileProperty getBaseline();
|
||||
|
||||
@Input
|
||||
public String getBaselinePath() {
|
||||
return getBaseline().get().getAsFile().getAbsolutePath();
|
||||
}
|
||||
|
||||
@Input public abstract Property<String> getLabel();
|
||||
@Input public abstract Property<String> getSurfaceDescription();
|
||||
@Input public abstract ListProperty<String> getRationale();
|
||||
@Input public abstract Property<String> getOwningProjectPath();
|
||||
@Input public abstract Property<String> getUpdateTaskName();
|
||||
@Input public abstract Property<String> getApprovalProperty();
|
||||
@Input public abstract Property<Boolean> getUpdateApproved();
|
||||
|
||||
/** Other leaves' production sources, held to the adopter baseline when one is declared. */
|
||||
@InputFiles
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
public abstract ConfigurableFileCollection getAdopterSources();
|
||||
|
||||
@Optional
|
||||
@InputFile
|
||||
public abstract RegularFileProperty getAdopterBaseline();
|
||||
|
||||
@TaskAction
|
||||
public void verifySurface() {
|
||||
if (getUpdateApproved().get()) {
|
||||
throw new GradleException(
|
||||
getName()
|
||||
+ " is read-only; use "
|
||||
+ getUpdateTaskName().get()
|
||||
+ " to record an approved change.");
|
||||
}
|
||||
List<File> roots = getSourceRoots().getFiles().stream().sorted().toList();
|
||||
try {
|
||||
String rendered =
|
||||
ApiSurfacePolicy.render(
|
||||
roots,
|
||||
getLabel().get(),
|
||||
getSurfaceDescription().get(),
|
||||
getRationale().get(),
|
||||
getOwningProjectPath().get(),
|
||||
getUpdateTaskName().get(),
|
||||
getApprovalProperty().get());
|
||||
ApiSurfacePolicy.verify(
|
||||
getName(),
|
||||
getUpdateTaskName().get(),
|
||||
getOwningProjectPath().get(),
|
||||
getApprovalProperty().get(),
|
||||
getBaseline().get().getAsFile(),
|
||||
rendered);
|
||||
if (getAdopterBaseline().isPresent()) {
|
||||
ApiSurfacePolicy.verifyAdopters(
|
||||
getName(),
|
||||
rendered,
|
||||
getAdopterBaseline().get().getAsFile(),
|
||||
JavaPublicTypes.imports(getAdopterSources().getFiles()));
|
||||
}
|
||||
} catch (IllegalStateException invalidSurface) {
|
||||
throw new GradleException(invalidSurface.getMessage(), invalidSurface);
|
||||
}
|
||||
getLogger().lifecycle("{}: OK — the committed public API surface is unchanged.", getName());
|
||||
}
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
package dev.caskeleton.buildlogic.architecture;
|
||||
|
||||
import dev.caskeleton.buildlogic.ModuleRegistry;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.SourceSetContainer;
|
||||
|
||||
public final class ArchitecturePlugin implements Plugin<Project> {
|
||||
private static final List<String> PRODUCTION_DECLARATIONS =
|
||||
List.of("api", "implementation", "compileOnly", "runtimeOnly");
|
||||
/** The registry, relative to the repository root. */
|
||||
public static final String REGISTRY = "config/architecture/modules.json";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
// One build, rooted at the repository root: the registry is the root's, and every source_path
|
||||
// is relative to it (the template's main build sits in src/, which is why its copy reads the
|
||||
// registry relative to the parent).
|
||||
Project root = project.getRootProject();
|
||||
File repositoryRoot = root.getProjectDir();
|
||||
File registryFile = new File(repositoryRoot, REGISTRY);
|
||||
ModuleRegistry registry = ModuleRegistry.read(registryFile, repositoryRoot);
|
||||
List<ModuleRegistry.Module> modules = registry.modulesForBuild("main");
|
||||
List<String> registryViolations = registryViolations(registry, modules);
|
||||
|
||||
var clean =
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"verifyCleanArchitectureDependencies",
|
||||
VerifyCleanArchitectureDependenciesTask.class,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription("Verifies Clean Architecture project dependency direction.");
|
||||
task.getRegistryFile().fileValue(registryFile);
|
||||
task.getRegistryViolations().set(registryViolations);
|
||||
task.getUnregisteredBuildScripts()
|
||||
.set(registry.unregisteredBuildScripts(root.getProjectDir()));
|
||||
});
|
||||
var ignoredSources =
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"verifyNoIgnoredSourcePackages",
|
||||
VerifyNoIgnoredSourcePackagesTask.class,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Fails when a Java source file lives in a package that Git ignores or would"
|
||||
+ " ignore.");
|
||||
task.getBuildRoot().set(root.getLayout().getProjectDirectory());
|
||||
});
|
||||
|
||||
project
|
||||
.getGradle()
|
||||
.projectsEvaluated(
|
||||
ignored -> {
|
||||
Set<String> declaredModules = new HashSet<>();
|
||||
root.getSubprojects().stream()
|
||||
.filter(sub -> sub.getChildProjects().isEmpty())
|
||||
.forEach(sub -> declaredModules.add(sub.getPath().replaceFirst("^:", "")));
|
||||
// One task per module, registered in the project that owns the configurations. The
|
||||
// root task used to walk every other project and resolve its `compileClasspath`,
|
||||
// which asks Gradle for state another project holds the lock on — with
|
||||
// `org.gradle.parallel=true` that is a hard failure, and it is why the flag was
|
||||
// turned off instead of the verification moved.
|
||||
List<String> moduleTaskPaths = new ArrayList<>();
|
||||
for (ModuleRegistry.Module module : modules) {
|
||||
Project owner = root.project(module.gradlePath());
|
||||
Set<String> allowed = new HashSet<>();
|
||||
for (String dependencyId : module.allowedDependencies()) {
|
||||
ModuleRegistry.Module dependency = registry.byId(dependencyId);
|
||||
if (dependency != null) {
|
||||
allowed.add(dependency.gradlePath().replaceFirst("^:", ""));
|
||||
}
|
||||
}
|
||||
Set<String> declaredEdges = declaredProjectEdges(owner);
|
||||
Provider<ResolvedComponentResult> compileClasspathRoot =
|
||||
owner
|
||||
.getConfigurations()
|
||||
.getByName("compileClasspath")
|
||||
.getIncoming()
|
||||
.getResolutionResult()
|
||||
.getRootComponent();
|
||||
String moduleName = module.gradlePath().replaceFirst("^:", "");
|
||||
owner
|
||||
.getTasks()
|
||||
.register(
|
||||
"verifyModuleDependencyDirection",
|
||||
VerifyModuleDependencyDirectionTask.class,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Verifies this module's declared and compile-visible project edges"
|
||||
+ " against the architecture registry.");
|
||||
task.getModuleName().set(moduleName);
|
||||
task.getAllowedDependencies().set(allowed);
|
||||
task.getDeclaredProjectEdges().set(declaredEdges);
|
||||
task.getCompileClasspathRoot().set(compileClasspathRoot);
|
||||
});
|
||||
moduleTaskPaths.add(module.gradlePath() + ":verifyModuleDependencyDirection");
|
||||
}
|
||||
clean.configure(
|
||||
task -> {
|
||||
task.getDeclaredModules().set(declaredModules);
|
||||
task.getGovernedModules()
|
||||
.set(
|
||||
modules.stream()
|
||||
.map(module -> module.gradlePath().replaceFirst("^:", ""))
|
||||
.toList());
|
||||
task.dependsOn(moduleTaskPaths);
|
||||
});
|
||||
|
||||
// Every source set of every project — testFixtures, integrationTest, systemTest and
|
||||
// the sample included — because a file Git drops is lost whichever lane owns it.
|
||||
// Directories under a build directory are generated and never committed.
|
||||
List<File> sourceRoots = new ArrayList<>();
|
||||
for (Project sub : root.getSubprojects()) {
|
||||
SourceSetContainer sourceSets =
|
||||
sub.getExtensions().findByType(SourceSetContainer.class);
|
||||
if (sourceSets == null) {
|
||||
continue;
|
||||
}
|
||||
Path buildDirectory = sub.getLayout().getBuildDirectory().get().getAsFile().toPath();
|
||||
for (SourceSet sourceSet : sourceSets) {
|
||||
for (File sourceRoot : sourceSet.getJava().getSrcDirs()) {
|
||||
if (!sourceRoot.toPath().startsWith(buildDirectory)) {
|
||||
sourceRoots.add(sourceRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ignoredSources.configure(task -> task.getSourceRoots().from(sourceRoots));
|
||||
});
|
||||
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"architectureCheck",
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription("Runs the build's architecture invariants.");
|
||||
task.dependsOn(clean, ignoredSources);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This module's declared {@code project(...)} edges, read while the owning project is configured.
|
||||
*
|
||||
* <p>Read here rather than in the task action: a {@link Configuration} cannot be stored in the
|
||||
* configuration cache, and every declaration this reads is final by {@code projectsEvaluated}.
|
||||
*/
|
||||
private static Set<String> declaredProjectEdges(Project owner) {
|
||||
Set<String> edges = new TreeSet<>();
|
||||
for (String name : PRODUCTION_DECLARATIONS) {
|
||||
Configuration configuration = owner.getConfigurations().findByName(name);
|
||||
if (configuration == null) {
|
||||
continue;
|
||||
}
|
||||
configuration
|
||||
.getDependencies()
|
||||
.withType(ProjectDependency.class)
|
||||
.forEach(dependency -> edges.add(dependency.getPath().replaceFirst("^:", "")));
|
||||
}
|
||||
return edges;
|
||||
}
|
||||
|
||||
private static List<String> registryViolations(
|
||||
ModuleRegistry registry, List<ModuleRegistry.Module> modules) {
|
||||
List<String> violations = new ArrayList<>();
|
||||
for (ModuleRegistry.Module module : modules) {
|
||||
for (String dependencyId : module.allowedDependencies()) {
|
||||
if (dependencyId.equals(module.id())) {
|
||||
violations.add("'" + module.id() + "' declares itself as an allowed dependency");
|
||||
continue;
|
||||
}
|
||||
ModuleRegistry.Module dependency = registry.byId(dependencyId);
|
||||
if (dependency == null) {
|
||||
violations.add(
|
||||
"'" + module.id() + "' allows unknown dependency id '" + dependencyId + "'");
|
||||
} else if (!dependency.buildName().equals(module.buildName())) {
|
||||
violations.add(
|
||||
"'" + module.id() + "' allows cross-build dependency id '" + dependencyId + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
return List.copyOf(violations);
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package dev.caskeleton.buildlogic.architecture;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
import org.gradle.api.provider.SetProperty;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.work.DisableCachingByDefault;
|
||||
|
||||
/**
|
||||
* The repository-wide half of the dependency contract.
|
||||
*
|
||||
* <p>Two questions only, and both are answered from the registry rather than from any project's
|
||||
* configurations: is the registry internally consistent, and does the set of modules it governs
|
||||
* match the set of leaves the build actually declares. A leaf that exists and is ungoverned is the
|
||||
* failure this catches — a new module cannot be added and quietly escape the direction rules.
|
||||
*
|
||||
* <p>Whether a given module's edges are allowed is {@link VerifyModuleDependencyDirectionTask}'s
|
||||
* job, one task per module, in the project that owns the configurations. That split is the whole
|
||||
* point: this task used to resolve every other project's {@code compileClasspath} itself, which
|
||||
* needs a lock it does not hold, and made {@code org.gradle.parallel=true} fail rather than merely
|
||||
* be unused.
|
||||
*/
|
||||
@DisableCachingByDefault(because = "Verification of live build structure emits no reusable output")
|
||||
public abstract class VerifyCleanArchitectureDependenciesTask extends DefaultTask {
|
||||
|
||||
@InputFile
|
||||
public abstract RegularFileProperty getRegistryFile();
|
||||
|
||||
@Input
|
||||
public abstract ListProperty<String> getRegistryViolations();
|
||||
|
||||
/** Every leaf the build declares. */
|
||||
@Input
|
||||
public abstract SetProperty<String> getDeclaredModules();
|
||||
|
||||
/** Every module the registry governs. */
|
||||
@Input
|
||||
public abstract ListProperty<String> getGovernedModules();
|
||||
|
||||
/**
|
||||
* Build scripts under the Gradle root that no registry entry owns. The settings plugin includes
|
||||
* registered modules only, so such a leaf never reaches {@link #getDeclaredModules()} and the
|
||||
* comparison below cannot see it (review 2026-11-01 08-05).
|
||||
*/
|
||||
@Input
|
||||
public abstract ListProperty<String> getUnregisteredBuildScripts();
|
||||
|
||||
@TaskAction
|
||||
public void verifyDependencies() {
|
||||
List<String> registryViolations = getRegistryViolations().get();
|
||||
if (!registryViolations.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"config/architecture/modules.json declares impossible edges:\n "
|
||||
+ String.join("\n ", registryViolations));
|
||||
}
|
||||
|
||||
List<String> unregistered = getUnregisteredBuildScripts().get();
|
||||
if (!unregistered.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"These build scripts have no registry entry, so the build does not include them and no"
|
||||
+ " gate compiles or tests them. Register each in config/architecture/modules.json"
|
||||
+ " or delete it:\n "
|
||||
+ String.join("\n ", unregistered));
|
||||
}
|
||||
|
||||
Set<String> declared = getDeclaredModules().get();
|
||||
Set<String> governed = new HashSet<>(getGovernedModules().get());
|
||||
Set<String> missingFromBuild = new TreeSet<>(governed);
|
||||
missingFromBuild.removeAll(declared);
|
||||
Set<String> missingFromPolicy = new TreeSet<>(declared);
|
||||
missingFromPolicy.removeAll(governed);
|
||||
if (!missingFromBuild.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"Clean Architecture dependency policy references missing Gradle modules "
|
||||
+ missingFromBuild
|
||||
+ ". Declared modules are "
|
||||
+ new TreeSet<>(declared)
|
||||
+ ".");
|
||||
}
|
||||
if (!missingFromPolicy.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"Gradle modules "
|
||||
+ missingFromPolicy
|
||||
+ " are not covered by verifyCleanArchitectureDependencies. Add an explicit dependency"
|
||||
+ " policy before using them.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package dev.caskeleton.buildlogic.architecture;
|
||||
|
||||
import dev.caskeleton.buildlogic.ResolvedComponents;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.SetProperty;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.work.DisableCachingByDefault;
|
||||
|
||||
/**
|
||||
* One module's own dependency-direction check, run by the project that owns the configurations.
|
||||
*
|
||||
* <p>This used to be a loop inside the root task, which reached into every other project and
|
||||
* resolved its {@code compileClasspath}. That is the one thing a task must not do: a configuration
|
||||
* belongs to its project, and resolving it from somewhere else asks Gradle for state it holds under
|
||||
* another project's lock. With {@code org.gradle.parallel=true} that is not a style objection — the
|
||||
* root task failed outright, which is why the flag was turned back off rather than the verification
|
||||
* moved. Here the task and the configurations are in the same project, so the check costs the build
|
||||
* nothing to parallelise.
|
||||
*
|
||||
* <p>The task keeps no {@code Configuration}. It keeps the declared project edges as strings and the
|
||||
* compile classpath's resolved root component, both established while the owning project is
|
||||
* configuring. Holding the configurations themselves is what made this task unstorable in the
|
||||
* configuration cache.
|
||||
*
|
||||
* <p>The root task keeps what is genuinely repository-wide — the registry's own consistency, and
|
||||
* whether the set of governed modules matches the set of declared ones — and depends on every one of
|
||||
* these.
|
||||
*/
|
||||
@DisableCachingByDefault(because = "Verification inspects live declarations and a resolved classpath")
|
||||
public abstract class VerifyModuleDependencyDirectionTask extends DefaultTask {
|
||||
|
||||
/** The registry name of the module this task governs. */
|
||||
@Input
|
||||
public abstract Property<String> getModuleName();
|
||||
|
||||
/** The module ids this module's registry entry permits. */
|
||||
@Input
|
||||
public abstract SetProperty<String> getAllowedDependencies();
|
||||
|
||||
/** Project paths this module declares in {@code api/implementation/compileOnly/runtimeOnly}. */
|
||||
@Input
|
||||
public abstract SetProperty<String> getDeclaredProjectEdges();
|
||||
|
||||
/** Root of this module's resolved {@code compileClasspath}. */
|
||||
@Internal
|
||||
public abstract Property<ResolvedComponentResult> getCompileClasspathRoot();
|
||||
|
||||
@TaskAction
|
||||
public void verify() {
|
||||
String moduleName = getModuleName().get();
|
||||
Set<String> allowed = getAllowedDependencies().get();
|
||||
|
||||
Set<String> actual = new HashSet<>(getDeclaredProjectEdges().get());
|
||||
// Declared edges are not the whole story: an `api(project(...))` two leaves away is visible to
|
||||
// this module's compiler and is therefore a real edge, whatever this build file says.
|
||||
for (ResolvedComponentResult component :
|
||||
ResolvedComponents.reachableFrom(getCompileClasspathRoot().get())) {
|
||||
if (component.getId() instanceof ProjectComponentIdentifier project) {
|
||||
String projectPath = project.getProjectPath().replaceFirst("^:", "");
|
||||
if (!projectPath.equals(moduleName)) {
|
||||
actual.add(projectPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> forbidden = new TreeSet<>(actual);
|
||||
forbidden.removeAll(allowed);
|
||||
if (!forbidden.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"Module ':"
|
||||
+ moduleName
|
||||
+ "' has forbidden project dependencies "
|
||||
+ forbidden
|
||||
+ ". Allowed dependencies are "
|
||||
+ new TreeSet<>(allowed)
|
||||
+ ".\nDirect and compile-visible production project edges must be explicitly"
|
||||
+ " registered.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
package dev.caskeleton.buildlogic.architecture;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.file.DirectoryProperty;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.PathSensitive;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.work.DisableCachingByDefault;
|
||||
|
||||
@DisableCachingByDefault(because = "Verification consults Git ignore rules")
|
||||
public abstract class VerifyNoIgnoredSourcePackagesTask extends DefaultTask {
|
||||
private static final Set<String> OUTPUT_DIRECTORY_NAMES =
|
||||
Set.of("build", "out", "target", "bin", "classes");
|
||||
|
||||
@InputFiles
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
public abstract ConfigurableFileCollection getSourceRoots();
|
||||
|
||||
@Internal
|
||||
public abstract DirectoryProperty getBuildRoot();
|
||||
|
||||
@TaskAction
|
||||
public void verifySourcePackages() {
|
||||
List<String> violations = new ArrayList<>();
|
||||
List<File> sourceFiles = new ArrayList<>();
|
||||
for (File sourceRoot : getSourceRoots().getFiles()) {
|
||||
if (!sourceRoot.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
try (var paths = Files.walk(sourceRoot.toPath())) {
|
||||
paths
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(path -> path.getFileName().toString().endsWith(".java"))
|
||||
.forEach(
|
||||
path -> {
|
||||
File candidate = path.toFile();
|
||||
sourceFiles.add(candidate);
|
||||
var relative = sourceRoot.toPath().relativize(path);
|
||||
for (int index = 0; index < relative.getNameCount() - 1; index++) {
|
||||
String segment = relative.getName(index).toString();
|
||||
if (OUTPUT_DIRECTORY_NAMES.contains(segment)) {
|
||||
violations.add(
|
||||
candidate
|
||||
+ ": package segment '"
|
||||
+ segment
|
||||
+ "' collides with a build output directory name");
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException exception) {
|
||||
throw new GradleException("verifyNoIgnoredSourcePackages: cannot scan " + sourceRoot, exception);
|
||||
}
|
||||
}
|
||||
if (sourceFiles.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"verifyNoIgnoredSourcePackages: found no Java sources at all; the gate would pass vacuously.");
|
||||
}
|
||||
|
||||
File repositoryRoot = checkoutRoot(getBuildRoot().get().getAsFile());
|
||||
if (repositoryRoot == null) {
|
||||
getLogger().lifecycle("verifyNoIgnoredSourcePackages: not a Git checkout; naming rule only.");
|
||||
} else {
|
||||
String stdin = sourceFiles.stream().map(File::getPath).collect(java.util.stream.Collectors.joining("\n"));
|
||||
String output = checkIgnore(repositoryRoot, stdin);
|
||||
for (String line : output.lines().filter(value -> !value.isBlank()).toList()) {
|
||||
String[] parts = line.split("\\t", -1);
|
||||
String rule = parts.length > 1 ? parts[0] : "(unknown rule)";
|
||||
String path = parts.length > 1 ? String.join("\t", java.util.Arrays.copyOfRange(parts, 1, parts.length)) : line;
|
||||
violations.add(path + ": ignored by " + rule + "; it will not survive a fresh checkout");
|
||||
}
|
||||
}
|
||||
|
||||
if (!violations.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"verifyNoIgnoredSourcePackages: "
|
||||
+ violations.size()
|
||||
+ " source file(s) Git cannot carry:\n "
|
||||
+ String.join("\n ", violations));
|
||||
}
|
||||
getLogger()
|
||||
.lifecycle(
|
||||
"verifyNoIgnoredSourcePackages: OK — {} Java sources are all committable.",
|
||||
sourceFiles.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* The nearest directory at or above {@code start} holding {@code .git} (a directory, or the file
|
||||
* a worktree has), or {@code null} for an exported source tree. Decided on the file system rather
|
||||
* than by asking Git, so that Git failing inside a checkout cannot read as "not a checkout".
|
||||
*/
|
||||
private static File checkoutRoot(File start) {
|
||||
for (File directory = start.getAbsoluteFile(); directory != null; directory = directory.getParentFile()) {
|
||||
if (new File(directory, ".git").exists()) {
|
||||
return directory;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Git's ignore verdicts for the paths on {@code stdin}. Fails closed: inside a checkout, a git that
|
||||
* cannot run or exits with anything but 0 (some path ignored) or 1 (none ignored) is an error, not
|
||||
* an empty answer — an empty answer is how the gate used to pass without asking.
|
||||
*/
|
||||
private String checkIgnore(File repositoryRoot, String stdin) {
|
||||
List<String> command =
|
||||
List.of("git", "-C", repositoryRoot.getPath(), "check-ignore", "--no-index", "-v", "--stdin");
|
||||
Process process;
|
||||
try {
|
||||
process = new ProcessBuilder(command).start();
|
||||
} catch (IOException unavailable) {
|
||||
throw new GradleException(
|
||||
"verifyNoIgnoredSourcePackages: "
|
||||
+ repositoryRoot
|
||||
+ " is a Git checkout but git could not run: "
|
||||
+ unavailable.getMessage(),
|
||||
unavailable);
|
||||
}
|
||||
try {
|
||||
try (var input = process.getOutputStream()) {
|
||||
input.write(stdin.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException exitedEarly) {
|
||||
// git stopped reading, which it does when it fails; its exit code below says why.
|
||||
}
|
||||
String output = new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
|
||||
String error = new String(process.getErrorStream().readAllBytes(), StandardCharsets.UTF_8);
|
||||
int exitCode = process.waitFor();
|
||||
if (exitCode != 0 && exitCode != 1) {
|
||||
throw new GradleException(
|
||||
"verifyNoIgnoredSourcePackages: `git check-ignore` exited "
|
||||
+ exitCode
|
||||
+ " inside the Git checkout at "
|
||||
+ repositoryRoot
|
||||
+ ": "
|
||||
+ error.strip());
|
||||
}
|
||||
return output;
|
||||
} catch (IOException unreadable) {
|
||||
throw new GradleException(
|
||||
"verifyNoIgnoredSourcePackages: could not read `git check-ignore` output", unreadable);
|
||||
} catch (InterruptedException interrupted) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new GradleException("verifyNoIgnoredSourcePackages: git command interrupted", interrupted);
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package dev.caskeleton.buildlogic.convention;
|
||||
|
||||
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.VersionCatalogsExtension;
|
||||
|
||||
public final class GrpcPlatformModuleConventionPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().apply("ca.platform-module");
|
||||
|
||||
var catalogs = project.getExtensions().getByType(VersionCatalogsExtension.class);
|
||||
var grpc =
|
||||
catalogs
|
||||
.named("libs")
|
||||
.findVersion("grpc")
|
||||
.orElseThrow(
|
||||
() ->
|
||||
new GradleException(
|
||||
"Version catalog 'libs' must define version 'grpc' for ca.grpc-platform-module"));
|
||||
String grpcVersion = grpc.getRequiredVersion();
|
||||
DependencyManagementExtension dependencyManagement =
|
||||
project.getExtensions().getByType(DependencyManagementExtension.class);
|
||||
dependencyManagement.imports(imports -> imports.mavenBom("io.grpc:grpc-bom:" + grpcVersion));
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package dev.caskeleton.buildlogic.convention;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
public final class JavaLibraryConventionPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().apply("ca.quality-conventions");
|
||||
project.getDependencies().add("testImplementation", "org.junit.jupiter:junit-jupiter");
|
||||
project.getDependencies().add("testImplementation", "org.assertj:assertj-core");
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package dev.caskeleton.buildlogic.convention;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
public final class PlatformModuleConventionPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().apply("ca.java-library");
|
||||
project.getPluginManager().apply("java-library");
|
||||
// Every module of this repository is a published library artifact.
|
||||
project.getPluginManager().apply("ca.library-publishing");
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package dev.caskeleton.buildlogic.convention;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
|
||||
public final class SpringConfigConventionPlugin implements Plugin<Project> {
|
||||
/**
|
||||
* How a module declares a property the processor cannot see — a switch read only by
|
||||
* {@code @ConditionalOnProperty} — so the environment contract finds it in the metadata.
|
||||
*/
|
||||
private static final String ADDITIONAL_METADATA =
|
||||
"src/main/resources/META-INF/additional-spring-configuration-metadata.json";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project
|
||||
.getDependencies()
|
||||
.add("annotationProcessor", "org.springframework.boot:spring-boot-configuration-processor");
|
||||
// The processor merges the additional metadata from the processed resources, so compileJava
|
||||
// runs after processResources and reruns when that one file changes. Without this it could run
|
||||
// first, or stay up to date when only that file changed, and the declared switch was missing
|
||||
// from the metadata verifyEnvKeys reads (review 2026-11-04 RR2-04-05). Only that file is an
|
||||
// input: every other resource leaves compileJava's cache key alone.
|
||||
project
|
||||
.getPluginManager()
|
||||
.withPlugin(
|
||||
"java",
|
||||
ignored ->
|
||||
project
|
||||
.getTasks()
|
||||
.named(
|
||||
"compileJava",
|
||||
compile -> {
|
||||
compile.dependsOn(project.getTasks().named("processResources"));
|
||||
// files(), not file(): most modules have no such file.
|
||||
compile
|
||||
.getInputs()
|
||||
.files(project.file(ADDITIONAL_METADATA))
|
||||
.withPropertyName("additionalConfigurationMetadata")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE);
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
package dev.caskeleton.buildlogic.java;
|
||||
|
||||
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.VersionCatalogsExtension;
|
||||
import org.gradle.api.artifacts.dsl.LockMode;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.plugins.jvm.JvmTestSuite;
|
||||
import org.gradle.api.provider.ProviderFactory;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||
import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.api.tasks.testing.Test;
|
||||
import org.gradle.jvm.toolchain.JavaLanguageVersion;
|
||||
import org.gradle.testing.base.TestingExtension;
|
||||
|
||||
public final class JavaConventionsPlugin implements Plugin<Project> {
|
||||
private static final List<String> COMPILER_ARGS =
|
||||
List.of("-parameters", "-Werror", "-Xlint:deprecation", "-Xlint:unchecked");
|
||||
|
||||
/** What {@link #sourceRevision} returns when the build was given no commit id. */
|
||||
public static final String UNKNOWN_REVISION = "unknown";
|
||||
|
||||
/**
|
||||
* The commit this build names: {@code -PgitRevision}, {@code GIT_SHA} or {@code GITHUB_SHA}, cut
|
||||
* to twelve lowercase hex characters, or {@link #UNKNOWN_REVISION} when none of them is a commit
|
||||
* id. The root {@code verifyReleaseProvenance} fails on the latter.
|
||||
*/
|
||||
public static String sourceRevision(ProviderFactory providers) {
|
||||
String declared =
|
||||
providers
|
||||
.gradleProperty("gitRevision")
|
||||
.orElse(providers.environmentVariable("GIT_SHA"))
|
||||
.orElse(providers.environmentVariable("GITHUB_SHA"))
|
||||
.getOrElse("");
|
||||
return declared.matches("(?i)[0-9a-f]{7,40}")
|
||||
? declared.toLowerCase(Locale.ROOT).substring(0, Math.min(12, declared.length()))
|
||||
: UNKNOWN_REVISION;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version this build names: the release tag ({@code -PreleaseTag} or {@code RELEASE_TAG},
|
||||
* {@code vMAJOR.MINOR.PATCH}) without its {@code v}, else {@code -PreleaseVersion} or {@code
|
||||
* RELEASE_VERSION}, else {@code 0.0.1}. A tag is how release.yml says which version it publishes,
|
||||
* so a tag of any other shape fails here, before a single module is built.
|
||||
*/
|
||||
public static String releaseVersion(ProviderFactory providers) {
|
||||
String declared =
|
||||
providers
|
||||
.gradleProperty("releaseVersion")
|
||||
.orElse(providers.environmentVariable("RELEASE_VERSION"))
|
||||
.getOrElse("");
|
||||
String tag =
|
||||
providers
|
||||
.gradleProperty("releaseTag")
|
||||
.orElse(providers.environmentVariable("RELEASE_TAG"))
|
||||
.getOrElse("");
|
||||
if (tag.isEmpty()) {
|
||||
return declared.isEmpty() ? "0.0.1" : declared;
|
||||
}
|
||||
if (!tag.matches("v\\d+\\.\\d+\\.\\d+")) {
|
||||
throw new GradleException(
|
||||
"release tag must be vMAJOR.MINOR.PATCH with no suffix; got '" + tag + "'.");
|
||||
}
|
||||
String fromTag = tag.substring(1);
|
||||
if (!declared.isEmpty() && !declared.equals(fromTag)) {
|
||||
throw new GradleException(
|
||||
"release tag " + tag + " and releaseVersion " + declared + " name different versions.");
|
||||
}
|
||||
return fromTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().apply("java");
|
||||
project.getPluginManager().apply("io.spring.dependency-management");
|
||||
// `ca.strict-test-lane` supplies the per-leaf `*TestLaneCheck` aggregates that the root's
|
||||
// repository-wide tasks depend on by path, so every Java leaf has to have them or the root task
|
||||
// graph cannot be built. `ca.api-surface` is opt-in: a leaf that wants it says so.
|
||||
project.getPluginManager().apply("ca.strict-test-lane");
|
||||
|
||||
var catalog = project.getExtensions().getByType(VersionCatalogsExtension.class).named("libs");
|
||||
String springBootVersion = catalog.findVersion("springBoot").orElseThrow().getRequiredVersion();
|
||||
|
||||
ProviderFactory providers = project.getProviders();
|
||||
// The Maven group every module publishes under. A property, not a constant, so this copy of the
|
||||
// template's convention reads the same in every library repository (gradle.properties).
|
||||
String libraryGroup = providers.gradleProperty("libraryGroup").getOrElse("");
|
||||
if (libraryGroup.isBlank()) {
|
||||
throw new GradleException("gradle.properties must set libraryGroup (the Maven group).");
|
||||
}
|
||||
project.setGroup(libraryGroup);
|
||||
String releaseVersion = releaseVersion(providers);
|
||||
if (!releaseVersion.matches("\\d+\\.\\d+\\.\\d+")) {
|
||||
throw new GradleException(
|
||||
"releaseVersion must be MAJOR.MINOR.PATCH without a leading 'v', pre-release or build"
|
||||
+ " metadata; got '"
|
||||
+ releaseVersion
|
||||
+ "'.");
|
||||
}
|
||||
// The release version alone, never the revision: a revision in the version put a new jar name in
|
||||
// every leaf's build/libs on every commit, which is what the deleted archive-hygiene plugin
|
||||
// existed to clean up (review BUILD-O3-5). The revision stays in each jar's manifest
|
||||
// (Build-Revision) and in app-bootstrap's build-info.properties, which reads the `sourceRevision`
|
||||
// extra property set here. This replaced the root `ca.release-provenance` plugin.
|
||||
String buildRevision = sourceRevision(providers);
|
||||
project.setVersion(releaseVersion + (buildRevision.equals(UNKNOWN_REVISION) ? "-SNAPSHOT" : ""));
|
||||
project.getExtensions().getExtraProperties().set("sourceRevision", buildRevision);
|
||||
|
||||
JavaPluginExtension javaExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
javaExtension.getToolchain().getLanguageVersion().set(JavaLanguageVersion.of(21));
|
||||
|
||||
project.getDependencyLocking().lockAllConfigurations();
|
||||
project.getDependencyLocking().getLockMode().set(LockMode.STRICT);
|
||||
|
||||
project
|
||||
.getTasks()
|
||||
.withType(AbstractArchiveTask.class)
|
||||
.configureEach(
|
||||
archive -> {
|
||||
archive.setPreserveFileTimestamps(false);
|
||||
archive.setReproducibleFileOrder(true);
|
||||
archive.dirPermissions(permissions -> permissions.unix("755"));
|
||||
archive.filePermissions(permissions -> permissions.unix("644"));
|
||||
});
|
||||
project
|
||||
.getTasks()
|
||||
.withType(Jar.class)
|
||||
.configureEach(
|
||||
jar ->
|
||||
jar.getManifest()
|
||||
.attributes(
|
||||
java.util.Map.of(
|
||||
"Implementation-Version", project.getVersion().toString(),
|
||||
"Build-Revision", buildRevision)));
|
||||
|
||||
// Both attributes change on every commit, and every test and SpotBugs task has this jar on its
|
||||
// runtime classpath: without the normalization a CI build never reuses a cached test result
|
||||
// (review O-4c). They describe the build, not the classes, so a runtime classpath ignores them.
|
||||
project
|
||||
.getNormalization()
|
||||
.getRuntimeClasspath()
|
||||
.metaInf(
|
||||
metaInf -> {
|
||||
metaInf.ignoreAttribute("Implementation-Version");
|
||||
metaInf.ignoreAttribute("Build-Revision");
|
||||
});
|
||||
|
||||
project
|
||||
.getTasks()
|
||||
.withType(JavaCompile.class)
|
||||
.configureEach(
|
||||
compile -> {
|
||||
compile.getOptions().setEncoding("UTF-8");
|
||||
for (String argument : COMPILER_ARGS) {
|
||||
if (!compile.getOptions().getCompilerArgs().contains(argument)) {
|
||||
compile.getOptions().getCompilerArgs().add(argument);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Spring dependency-management reads Maven BOM property overrides from project extra properties.
|
||||
// commons-lang3: the Boot BOM manages 3.19.0, and the SpotBugs worker (which shares the
|
||||
// buildscript's commons-lang3) fails with NoClassDefFoundError on it; 3.20.0 is what it needs.
|
||||
// Delete the override once the BOM manages 3.20.0 or later. (A `netty.version` override sat
|
||||
// here too and was removed: it pinned the version the BOM already manages, review 2026-11-01
|
||||
// O-11c.)
|
||||
project.getExtensions().getExtraProperties().set("commons-lang3.version", "3.20.0");
|
||||
// httpcore5: the Boot BOM manages 5.3.6, and the 5.3 line has no fix for two High advisories
|
||||
// (CVE-2026-54399, unbounded HTTP/1 header parsing; CVE-2026-54428, unbounded HPACK header
|
||||
// list). 5.4.3 is the first fixed core. httpclient5 moves with it because each client release
|
||||
// is built against one core line (5.5 on 5.3, 5.6 on 5.4); 5.6.3 declares 5.4.3 and also
|
||||
// carries the Content-Encoding connection-leak fix 5.5.2 lacks. Delete both once the BOM
|
||||
// manages httpcore5 5.4.3 or later.
|
||||
project.getExtensions().getExtraProperties().set("httpcore5.version", "5.4.3");
|
||||
project.getExtensions().getExtraProperties().set("httpclient5.version", "5.6.3");
|
||||
DependencyManagementExtension dependencyManagement =
|
||||
project.getExtensions().getByType(DependencyManagementExtension.class);
|
||||
dependencyManagement.imports(
|
||||
imports ->
|
||||
imports.mavenBom(
|
||||
"org.springframework.boot:spring-boot-dependencies:" + springBootVersion));
|
||||
// The catalog's `pinned-*` libraries: no leaf declares them, and their upstream still brings a
|
||||
// version with a High or Critical advisory (the catalog says which and from where). Dependency
|
||||
// management rather than a Gradle constraint because it reaches every configuration, so the
|
||||
// Checkstyle and Error Prone classpaths get the fixed version too. A leaf that declares one of
|
||||
// these itself, with a version, still wins.
|
||||
for (String alias : catalog.getLibraryAliases()) {
|
||||
if (alias.startsWith("pinned.")) {
|
||||
var library = catalog.findLibrary(alias).orElseThrow().get();
|
||||
String coordinates =
|
||||
library.getModule() + ":" + library.getVersionConstraint().getRequiredVersion();
|
||||
dependencyManagement.dependencies(dependencies -> dependencies.dependency(coordinates));
|
||||
}
|
||||
}
|
||||
|
||||
project
|
||||
.getDependencies()
|
||||
.add("testRuntimeOnly", "org.junit.platform:junit-platform-launcher");
|
||||
|
||||
project.getTasks().named("test", Test.class).configure(Test::useJUnitPlatform);
|
||||
|
||||
// A leaf's extra test source sets are JVM test suites (review BUILD-O3-5 replaced the
|
||||
// ca.auxiliary-source-set plugin). A suite adds its framework dependency with Gradle's default
|
||||
// JUnit version, and a version written into a dependency outranks the Spring Boot BOM — so the
|
||||
// suites would run a different JUnit from `test`. They get the BOM's version instead.
|
||||
project
|
||||
.getExtensions()
|
||||
.getByType(TestingExtension.class)
|
||||
.getSuites()
|
||||
.withType(JvmTestSuite.class)
|
||||
.matching(suite -> !suite.getName().equals("test"))
|
||||
.configureEach(
|
||||
suite ->
|
||||
suite.useJUnitJupiter(
|
||||
project.provider(
|
||||
() ->
|
||||
dependencyManagement
|
||||
.getManagedVersions()
|
||||
.get("org.junit.jupiter:junit-jupiter"))));
|
||||
|
||||
// The main-branch stage of this leaf (the root `mainCheck` aggregates every leaf's). Empty unless
|
||||
// a convention or the leaf attaches a gate that is not worth a pull request's wait.
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"mainCheck",
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription("Runs this leaf's main-branch-stage gates.");
|
||||
});
|
||||
|
||||
boolean writeLocksRequested = project.getGradle().getStartParameter().isWriteDependencyLocks();
|
||||
var resolveAndLockAll =
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"resolveAndLockAll",
|
||||
ResolveConfigurationsTask.class,
|
||||
task -> {
|
||||
task.setGroup("build setup");
|
||||
task.setDescription(
|
||||
"Resolves every configuration and writes this project's dependency lock state.");
|
||||
task.getRequireWriteLocks().set(true);
|
||||
task.getWriteLocksRequested().set(writeLocksRequested);
|
||||
task.notCompatibleWithConfigurationCache(
|
||||
"Resolves configurations captured from the owning project");
|
||||
});
|
||||
var verifyDependencyLocks =
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"verifyDependencyLocks",
|
||||
ResolveConfigurationsTask.class,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Resolves every configuration and fails when strict dependency locks drift.");
|
||||
task.getRequireWriteLocks().set(false);
|
||||
task.getWriteLocksRequested().set(writeLocksRequested);
|
||||
task.notCompatibleWithConfigurationCache(
|
||||
"Resolves configurations captured from the owning project");
|
||||
});
|
||||
project.afterEvaluate(
|
||||
ignored -> {
|
||||
List<Configuration> resolvable =
|
||||
project.getConfigurations().stream().filter(Configuration::isCanBeResolved).toList();
|
||||
resolveAndLockAll.configure(task -> task.setConfigurationsToResolve(resolvable));
|
||||
verifyDependencyLocks.configure(task -> task.setConfigurationsToResolve(resolvable));
|
||||
});
|
||||
|
||||
// The Mockito agent on every Test JVM, attached at startup rather than self-attached. The agent
|
||||
// is the mockito-core jar alone, hence non-transitive.
|
||||
Configuration agentDependencies =
|
||||
project.getConfigurations().dependencyScope("mockitoAgentDependencies").get();
|
||||
Configuration agent =
|
||||
project
|
||||
.getConfigurations()
|
||||
.resolvable(
|
||||
"mockitoAgent",
|
||||
configuration -> {
|
||||
configuration.extendsFrom(agentDependencies);
|
||||
configuration.setTransitive(false);
|
||||
})
|
||||
.get();
|
||||
project.getDependencies().add(agentDependencies.getName(), "org.mockito:mockito-core");
|
||||
// Every Test JVM runs in UTC, so a timestamp test does not depend on the host's zone. A system
|
||||
// property rather than a JVM argument: a strict lane's own `jvmArgs` replace the argument list,
|
||||
// and this used to be repeated in 28 lanes for that reason (review 2026-11-01 O-10b).
|
||||
//
|
||||
// The container images the lanes start come from config/testing/container-images.properties,
|
||||
// each as `ca.test.image.<key>`, with the file as an input (review 2026-11-01 08-04).
|
||||
File images = containerImageCatalog(project);
|
||||
Map<String, String> containerImages = containerImages(images);
|
||||
project.getExtensions().getExtraProperties().set("testContainerImages", containerImages);
|
||||
project
|
||||
.getTasks()
|
||||
.withType(Test.class)
|
||||
.configureEach(
|
||||
test -> {
|
||||
test.systemProperty("user.timezone", "UTC");
|
||||
containerImages.forEach(
|
||||
(key, image) -> test.systemProperty(CONTAINER_IMAGE_PROPERTY_PREFIX + key, image));
|
||||
test.getInputs()
|
||||
.file(images)
|
||||
.withPathSensitivity(PathSensitivity.NONE)
|
||||
.withPropertyName("containerImageCatalog");
|
||||
});
|
||||
project
|
||||
.getTasks()
|
||||
.withType(Test.class)
|
||||
.configureEach(
|
||||
test -> {
|
||||
MockitoAgentArgumentProvider provider =
|
||||
project.getObjects().newInstance(MockitoAgentArgumentProvider.class);
|
||||
provider.getMockitoCoreClasspath().from(agent);
|
||||
provider.getOwner().set(project.getPath() + ":" + test.getName());
|
||||
test.getJvmArgumentProviders().add(provider);
|
||||
});
|
||||
}
|
||||
|
||||
/** The system property prefix under which every Test JVM receives the catalog's images. */
|
||||
public static final String CONTAINER_IMAGE_PROPERTY_PREFIX = "ca.test.image.";
|
||||
|
||||
private static File containerImageCatalog(Project project) {
|
||||
File catalog = project.getRootProject().file("config/testing/container-images.properties");
|
||||
if (!catalog.isFile()) {
|
||||
throw new GradleException("Missing test container image catalog: " + catalog);
|
||||
}
|
||||
return catalog;
|
||||
}
|
||||
|
||||
private static Map<String, String> containerImages(File catalog) {
|
||||
Properties properties = new Properties();
|
||||
try (var in = Files.newInputStream(catalog.toPath())) {
|
||||
properties.load(in);
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to read " + catalog, exception);
|
||||
}
|
||||
Map<String, String> images = new TreeMap<>();
|
||||
properties.stringPropertyNames().forEach(key -> images.put(key, properties.getProperty(key)));
|
||||
return Map.copyOf(images);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package dev.caskeleton.buildlogic.java;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Classpath;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.process.CommandLineArgumentProvider;
|
||||
|
||||
public abstract class MockitoAgentArgumentProvider implements CommandLineArgumentProvider {
|
||||
@Classpath
|
||||
public abstract ConfigurableFileCollection getMockitoCoreClasspath();
|
||||
|
||||
@Input
|
||||
public abstract Property<String> getOwner();
|
||||
|
||||
@Override
|
||||
public Iterable<String> asArguments() {
|
||||
List<File> candidates =
|
||||
getMockitoCoreClasspath().getFiles().stream()
|
||||
.filter(File::isFile)
|
||||
.filter(file -> file.getName().matches("mockito-core-[^/]+\\.jar"))
|
||||
.sorted(Comparator.comparing(File::getAbsolutePath))
|
||||
.toList();
|
||||
if (candidates.size() != 1) {
|
||||
throw new GradleException(
|
||||
getOwner().get()
|
||||
+ ": expected exactly one mockito-core JAR for the test JVM, found "
|
||||
+ candidates.size()
|
||||
+ ": "
|
||||
+ candidates.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return List.of("-javaagent:" + candidates.getFirst().getAbsolutePath(), "-Xshare:off");
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package dev.caskeleton.buildlogic.java;
|
||||
|
||||
import java.util.List;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.work.DisableCachingByDefault;
|
||||
|
||||
@DisableCachingByDefault(because = "Dependency resolution verifies or writes external lock state")
|
||||
public abstract class ResolveConfigurationsTask extends DefaultTask {
|
||||
private List<Configuration> configurations = List.of();
|
||||
|
||||
@Internal
|
||||
public List<Configuration> getConfigurationsToResolve() {
|
||||
return configurations;
|
||||
}
|
||||
|
||||
public void setConfigurationsToResolve(List<Configuration> configurations) {
|
||||
this.configurations = List.copyOf(configurations);
|
||||
}
|
||||
|
||||
@Input
|
||||
public abstract Property<Boolean> getRequireWriteLocks();
|
||||
|
||||
@Input
|
||||
public abstract Property<Boolean> getWriteLocksRequested();
|
||||
|
||||
@TaskAction
|
||||
public void resolveConfigurations() {
|
||||
if (getRequireWriteLocks().get() && !getWriteLocksRequested().get()) {
|
||||
throw new GradleException(getPath() + " requires the --write-locks command-line flag.");
|
||||
}
|
||||
configurations.forEach(Configuration::resolve);
|
||||
}
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
package dev.caskeleton.buildlogic.publishing;
|
||||
|
||||
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.credentials.HttpHeaderCredentials;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.publish.PublishingExtension;
|
||||
import org.gradle.api.publish.maven.MavenPublication;
|
||||
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository;
|
||||
import org.gradle.authentication.http.HttpHeaderAuthentication;
|
||||
import org.gradle.plugins.signing.SigningExtension;
|
||||
|
||||
/**
|
||||
* Publishes one library module to the owner's Gitea Maven registry, or to a staging directory.
|
||||
*
|
||||
* <p>Every module publishes one Maven publication, {@code maven}, built from the {@code java}
|
||||
* component with its sources and javadoc jars. Two repositories:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code gitea}: {@code packagesUrl} from gradle.properties, authenticated with the {@code
|
||||
* Authorization: token <PACKAGES_TOKEN>} header. Gitea's job token cannot publish packages,
|
||||
* so the token is a package-scoped personal access token in a repository secret; it is read
|
||||
* from the environment and never written to a file.
|
||||
* <li>{@code staging}: {@code build/staging-repository} under the root project. {@code
|
||||
* releaseRehearsal} publishes there, so everything up to the upload runs without a secret.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Versions: the leaves declare most dependencies without a version and let Spring dependency
|
||||
* management fill it from a BOM. A published POM or Gradle module file written from the
|
||||
* declarations would carry no version, so the publication maps every variant's dependencies to
|
||||
* the versions its own resolution chose ({@code versionMapping}), and the plugin's POM
|
||||
* customization, which would add the BOM imports a consumer never inherits, is off.
|
||||
*
|
||||
* <p>Signing: with {@code SIGNING_KEY} (an ASCII-armoured PGP secret key) and {@code
|
||||
* SIGNING_PASSWORD} in the environment, every published file gets an {@code .asc}. Without them
|
||||
* nothing is signed, and a task that uploads to {@code gitea} fails before it starts: an unsigned
|
||||
* release is not a release.
|
||||
*/
|
||||
public final class LibraryPublishingPlugin implements Plugin<Project> {
|
||||
public static final String PUBLICATION = "maven";
|
||||
public static final String GITEA_REPOSITORY = "gitea";
|
||||
public static final String STAGING_REPOSITORY = "staging";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().apply("maven-publish");
|
||||
project.getPluginManager().apply("signing");
|
||||
|
||||
JavaPluginExtension java = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
java.withSourcesJar();
|
||||
java.withJavadocJar();
|
||||
|
||||
project
|
||||
.getExtensions()
|
||||
.getByType(DependencyManagementExtension.class)
|
||||
.generatedPomCustomization(customization -> customization.setEnabled(false));
|
||||
|
||||
Provider<String> packagesUrl = project.getProviders().gradleProperty("packagesUrl");
|
||||
Provider<String> repositoryUrl = project.getProviders().gradleProperty("repositoryUrl");
|
||||
Provider<String> token = project.getProviders().environmentVariable("PACKAGES_TOKEN");
|
||||
|
||||
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
|
||||
MavenPublication publication =
|
||||
publishing
|
||||
.getPublications()
|
||||
.create(
|
||||
PUBLICATION,
|
||||
MavenPublication.class,
|
||||
maven -> {
|
||||
maven.from(project.getComponents().getByName("java"));
|
||||
maven.versionMapping(
|
||||
mapping -> mapping.allVariants(variant -> variant.fromResolutionResult()));
|
||||
maven.pom(
|
||||
pom -> {
|
||||
pom.getName().set(project.getName());
|
||||
pom.getDescription()
|
||||
.set(
|
||||
project.provider(
|
||||
() ->
|
||||
project.getDescription() == null
|
||||
? project.getName()
|
||||
: project.getDescription()));
|
||||
pom.getUrl().set(repositoryUrl);
|
||||
pom.scm(
|
||||
scm -> {
|
||||
scm.getUrl().set(repositoryUrl);
|
||||
scm.getConnection().set(repositoryUrl.map(url -> "scm:git:" + url + ".git"));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
publishing
|
||||
.getRepositories()
|
||||
.maven(
|
||||
repository -> {
|
||||
repository.setName(GITEA_REPOSITORY);
|
||||
repository.setUrl(packagesUrl);
|
||||
repository.credentials(
|
||||
HttpHeaderCredentials.class,
|
||||
credentials -> {
|
||||
credentials.setName("Authorization");
|
||||
credentials.setValue("token " + token.getOrElse(""));
|
||||
});
|
||||
repository.getAuthentication().create("header", HttpHeaderAuthentication.class);
|
||||
});
|
||||
publishing
|
||||
.getRepositories()
|
||||
.maven(
|
||||
repository -> {
|
||||
repository.setName(STAGING_REPOSITORY);
|
||||
repository.setUrl(
|
||||
project
|
||||
.getRootProject()
|
||||
.getLayout()
|
||||
.getBuildDirectory()
|
||||
.dir("staging-repository"));
|
||||
});
|
||||
|
||||
String signingKey = project.getProviders().environmentVariable("SIGNING_KEY").getOrElse("");
|
||||
String signingPassword =
|
||||
project.getProviders().environmentVariable("SIGNING_PASSWORD").getOrElse("");
|
||||
boolean signed = !signingKey.isBlank();
|
||||
if (signed) {
|
||||
SigningExtension signing = project.getExtensions().getByType(SigningExtension.class);
|
||||
signing.useInMemoryPgpKeys(signingKey, signingPassword);
|
||||
signing.sign(publication);
|
||||
}
|
||||
|
||||
// Nothing leaves the machine before the release checks have passed, and nothing reaches Gitea
|
||||
// unsigned or without a token. Gitea refuses a second upload of a version, so a half-published
|
||||
// version cannot be repaired by publishing it again; the checks run first (design 05, 7.2).
|
||||
project
|
||||
.getTasks()
|
||||
.withType(PublishToMavenRepository.class)
|
||||
.configureEach(
|
||||
task -> {
|
||||
task.mustRunAfter(":releaseCheck");
|
||||
if (task.getName().endsWith("To" + capitalized(GITEA_REPOSITORY) + "Repository")) {
|
||||
task.doFirst(
|
||||
"requireReleaseCredentials",
|
||||
ignored -> {
|
||||
if (!signed) {
|
||||
throw new GradleException(
|
||||
"SIGNING_KEY is not set; refusing to publish unsigned files to Gitea.");
|
||||
}
|
||||
if (token.getOrElse("").isBlank()) {
|
||||
throw new GradleException(
|
||||
"PACKAGES_TOKEN is not set; Gitea's job token cannot publish packages.");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String capitalized(String name) {
|
||||
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
|
||||
}
|
||||
}
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
package dev.caskeleton.buildlogic.quality;
|
||||
|
||||
import com.diffplug.gradle.spotless.SpotlessExtension;
|
||||
import com.github.spotbugs.snom.Confidence;
|
||||
import com.github.spotbugs.snom.SpotBugsExtension;
|
||||
import com.github.spotbugs.snom.SpotBugsReport;
|
||||
import com.github.spotbugs.snom.SpotBugsTask;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import net.ltgt.gradle.errorprone.ErrorProneOptions;
|
||||
import net.ltgt.gradle.errorprone.ErrorProneOptionsKt;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.VersionCatalog;
|
||||
import org.gradle.api.artifacts.VersionCatalogsExtension;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.plugins.quality.Checkstyle;
|
||||
import org.gradle.api.plugins.quality.CheckstyleExtension;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
|
||||
public final class QualityConventionsPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().apply("ca.java-conventions");
|
||||
project.getPluginManager().apply("com.diffplug.spotless");
|
||||
project.getPluginManager().apply("checkstyle");
|
||||
project.getPluginManager().apply("com.github.spotbugs");
|
||||
project.getPluginManager().apply("net.ltgt.errorprone");
|
||||
|
||||
VersionCatalog catalog =
|
||||
project.getExtensions().getByType(VersionCatalogsExtension.class).named("libs");
|
||||
JavaPluginExtension javaExtension =
|
||||
project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
SourceSet main = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
SourceSet test = javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
|
||||
|
||||
File repositoryConfigDirectory = project.getRootProject().file("config");
|
||||
|
||||
SpotlessExtension spotless = project.getExtensions().getByType(SpotlessExtension.class);
|
||||
spotless.java(
|
||||
java -> {
|
||||
java.googleJavaFormat(version(catalog, "googleJavaFormat"));
|
||||
java.importOrder();
|
||||
java.removeUnusedImports();
|
||||
});
|
||||
|
||||
CheckstyleExtension checkstyle =
|
||||
project.getExtensions().getByType(CheckstyleExtension.class);
|
||||
checkstyle.setToolVersion(version(catalog, "checkstyle"));
|
||||
checkstyle.setConfigFile(new File(repositoryConfigDirectory, "checkstyle/checkstyle.xml"));
|
||||
checkstyle.getConfigDirectory().set(new File(repositoryConfigDirectory, "checkstyle"));
|
||||
checkstyle.setIgnoreFailures(false);
|
||||
checkstyle.setMaxWarnings(Integer.MAX_VALUE);
|
||||
checkstyle.setSourceSets(List.of(main, test));
|
||||
|
||||
SpotBugsExtension spotBugs = project.getExtensions().getByType(SpotBugsExtension.class);
|
||||
spotBugs.getToolVersion().set(version(catalog, "spotbugs"));
|
||||
// MEDIUM (review 2026-11-01 08-07, decided 2026-11-03). HIGH reported 0 findings and left out
|
||||
// FindSecBugs' injection, ReDoS and weak-crypto rules, which report at MEDIUM. The first MEDIUM
|
||||
// run over every analysed leaf reported 307 findings, all priority 2, and each was judged
|
||||
// against the code it names: "fixed" changed the code, "excluded" is a Match in
|
||||
// config/spotbugs/exclude.xml that carries its reason.
|
||||
//
|
||||
// pattern / group found fixed excluded
|
||||
// EI_EXPOSE_REP, EI_EXPOSE_REP2 196 11 185
|
||||
// non-collection references (collaborators) 97 - 97 pattern
|
||||
// settings binding carriers 43 - 43 by class
|
||||
// transport DTOs under adapter.inbound 23 - 23 pattern
|
||||
// collection already copied at construction 20 - 20 class+field
|
||||
// value type exposing mutable state 13 11 2 per site
|
||||
// CT_CONSTRUCTOR_THROW 63 24 39
|
||||
// made final (21 classes) 24 24 -
|
||||
// CGLIB-proxied (@RequiresPermission, @Configuration) 30 - 30 annotation
|
||||
// designed for extension (exception roots, bases) 9 - 9 by class
|
||||
// SECURITY: REDOS 11, UNSAFE_HASH_EQUALS 7, 25 0 25 per site
|
||||
// SQL_INJECTION_* 3, PREDICTABLE_RANDOM 2, XSS 1, WEAK_MESSAGE_DIGEST_SHA1 1
|
||||
// others 23 11 12 per site
|
||||
// NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE 13 (6 fixed), AT_NONATOMIC 2 (fixed),
|
||||
// NP_NULL_ON_SOME_PATH 1 (fixed), BC_IMPOSSIBLE_INSTANCEOF 1 (fixed), BX_UNBOXING 1
|
||||
// (fixed), RV_RETURN_VALUE_IGNORED 2, MS_EXPOSE_REP 2, DLS_DEAD_LOCAL_STORE 1
|
||||
// total 307 46 261
|
||||
//
|
||||
// Found afterwards and judged the same way (review 15절, r3-L): the optional-platforms (gRPC)
|
||||
// build reads this same exclude file and had not been analysed at MEDIUM (13), and the
|
||||
// httpclient retry jitter source r3-J added (1).
|
||||
// USO_UNSAFE_METHOD_SYNCHRONIZATION 6 6 -
|
||||
// GrpcAdmissionController: private lock object
|
||||
// SECURITY: REDOS 4, UNSAFE_HASH_EQUALS 1, 7 0 7 per site
|
||||
// COMMAND_INJECTION 1, PREDICTABLE_RANDOM 1
|
||||
// CT_CONSTRUCTOR_THROW (GrpcPlatformException root) 1 0 1 by class
|
||||
// total 14 6 8
|
||||
//
|
||||
// A new finding fails qualityCheck. Fix it, or add a Match scoped to the class and method (or
|
||||
// field) with the reason it is not a defect. A pattern-wide Match needs a reason that holds for
|
||||
// every class it can ever match, as the EI reference and DTO patterns state theirs.
|
||||
spotBugs.getReportLevel().set(Confidence.MEDIUM);
|
||||
spotBugs.getExcludeFilter().set(new File(repositoryConfigDirectory, "spotbugs/exclude.xml"));
|
||||
// Keep local check fast; qualityCheck is the explicit bytecode-analysis lane.
|
||||
spotBugs.getRunOnCheck().set(false);
|
||||
|
||||
// Test code (every source set but main) is analysed too, by testQualityCheck, against its own
|
||||
// filter: config/spotbugs/exclude-test.xml says which rules do not apply to code that never
|
||||
// runs in production, and why. Until 2026-11-04 these tasks existed, ran in no gate, and 53 of
|
||||
// them failed (300 findings) without anyone seeing it.
|
||||
File testExcludeFilter = new File(repositoryConfigDirectory, "spotbugs/exclude-test.xml");
|
||||
// Registered after evaluation on purpose. The SpotBugs plugin registers a task per source set
|
||||
// and, in that registration, sets the task's auxiliary classpath to the compile classpath. A
|
||||
// configureEach added before a task is registered runs before that registration action, so
|
||||
// for every source set created after this plugin (testFixtures, the test suites) an earlier
|
||||
// configureEach was overwritten and the runtime classpath below never arrived.
|
||||
project.afterEvaluate(
|
||||
evaluated ->
|
||||
evaluated
|
||||
.getTasks()
|
||||
.withType(SpotBugsTask.class)
|
||||
.configureEach(
|
||||
task -> {
|
||||
SourceSet analysed = analysedSourceSet(javaExtension, task);
|
||||
if (analysed == null) {
|
||||
return;
|
||||
}
|
||||
if (!analysed.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) {
|
||||
task.getExcludeFilter().set(testExcludeFilter);
|
||||
}
|
||||
// The compile classpath alone leaves out runtime-only types a class still
|
||||
// links against (org.jboss.logging.BasicLogger, a Resilience4j supertype a
|
||||
// fixture implements), and the analysis of everything that touches them is
|
||||
// then incomplete.
|
||||
task.getAuxClassPaths()
|
||||
.from(analysed.getRuntimeClasspath().minus(analysed.getOutput()));
|
||||
}));
|
||||
project
|
||||
.getTasks()
|
||||
.withType(SpotBugsTask.class)
|
||||
.configureEach(
|
||||
task -> {
|
||||
if (analysedSourceSet(javaExtension, task) == null) {
|
||||
return;
|
||||
}
|
||||
// The SpotBugs Gradle plugin rewrites this file without truncating it. A classpath
|
||||
// shorter than the previous run's (the version drops from `0.0.1+<revision>` to
|
||||
// `0.0.1-SNAPSHOT` once the tree is dirty) keeps the old tail, the last entry reads
|
||||
// `...-SNAPSHOT.jar.jar`, and SpotBugs reports its classes as missing.
|
||||
File auxClasspathFile =
|
||||
project
|
||||
.getLayout()
|
||||
.getBuildDirectory()
|
||||
.file("spotbugs/auxclasspath/" + task.getName())
|
||||
.get()
|
||||
.getAsFile();
|
||||
task.doFirst(ignored -> auxClasspathFile.delete());
|
||||
SpotBugsReport xml = task.getReports().maybeCreate("xml");
|
||||
xml.getRequired().set(true);
|
||||
task.doLast(
|
||||
ignored -> {
|
||||
List<String> failures =
|
||||
SpotBugsAnalysisReport.failures(xml.getOutputLocation().get().getAsFile());
|
||||
if (!failures.isEmpty()) {
|
||||
throw new GradleException(
|
||||
task.getPath()
|
||||
+ ": SpotBugs analysis incomplete:\n "
|
||||
+ String.join("\n ", failures));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
project
|
||||
.getTasks()
|
||||
.withType(JavaCompile.class)
|
||||
.configureEach(
|
||||
compile -> {
|
||||
ErrorProneOptions options =
|
||||
ErrorProneOptionsKt.getErrorprone(compile.getOptions());
|
||||
options.getDisableWarningsInGeneratedCode().set(true);
|
||||
});
|
||||
|
||||
// JMH (me.champeau.jmh) compiles benchmarks and the code it generates from them; neither is
|
||||
// shipped, and generated code does not answer to the repository's lint or bug patterns.
|
||||
project
|
||||
.getPluginManager()
|
||||
.withPlugin(
|
||||
"me.champeau.jmh",
|
||||
ignored -> {
|
||||
project
|
||||
.getTasks()
|
||||
.withType(JavaCompile.class)
|
||||
.matching(
|
||||
compile ->
|
||||
compile.getName().equals("compileJmhJava")
|
||||
|| compile.getName().equals("jmhCompileGeneratedClasses"))
|
||||
.configureEach(
|
||||
compile -> {
|
||||
ErrorProneOptionsKt.getErrorprone(compile.getOptions())
|
||||
.getEnabled()
|
||||
.set(false);
|
||||
compile.getOptions().getCompilerArgs().removeIf("-Werror"::equals);
|
||||
});
|
||||
project
|
||||
.getTasks()
|
||||
.matching(
|
||||
task ->
|
||||
task.getName().equals("spotbugsJmh")
|
||||
|| task.getName().equals("checkstyleJmh"))
|
||||
.configureEach(task -> task.setEnabled(false));
|
||||
});
|
||||
|
||||
project
|
||||
.getDependencies()
|
||||
.add(
|
||||
"spotbugsPlugins",
|
||||
"com.h3xstream.findsecbugs:findsecbugs-plugin:" + version(catalog, "findsecbugs"));
|
||||
project
|
||||
.getDependencies()
|
||||
.add(
|
||||
"errorprone",
|
||||
"com.google.errorprone:error_prone_core:" + version(catalog, "errorprone"));
|
||||
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"auxiliaryStyleCheck",
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Runs Checkstyle for non-default source sets outside the fast local check lane.");
|
||||
task.dependsOn(
|
||||
project
|
||||
.getTasks()
|
||||
.withType(Checkstyle.class)
|
||||
.matching(
|
||||
check ->
|
||||
!check.getName().equals("checkstyleMain")
|
||||
&& !check.getName().equals("checkstyleTest")));
|
||||
});
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"qualityCheck",
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription("Runs this leaf's SpotBugs and FindSecBugs bytecode analysis.");
|
||||
task.dependsOn(project.getTasks().named("spotbugsMain"));
|
||||
});
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
"testQualityCheck",
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Runs SpotBugs and FindSecBugs over this leaf's test source sets"
|
||||
+ " (config/spotbugs/exclude-test.xml).");
|
||||
task.dependsOn(
|
||||
project
|
||||
.getTasks()
|
||||
.withType(SpotBugsTask.class)
|
||||
.matching(
|
||||
spotbugs ->
|
||||
!spotbugs.getName().equals("spotbugsMain")
|
||||
&& !spotbugs.getName().equals("spotbugsJmh")));
|
||||
});
|
||||
}
|
||||
|
||||
/** The source set a {@code spotbugs<SourceSet>} task analyses, or null for any other name. */
|
||||
private static SourceSet analysedSourceSet(JavaPluginExtension javaExtension, SpotBugsTask task) {
|
||||
String suffix = task.getName().substring("spotbugs".length());
|
||||
if (suffix.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return javaExtension
|
||||
.getSourceSets()
|
||||
.findByName(Character.toLowerCase(suffix.charAt(0)) + suffix.substring(1));
|
||||
}
|
||||
|
||||
private static String version(VersionCatalog catalog, String alias) {
|
||||
return catalog
|
||||
.findVersion(alias)
|
||||
.orElseThrow(
|
||||
() -> new GradleException("Version catalog 'libs' must define version '" + alias + "'"))
|
||||
.getRequiredVersion();
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package dev.caskeleton.buildlogic.quality;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
final class SpotBugsAnalysisReport {
|
||||
private SpotBugsAnalysisReport() {}
|
||||
|
||||
static List<String> failures(File reportFile) {
|
||||
List<String> failures = new ArrayList<>();
|
||||
if (!reportFile.isFile()) {
|
||||
return List.of("missing XML report " + reportFile);
|
||||
}
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
|
||||
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
|
||||
factory.setExpandEntityReferences(false);
|
||||
factory.setXIncludeAware(false);
|
||||
var document = factory.newDocumentBuilder().parse(reportFile);
|
||||
NodeList errorsNodes = document.getElementsByTagName("Errors");
|
||||
if (errorsNodes.getLength() != 1) {
|
||||
return List.of("expected one Errors element in " + reportFile.getName());
|
||||
}
|
||||
Element errors = (Element) errorsNodes.item(0);
|
||||
NodeList missingClasses = errors.getElementsByTagName("MissingClass");
|
||||
for (int index = 0; index < missingClasses.getLength(); index++) {
|
||||
String className = missingClasses.item(index).getTextContent().trim();
|
||||
failures.add("missing analysis class " + (className.isBlank() ? "<unnamed>" : className));
|
||||
}
|
||||
NodeList errorNodes = errors.getElementsByTagName("Error");
|
||||
for (int index = 0; index < errorNodes.getLength(); index++) {
|
||||
Element error = (Element) errorNodes.item(index);
|
||||
NodeList messages = error.getElementsByTagName("ErrorMessage");
|
||||
String message =
|
||||
messages.getLength() == 0 ? "" : messages.item(0).getTextContent().trim();
|
||||
failures.add("analysis error " + (message.isBlank() ? "<no message>" : message));
|
||||
}
|
||||
validateDeclaredCount(failures, errors, "missingClasses", missingClasses.getLength());
|
||||
validateDeclaredCount(failures, errors, "errors", errorNodes.getLength());
|
||||
return List.copyOf(failures);
|
||||
} catch (Exception exception) {
|
||||
return List.of("unreadable XML report: " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateDeclaredCount(
|
||||
List<String> failures, Element errors, String attribute, int observed) {
|
||||
String declared = errors.getAttribute(attribute);
|
||||
if (!declared.matches("\\d+")) {
|
||||
failures.add("invalid " + attribute + " count '" + declared + "'");
|
||||
return;
|
||||
}
|
||||
if (Integer.parseInt(declared) > observed) {
|
||||
failures.add(declared + " " + attribute + " reported but only " + observed + " detailed");
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package dev.caskeleton.buildlogic.settings;
|
||||
|
||||
import dev.caskeleton.buildlogic.ModuleRegistrySettingsInstaller;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.initialization.Settings;
|
||||
|
||||
public final class ArchitectureRegistrySettingsPlugin implements Plugin<Settings> {
|
||||
@Override
|
||||
public void apply(Settings settings) {
|
||||
try {
|
||||
// The Gradle root is the repository root here; source_path in the registry is relative to it.
|
||||
File repositoryRoot = settings.getSettingsDir().getCanonicalFile();
|
||||
File registryFile = new File(settings.getSettingsDir(), "config/architecture/modules.json");
|
||||
ModuleRegistrySettingsInstaller.install(settings, registryFile, repositoryRoot, "main");
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to resolve architecture registry paths", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import org.gradle.api.services.BuildService;
|
||||
import org.gradle.api.services.BuildServiceParameters;
|
||||
|
||||
/**
|
||||
* One slot, shared by every lane that starts a real server or container.
|
||||
*
|
||||
* <p>Turning on {@code org.gradle.parallel} made three web throttle IT cases and a WebSocket
|
||||
* shutdown contract fail on socket timeouts, and pass when run alone. Those lanes start an embedded
|
||||
* server and then assert on timing — a permit released at the wrong
|
||||
* moment, a capacity refusal that has to arrive inside a five-second read timeout, connections
|
||||
* closed rather than dropped during shutdown. Several of them at once means the machine decides the
|
||||
* result, not the code, and a gate whose result depends on the machine is the kind this repository's
|
||||
* own review says gets switched off within a quarter.
|
||||
*
|
||||
* <p>Ordering them inside one leaf was not enough: the contention is across leaves. A build service
|
||||
* with {@code maxParallelUsages = 1} is Gradle's answer to "these tasks must not overlap", and it
|
||||
* scopes to exactly the lanes that need it — every strict lane whose category is not {@code TEST}.
|
||||
* The hermetic unit lanes, which are the bulk of the build and the reason to run in parallel at all,
|
||||
* are untouched.
|
||||
*/
|
||||
public abstract class ExclusiveRealServerLaneService
|
||||
implements BuildService<BuildServiceParameters.None> {}
|
||||
File diff suppressed because it is too large
Load Diff
+60
@@ -0,0 +1,60 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.gradle.api.tasks.testing.TestDescriptor;
|
||||
import org.gradle.api.tasks.testing.TestListener;
|
||||
import org.gradle.api.tasks.testing.TestResult;
|
||||
|
||||
final class StrictLaneExecutionTracker implements TestListener {
|
||||
private final boolean collectSelectors;
|
||||
private final AtomicLong executed = new AtomicLong();
|
||||
private final AtomicLong skipped = new AtomicLong();
|
||||
private final Set<String> executedSelectors =
|
||||
Collections.synchronizedSet(new LinkedHashSet<>());
|
||||
|
||||
StrictLaneExecutionTracker(boolean collectSelectors) {
|
||||
this.collectSelectors = collectSelectors;
|
||||
}
|
||||
|
||||
long executedCount() {
|
||||
return executed.get();
|
||||
}
|
||||
|
||||
long skippedCount() {
|
||||
return skipped.get();
|
||||
}
|
||||
|
||||
Set<String> executedSelectors() {
|
||||
synchronized (executedSelectors) {
|
||||
return Set.copyOf(executedSelectors);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeSuite(TestDescriptor suite) {}
|
||||
|
||||
@Override
|
||||
public void afterSuite(TestDescriptor suite, TestResult result) {}
|
||||
|
||||
@Override
|
||||
public void beforeTest(TestDescriptor testDescriptor) {}
|
||||
|
||||
@Override
|
||||
public void afterTest(TestDescriptor descriptor, TestResult result) {
|
||||
if (result.getResultType() == TestResult.ResultType.SKIPPED) {
|
||||
skipped.incrementAndGet();
|
||||
return;
|
||||
}
|
||||
executed.incrementAndGet();
|
||||
if (collectSelectors) {
|
||||
String className = descriptor.getClassName();
|
||||
if (className != null) {
|
||||
executedSelectors.add(className);
|
||||
executedSelectors.add(className + "." + descriptor.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import org.gradle.api.file.DirectoryProperty;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
|
||||
/**
|
||||
* The stages a strict lane may belong to, and where the workflows that run them live.
|
||||
*
|
||||
* <p>A stage is a task path a workflow executes ({@code :ci}, {@code :mainCheck}, ...). Every strict
|
||||
* lane that is not {@code explicitOnly} must be in the plan of at least one stage, and every stage
|
||||
* must be executed — not merely planned with {@code --dry-run} — by at least one workflow.
|
||||
*/
|
||||
public abstract class StrictLaneStagesExtension {
|
||||
public abstract ListProperty<String> getStages();
|
||||
|
||||
/**
|
||||
* The repository's {@code .github/workflows}. Its grandparent is the repository root, and a
|
||||
* command executes this build's stages only when it starts in this build's directory from there
|
||||
* — its step's {@code working-directory} joined with its {@code -p}. The directory is read from
|
||||
* where the build is, so no build states it (review 2026-11-04 RR2-04-04: a {@code -p} value
|
||||
* alone missed {@code working-directory: src/platforms/optional-build} with {@code ../gradlew}).
|
||||
*/
|
||||
public abstract DirectoryProperty getWorkflowDirectory();
|
||||
|
||||
public void stage(String... taskPaths) {
|
||||
getStages().addAll(taskPaths);
|
||||
}
|
||||
}
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.execution.TaskExecutionGraph;
|
||||
|
||||
/**
|
||||
* Fails when a strict lane belongs to no stage a workflow executes.
|
||||
*
|
||||
* <p>A strict lane fails closed when it runs, but nothing makes it run: a lane that no workflow
|
||||
* reaches is a file that looks like coverage (review 2026-11-01 08-01 found fourteen). The rule is
|
||||
* stated once, here, instead of as one workflow line per lane:
|
||||
*
|
||||
* <ol>
|
||||
* <li>every strict lane that is not {@code explicitOnly} is in the task plan of a declared stage
|
||||
* as a workflow runs it — a lane the command removes with {@code -x} is not covered, matched
|
||||
* the way Gradle matches it, abbreviations included ({@link TaskSelectors});
|
||||
* <li>every declared stage is executed by a workflow. Not counted ({@code NOT_COUNTED}; review
|
||||
* 2026-11-03 RR-06-04, 2026-11-04 RR2-04-04, RR5-02-02, 2026-11-05 RR6-04-01..06, 2026-11-06
|
||||
* RR7-05-01, owner decision 2026-11-07 on the release flow): a command
|
||||
* after which Gradle runs no task ({@code --dry-run}, {@code -v}, {@code --help}, …) or that
|
||||
* Gradle rejects (a short-option bundle such as {@code -mx}), one for another build, and one
|
||||
* that does not gate for one of three reasons — its failure may not fail its step, it may not
|
||||
* run, or this check does not read it although its failure would fail the step ({@code
|
||||
* WorkflowGradleInvocations} and {@code ShellScript} name the shapes).
|
||||
* </ol>
|
||||
*
|
||||
* <p>Each build that holds strict lanes applies it at its own root: the main build, and the
|
||||
* optional-platforms build. A command executes this build when it starts in this build's directory
|
||||
* — its step's {@code working-directory}, moved by the {@code cd} commands the same shell surely
|
||||
* ran before it, joined with its {@code -p}, from the repository root, which is where GitHub keeps
|
||||
* {@code .github/workflows} ({@code ShellScript} says which {@code cd} it follows).
|
||||
* A stage named only by commands that do not count is reported with each command's reason. Applied
|
||||
* to the main build only, it said "every strict lane" while the optional build's performance lane
|
||||
* ran nowhere (RR-06-03).</p>
|
||||
*
|
||||
* <p>The task plan is Gradle's own: {@code verifyStrictLaneStages} depends on the stages, so a
|
||||
* {@code --dry-run} of it builds the real plan, and the check reads it when the graph is ready. It
|
||||
* refuses to run without {@code --dry-run}, which would execute every stage.
|
||||
*/
|
||||
public final class StrictLaneStagesPlugin implements Plugin<Project> {
|
||||
public static final String TASK_NAME = "verifyStrictLaneStages";
|
||||
|
||||
/** What a failure names as not counted, in the three reasons the readers give, and what to do. */
|
||||
static final String NOT_COUNTED =
|
||||
"Not counted: a command after which Gradle runs no task (--dry-run, -m, -v, --help,"
|
||||
+ " --status, ...) or that Gradle rejects (a short-option bundle such as -mx), and one"
|
||||
+ " for another build; one whose failure may not fail its step (|| true, a pipe without"
|
||||
+ " pipefail, !, &, an if/while condition, the part before && of a list that is not the"
|
||||
+ " script's last command, after set +e or a trap that exits 0, continue-on-error); one"
|
||||
+ " that may not run (after ||, inside if/while/for/case or a function, after an exit 0,"
|
||||
+ " exec or set -n, under an if: other than always()/success()/!cancelled(), in a"
|
||||
+ " workflow that starts only on a request, or on changes only through a paths or"
|
||||
+ " paths-ignore filter, or a reusable one no counted job calls, in a"
|
||||
+ " job that needs a job that may be skipped, and for any stage but :releaseCheck in a"
|
||||
+ " workflow that starts only on a tag push or a release); and one this check does not"
|
||||
+ " read although"
|
||||
+ " its failure"
|
||||
+ " would fail the step (|| exit 1, inside { } or ( ), $( ), bash -c, gradlew as"
|
||||
+ " another command's argument, after a cd it does not follow, a shell other than bash"
|
||||
+ " or sh, a runner that may be Windows). Run the stage as ./gradlew on a line of its"
|
||||
+ " own, in a step and job that run on every push, pull request or schedule, with no"
|
||||
+ " paths or paths-ignore filter (:releaseCheck may run on a tag push or a release)";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
if (project != project.getRootProject()) {
|
||||
throw new GradleException("ca.strict-lane-stages is applied to the root project only.");
|
||||
}
|
||||
StrictLaneStagesExtension extension =
|
||||
project.getExtensions().create("strictLaneStages", StrictLaneStagesExtension.class);
|
||||
var verify =
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
TASK_NAME,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(
|
||||
"Fails when a strict lane is in no stage a workflow executes. Run with --dry-run.");
|
||||
task.notCompatibleWithConfigurationCache(
|
||||
"the check reads the task graph itself, which a cached entry does not rebuild");
|
||||
});
|
||||
project.afterEvaluate(
|
||||
ignored -> verify.configure(task -> task.dependsOn(extension.getStages().get().toArray())));
|
||||
project
|
||||
.getGradle()
|
||||
.getTaskGraph()
|
||||
.whenReady(
|
||||
graph -> {
|
||||
Task task = verify.get();
|
||||
if (!graph.hasTask(task)) {
|
||||
return;
|
||||
}
|
||||
if (!project.getGradle().getStartParameter().isDryRun()) {
|
||||
throw new GradleException(
|
||||
TASK_NAME
|
||||
+ " checks the plan of "
|
||||
+ extension.getStages().get()
|
||||
+ " and would execute all of them; run it with --dry-run.");
|
||||
}
|
||||
File workflowDirectory = extension.getWorkflowDirectory().get().getAsFile();
|
||||
List<String> problems =
|
||||
problems(
|
||||
project,
|
||||
graph,
|
||||
extension.getStages().get(),
|
||||
workflowDirectory,
|
||||
buildDirectory(project, workflowDirectory));
|
||||
if (!problems.isEmpty()) {
|
||||
throw new GradleException(
|
||||
TASK_NAME
|
||||
+ ": "
|
||||
+ problems.size()
|
||||
+ " problem(s). A lane no executed stage reaches runs nowhere; put it in a"
|
||||
+ " stage, or declare explicitOnly(\"reason\") if it needs an input no stage"
|
||||
+ " has.\n - "
|
||||
+ String.join("\n - ", problems));
|
||||
}
|
||||
project
|
||||
.getLogger()
|
||||
.lifecycle(
|
||||
TASK_NAME + ": every strict lane is in an executed stage.");
|
||||
});
|
||||
}
|
||||
|
||||
private static List<String> problems(
|
||||
Project root,
|
||||
TaskExecutionGraph graph,
|
||||
List<String> stages,
|
||||
File workflowDirectory,
|
||||
String buildDirectory) {
|
||||
List<String> problems = new ArrayList<>(foldedCommandBreaks(workflowDirectory));
|
||||
Map<String, List<WorkflowGradleInvocations.Invocation>> invocationsByWorkflow =
|
||||
invocations(workflowDirectory);
|
||||
List<WorkflowGradleInvocations.Invocation> invocations =
|
||||
invocationsByWorkflow.values().stream().flatMap(List::stream).toList();
|
||||
// Only an executed stage covers a lane — a stage no workflow runs is the same gap one level
|
||||
// up — and only as the command runs it: what its -x removes is not covered.
|
||||
Map<String, Set<String>> tasksByProject = new LinkedHashMap<>();
|
||||
root.getAllprojects()
|
||||
.forEach(
|
||||
project -> tasksByProject.put(project.getPath(), Set.copyOf(project.getTasks().getNames())));
|
||||
Map<String, Set<String>> plans = new LinkedHashMap<>();
|
||||
for (String stage : stages) {
|
||||
List<WorkflowGradleInvocations.Invocation> executions =
|
||||
invocations.stream()
|
||||
.filter(invocation -> invocation.executes(stage, buildDirectory))
|
||||
.toList();
|
||||
if (executions.isEmpty()) {
|
||||
problems.add(
|
||||
"stage "
|
||||
+ stage
|
||||
+ " is executed by no workflow in "
|
||||
+ workflowDirectory.getName()
|
||||
+ " for the build in "
|
||||
+ buildDirectory
|
||||
+ ". "
|
||||
+ NOT_COUNTED
|
||||
+ notCounted(invocationsByWorkflow, stage, buildDirectory));
|
||||
continue;
|
||||
}
|
||||
Task stageTask = root.getTasks().findByPath(stage);
|
||||
int run = 0;
|
||||
for (WorkflowGradleInvocations.Invocation execution : executions) {
|
||||
Set<String> excluded =
|
||||
TaskSelectors.excludedPaths(execution.excludedTasks(), tasksByProject);
|
||||
plans.put(
|
||||
stage + "#" + run++, stageTask == null ? Set.of() : plan(graph, stageTask, excluded));
|
||||
}
|
||||
}
|
||||
List<String> lanes = new ArrayList<>();
|
||||
root.getAllprojects().stream()
|
||||
.sorted(Comparator.comparing(Project::getPath))
|
||||
.forEach(
|
||||
project -> {
|
||||
StrictTestLaneExtension lanesOf =
|
||||
project.getExtensions().findByType(StrictTestLaneExtension.class);
|
||||
if (lanesOf == null) {
|
||||
return;
|
||||
}
|
||||
lanesOf.getLanes().stream()
|
||||
.filter(lane -> lane.getExplicitOnlyReason() == null)
|
||||
.map(lane -> taskPath(project, lane.getName()))
|
||||
.sorted()
|
||||
.forEach(lanes::add);
|
||||
});
|
||||
for (String lane : lanes) {
|
||||
if (plans.values().stream().noneMatch(plan -> plan.contains(lane))) {
|
||||
problems.add("strict lane " + lane + " is in no executed stage of " + stages);
|
||||
}
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
|
||||
/**
|
||||
* The commands that name {@code stage} but do not execute it for this build, each with why — its
|
||||
* uncounted reason, the other build it starts (review 2026-11-04 RR5-02-03: a typo in a {@code cd}
|
||||
* or a {@code cd src} under {@code working-directory: src} is named, not hidden), or a dry run: a
|
||||
* workflow that calls the stage in a way this check does not count is told so, instead of failing
|
||||
* as if it never did.
|
||||
*/
|
||||
private static String notCounted(
|
||||
Map<String, List<WorkflowGradleInvocations.Invocation>> invocationsByWorkflow,
|
||||
String stage,
|
||||
String buildDirectory) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
invocationsByWorkflow.forEach(
|
||||
(workflow, invocations) ->
|
||||
invocations.stream()
|
||||
.filter(invocation -> invocation.requests(stage))
|
||||
.forEach(
|
||||
invocation ->
|
||||
lines.add(
|
||||
workflow
|
||||
+ ": gradlew "
|
||||
+ String.join(" ", invocation.tasks())
|
||||
+ " — "
|
||||
+ invocation.whyNotExecuting(stage, buildDirectory))));
|
||||
return lines.isEmpty()
|
||||
? ""
|
||||
: "; commands that name it but do not count:\n " + String.join("\n ", lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* The tasks {@code stage} reaches as a command runs it: what its -x removes is cut off. A task of
|
||||
* an included build (a stage that runs build-logic's tests) is not in this build's plan and holds
|
||||
* none of its lanes, so the walk does not ask the graph about it — the graph would refuse.
|
||||
*/
|
||||
private static Set<String> plan(TaskExecutionGraph graph, Task stage, Set<String> excluded) {
|
||||
Set<String> seen = new HashSet<>();
|
||||
Deque<Task> pending = new ArrayDeque<>(List.of(stage));
|
||||
while (!pending.isEmpty()) {
|
||||
Task task = pending.pop();
|
||||
if (!excluded.contains(task.getPath()) && seen.add(task.getPath()) && graph.hasTask(task)) {
|
||||
pending.addAll(graph.getDependencies(task));
|
||||
}
|
||||
}
|
||||
return seen;
|
||||
}
|
||||
|
||||
/** A folded run block broken by a blank line runs its options as commands; see the reader. */
|
||||
private static List<String> foldedCommandBreaks(File workflowDirectory) {
|
||||
List<String> problems = new ArrayList<>();
|
||||
for (File file : workflowFiles(workflowDirectory)) {
|
||||
try {
|
||||
WorkflowGradleInvocations.foldedCommandBreaks(
|
||||
Files.readString(file.toPath(), StandardCharsets.UTF_8))
|
||||
.forEach(problem -> problems.add(file.getName() + " " + problem));
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to read " + file, exception);
|
||||
}
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
|
||||
private static File[] workflowFiles(File workflowDirectory) {
|
||||
File[] files =
|
||||
workflowDirectory.listFiles(
|
||||
file -> file.getName().endsWith(".yml") || file.getName().endsWith(".yaml"));
|
||||
if (files == null || files.length == 0) {
|
||||
throw new GradleException(
|
||||
TASK_NAME + ": no workflow files in " + workflowDirectory + "; nothing could run a stage.");
|
||||
}
|
||||
Arrays.sort(files);
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each workflow file's Gradle commands, by file name, in file order — read together, because a
|
||||
* reusable workflow runs only through the workflows that call it (RR6-04-06).
|
||||
*/
|
||||
private static Map<String, List<WorkflowGradleInvocations.Invocation>> invocations(
|
||||
File workflowDirectory) {
|
||||
Map<String, String> workflows = new LinkedHashMap<>();
|
||||
for (File file : workflowFiles(workflowDirectory)) {
|
||||
try {
|
||||
workflows.put(file.getName(), Files.readString(file.toPath(), StandardCharsets.UTF_8));
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("failed to read " + file, exception);
|
||||
}
|
||||
}
|
||||
return WorkflowGradleInvocations.readAll(workflows);
|
||||
}
|
||||
|
||||
/**
|
||||
* This build's directory from the repository root, which holds {@code .github/workflows}: {@code
|
||||
* src} for the main build, {@code src/platforms/optional-build} for the optional one.
|
||||
*/
|
||||
private static String buildDirectory(Project root, File workflowDirectory) {
|
||||
File repository = workflowDirectory.getAbsoluteFile().getParentFile().getParentFile();
|
||||
String relative =
|
||||
repository
|
||||
.toPath()
|
||||
.normalize()
|
||||
.relativize(root.getRootDir().getAbsoluteFile().toPath().normalize())
|
||||
.toString()
|
||||
.replace(File.separatorChar, '/');
|
||||
return WorkflowGradleInvocations.Invocation.normalized(relative);
|
||||
}
|
||||
|
||||
private static String taskPath(Project project, String name) {
|
||||
return project == project.getRootProject() ? ":" + name : project.getPath() + ":" + name;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
|
||||
public class StrictTestLaneExtension {
|
||||
private final NamedDomainObjectContainer<StrictTestLaneSpec> lanes;
|
||||
|
||||
public StrictTestLaneExtension(NamedDomainObjectContainer<StrictTestLaneSpec> lanes) {
|
||||
this.lanes = lanes;
|
||||
}
|
||||
|
||||
public NamedDomainObjectContainer<StrictTestLaneSpec> getLanes() {
|
||||
return lanes;
|
||||
}
|
||||
|
||||
public void lane(String name, Action<? super StrictTestLaneSpec> configuration) {
|
||||
// Configured before it is added, so the plugin's `lanes.all` action sees the declared source
|
||||
// set (it decides whether the lane is its JVM test suite's own task).
|
||||
if (lanes.findByName(name) != null) {
|
||||
throw new GradleException("strict test lane '" + name + "' is declared twice");
|
||||
}
|
||||
StrictTestLaneSpec lane = new StrictTestLaneSpec(name);
|
||||
configuration.execute(lane);
|
||||
lanes.add(lane);
|
||||
}
|
||||
}
|
||||
+473
@@ -0,0 +1,473 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import dev.caskeleton.buildlogic.RequiredTestExecution;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
import org.gradle.api.tasks.testing.Test;
|
||||
import org.gradle.testing.base.TestingExtension;
|
||||
|
||||
public final class StrictTestLanePlugin implements Plugin<Project> {
|
||||
/**
|
||||
* The switch a performance lane's machine-dependent bounds used to sit behind, now always on.
|
||||
*
|
||||
* <p>Each leaf declared it with its own default — {@code false} for the httpclient lane, {@code
|
||||
* true} for the Mongo lane — and only the workflows set it. {@code ./gradlew :performanceCheck}
|
||||
* typed by hand therefore passed with the httpclient heap bound compared to nothing (the
|
||||
* 2026-11-05 desktop gate). The convention owns it now: every performance lane's test JVM gets
|
||||
* {@code true}, so a test that still reads the switch asserts, and a build that sets it to
|
||||
* anything else fails before the lane runs. Nothing in this repository reads it any more; the
|
||||
* value is for tests written against the old switch, such as a derived service's.
|
||||
*/
|
||||
static final String PERFORMANCE_ASSERTIONS = "performance.assertions.enabled";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPluginManager().withPlugin("java", ignored -> configure(project));
|
||||
}
|
||||
|
||||
private static void configure(Project project) {
|
||||
NamedDomainObjectContainer<StrictTestLaneSpec> lanes =
|
||||
project.container(StrictTestLaneSpec.class, StrictTestLaneSpec::new);
|
||||
StrictTestLaneExtension extension =
|
||||
project
|
||||
.getExtensions()
|
||||
.create("strictTestLanes", StrictTestLaneExtension.class, lanes);
|
||||
String ownerPath = project.getPath();
|
||||
JavaPluginExtension java = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
|
||||
lanes.all(
|
||||
lane -> {
|
||||
// A lane named after the JVM test suite it runs is that suite's own Test task: the suite
|
||||
// (jvm-test-suite, which replaced ca.auxiliary-source-set) registers it, the lane makes it
|
||||
// strict. Any other name collision still fails in register().
|
||||
TaskProvider<Test> laneTask =
|
||||
isOwnSuiteTask(project, lane)
|
||||
? project.getTasks().named(lane.getName(), Test.class)
|
||||
: project.getTasks().register(lane.getName(), Test.class);
|
||||
laneTask.configure(test -> configureLane(project, java, ownerPath, lane, test));
|
||||
|
||||
project
|
||||
.getGradle()
|
||||
.getTaskGraph()
|
||||
.whenReady(
|
||||
graph -> {
|
||||
boolean selected =
|
||||
graph.getAllTasks().stream().anyMatch(task -> task == laneTask.get());
|
||||
if (!selected) {
|
||||
return;
|
||||
}
|
||||
SourceSet sourceSet = java.getSourceSets().getByName(lane.getSourceSet());
|
||||
if (sourceSet.getAllSource().getFiles().isEmpty()) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " has no sources in source set '"
|
||||
+ lane.getSourceSet()
|
||||
+ "'. Gradle would skip it as NO-SOURCE and report success for a lane that ran nothing.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
project.afterEvaluate(
|
||||
ignored -> lanes.forEach(lane -> validateLane(project, lane)));
|
||||
|
||||
lanes.all(
|
||||
lane ->
|
||||
project.afterEvaluate(
|
||||
ignored -> {
|
||||
if (!lane.isMainStage()) {
|
||||
return;
|
||||
}
|
||||
String tag = lane.getTag();
|
||||
if (tag == null || tag.isBlank()) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " is a main-stage lane without a tag; the tag is what keeps its tests out of `test`.");
|
||||
}
|
||||
project
|
||||
.getTasks()
|
||||
.named("test", Test.class)
|
||||
.configure(test -> test.useJUnitPlatform(options -> options.excludeTags(tag)));
|
||||
project
|
||||
.getTasks()
|
||||
.matching(task -> task.getName().equals("mainCheck"))
|
||||
.configureEach(task -> task.dependsOn(lane.getName()));
|
||||
}));
|
||||
|
||||
registerAggregate(
|
||||
project,
|
||||
extension,
|
||||
"strictTestLaneCheck",
|
||||
"Runs every strict test lane this leaf declares.",
|
||||
lane -> true);
|
||||
registerAggregate(
|
||||
project,
|
||||
extension,
|
||||
"testLaneCheck",
|
||||
"Runs this leaf's hermetic test lanes.",
|
||||
lane -> lane.getCategory() == TestLaneCategory.TEST);
|
||||
registerAggregate(
|
||||
project,
|
||||
extension,
|
||||
"integrationTestLaneCheck",
|
||||
"Runs this leaf's external-infrastructure integration test lanes.",
|
||||
lane -> lane.getCategory() == TestLaneCategory.INTEGRATION);
|
||||
registerAggregate(
|
||||
project,
|
||||
extension,
|
||||
"systemTestLaneCheck",
|
||||
"Runs this leaf's full application/system test lanes.",
|
||||
lane -> lane.getCategory() == TestLaneCategory.SYSTEM);
|
||||
registerAggregate(
|
||||
project,
|
||||
extension,
|
||||
"architectureTestLaneCheck",
|
||||
"Runs this leaf's architecture test lanes.",
|
||||
lane -> lane.getCategory() == TestLaneCategory.ARCHITECTURE);
|
||||
registerAggregate(
|
||||
project,
|
||||
extension,
|
||||
"performanceTestLaneCheck",
|
||||
"Runs this leaf's performance test lanes.",
|
||||
lane -> lane.getCategory() == TestLaneCategory.PERFORMANCE);
|
||||
}
|
||||
|
||||
private static void registerAggregate(
|
||||
Project project,
|
||||
StrictTestLaneExtension extension,
|
||||
String taskName,
|
||||
String description,
|
||||
Predicate<StrictTestLaneSpec> selection) {
|
||||
project
|
||||
.getTasks()
|
||||
.register(
|
||||
taskName,
|
||||
task -> {
|
||||
task.setGroup("verification");
|
||||
task.setDescription(description);
|
||||
task.dependsOn(
|
||||
project.provider(
|
||||
() ->
|
||||
extension.getLanes().stream()
|
||||
.filter(lane -> lane.getExplicitOnlyReason() == null)
|
||||
.filter(selection)
|
||||
.map(lane -> project.getTasks().named(lane.getName()))
|
||||
.toList()));
|
||||
// An explicit-only lane is left out, and the aggregate says so when it runs, so a
|
||||
// green aggregate is never read as covering it.
|
||||
var leftOut =
|
||||
project.provider(
|
||||
() ->
|
||||
extension.getLanes().stream()
|
||||
.filter(lane -> lane.getExplicitOnlyReason() != null)
|
||||
.filter(selection)
|
||||
.map(
|
||||
lane ->
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ project.getPath()
|
||||
+ " runs only when named: "
|
||||
+ lane.getExplicitOnlyReason()
|
||||
+ ".")
|
||||
.toList());
|
||||
task.doLast(
|
||||
running -> leftOut.get().forEach(note -> running.getLogger().lifecycle(note)));
|
||||
});
|
||||
}
|
||||
|
||||
private static void configureLane(
|
||||
Project project,
|
||||
JavaPluginExtension java,
|
||||
String ownerPath,
|
||||
StrictTestLaneSpec lane,
|
||||
Test test) {
|
||||
SourceSet sourceSet = java.getSourceSets().getByName(lane.getSourceSet());
|
||||
if (startsARealServer(lane)) {
|
||||
// INTEGRATION, SYSTEM and PERFORMANCE lanes start a server, a container or both, and
|
||||
// several of those at once under `org.gradle.parallel` makes the machine decide the result.
|
||||
// One slot for all of them, build-wide — ordering them inside a leaf was not enough, because
|
||||
// the web and websocket lanes contend with each other across leaves. An ARCHITECTURE lane
|
||||
// imports classes and starts nothing, so it does not wait for that slot (review 2026-11-01
|
||||
// 08-06).
|
||||
test.usesService(
|
||||
project
|
||||
.getGradle()
|
||||
.getSharedServices()
|
||||
.registerIfAbsent(
|
||||
"exclusiveRealServerLane",
|
||||
ExclusiveRealServerLaneService.class,
|
||||
specification -> specification.getMaxParallelUsages().set(1)));
|
||||
}
|
||||
test.setGroup(
|
||||
lane.getGroup() == null || lane.getGroup().isBlank() ? "verification" : lane.getGroup());
|
||||
test.setDescription(lane.getDescription());
|
||||
test.setTestClassesDirs(sourceSet.getOutput().getClassesDirs());
|
||||
test.setClasspath(sourceSet.getRuntimeClasspath());
|
||||
String tag = lane.getTag();
|
||||
if (tag != null && !tag.trim().isEmpty()) {
|
||||
test.useJUnitPlatform(options -> options.includeTags(tag));
|
||||
} else {
|
||||
test.useJUnitPlatform();
|
||||
}
|
||||
List<String> required = lane.getRequiredTests();
|
||||
if (!required.isEmpty()) {
|
||||
test.filter(
|
||||
filter -> {
|
||||
required.forEach(filter::includeTestsMatching);
|
||||
filter.setFailOnNoMatchingTests(true);
|
||||
});
|
||||
}
|
||||
test.getFailOnNoDiscoveredTests().set(true);
|
||||
// A lane whose result follows from its declared inputs may be up to date or come from the
|
||||
// build cache: the result it reuses was produced by a run that passed the checks below (no test
|
||||
// ran, a skip, a required test missing), with the same classes, filter and properties. A lane
|
||||
// whose result depends on what Gradle cannot see runs every time (review 2026-11-01 08-02).
|
||||
// The verdict below reads the lane's policy, not only its test results, so the policy is an
|
||||
// input: tightening it (rejectSkipped = true, another required test, another category) must
|
||||
// judge the lane again rather than reuse a result produced under the looser policy. Without
|
||||
// this a lane that skipped a test stayed green, up to date and from the build cache, after
|
||||
// rejectSkipped was switched on (review 2026-11-03 RR-06-02).
|
||||
test.getInputs()
|
||||
.property("strictLane.rejectSkipped", project.provider(() -> rejectsSkipped(lane)));
|
||||
test.getInputs()
|
||||
.property("strictLane.requiredTests", project.provider(lane::getRequiredTests));
|
||||
test.getInputs()
|
||||
.property(
|
||||
"strictLane.tag", project.provider(() -> lane.getTag() == null ? "" : lane.getTag()));
|
||||
test.getInputs()
|
||||
.property("strictLane.category", project.provider(() -> lane.getCategory().name()));
|
||||
test.getInputs().property("strictLane.mainStage", project.provider(lane::isMainStage));
|
||||
String rerunReason = rerunReason(lane);
|
||||
if (rerunReason != null) {
|
||||
test.getOutputs().upToDateWhen(ignored -> false);
|
||||
test.getOutputs().doNotCacheIf(rerunReason, ignored -> true);
|
||||
}
|
||||
boolean performance = lane.getCategory() == TestLaneCategory.PERFORMANCE;
|
||||
if (performance) {
|
||||
// Set before the lane's own JVM arguments and system properties — Gradle turns a -D in
|
||||
// jvmArgs into a system property — so a lane that still declares the switch replaces this
|
||||
// value and the check below sees the override, instead of the override disappearing silently.
|
||||
test.systemProperty(PERFORMANCE_ASSERTIONS, "true");
|
||||
Provider<String> requested = project.getProviders().gradleProperty(PERFORMANCE_ASSERTIONS);
|
||||
String laneName = lane.getName();
|
||||
test.doFirst(
|
||||
running -> requireAssertionsOn(laneName, ownerPath, requested.getOrNull(), (Test) running));
|
||||
}
|
||||
if (lane.getMaxHeapSize() != null && !lane.getMaxHeapSize().isBlank()) {
|
||||
test.setMaxHeapSize(lane.getMaxHeapSize());
|
||||
}
|
||||
if (!lane.getJvmArgs().isEmpty()) {
|
||||
test.setJvmArgs(lane.getJvmArgs());
|
||||
}
|
||||
lane.getShouldRunAfter().forEach(test::shouldRunAfter);
|
||||
lane.getDependsOn().forEach(test::dependsOn);
|
||||
lane.getSystemProperties().forEach(test::systemProperty);
|
||||
for (File directory : lane.getInputDirectories()) {
|
||||
test.getInputs().dir(directory).withPathSensitivity(PathSensitivity.RELATIVE);
|
||||
}
|
||||
|
||||
StrictLaneExecutionTracker tracker = new StrictLaneExecutionTracker(!required.isEmpty());
|
||||
test.addTestListener(tracker);
|
||||
test.doLast(
|
||||
ignored -> {
|
||||
if (tracker.executedCount() == 0L) {
|
||||
String detail;
|
||||
if (tracker.skippedCount() > 0L) {
|
||||
detail =
|
||||
"; all "
|
||||
+ tracker.skippedCount()
|
||||
+ " test(s) it selected were skipped (@Disabled or an unmet assumption), and a skip is not a result";
|
||||
} else if (tag != null && !tag.trim().isEmpty()) {
|
||||
detail =
|
||||
"; its tag '"
|
||||
+ tag
|
||||
+ "' matches nothing in source set '"
|
||||
+ lane.getSourceSet()
|
||||
+ "'";
|
||||
} else if (required.isEmpty()) {
|
||||
detail = " in source set '" + lane.getSourceSet() + "'";
|
||||
} else {
|
||||
detail = "; its required tests " + required + " matched no executable test";
|
||||
}
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " executed no test"
|
||||
+ detail
|
||||
+ " — a lane that runs nothing reports success for whatever it was meant to prove.");
|
||||
}
|
||||
if (rejectsSkipped(lane) && tracker.skippedCount() > 0L) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " forbids skipped tests but observed "
|
||||
+ tracker.skippedCount()
|
||||
+ " skipped test(s)."
|
||||
+ (performance
|
||||
? " A performance lane always does: a skipped test is a bound nobody measured."
|
||||
: ""));
|
||||
}
|
||||
if (!required.isEmpty()) {
|
||||
List<String> absent =
|
||||
RequiredTestExecution.absent(required, tracker.executedSelectors());
|
||||
if (!absent.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " required "
|
||||
+ absent
|
||||
+ " and executed neither. A lane that named a test it no longer runs proves less than it claims.");
|
||||
}
|
||||
}
|
||||
});
|
||||
if (lane.getCustomize() != null) {
|
||||
lane.getCustomize().execute(test);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A performance lane rejects skipped tests whatever it declares: its tests are its bounds, and a
|
||||
* skip is a bound the run reports as passed without comparing it to anything.
|
||||
*/
|
||||
private static boolean rejectsSkipped(StrictTestLaneSpec lane) {
|
||||
return lane.isRejectSkipped() || lane.getCategory() == TestLaneCategory.PERFORMANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fails a performance lane, before any test runs, when the build or the lane turns its bounds off.
|
||||
* {@code true} from the build is accepted, so a command that still passes it keeps working.
|
||||
*/
|
||||
private static void requireAssertionsOn(
|
||||
String laneName, String ownerPath, String requestedByBuild, Test test) {
|
||||
if (requestedByBuild != null && !Boolean.parseBoolean(requestedByBuild.trim())) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ laneName
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " is a performance lane, and this build sets "
|
||||
+ PERFORMANCE_ASSERTIONS
|
||||
+ "="
|
||||
+ requestedByBuild
|
||||
+ " (-P"
|
||||
+ PERFORMANCE_ASSERTIONS
|
||||
+ ", or -Dorg.gradle.project."
|
||||
+ PERFORMANCE_ASSERTIONS
|
||||
+ " in GRADLE_OPTS). A performance lane asserts its bounds in every run: one without"
|
||||
+ " them measures nothing it can fail on and still reports success. Remove the"
|
||||
+ " property or set it to true.");
|
||||
}
|
||||
Object effective = test.getSystemProperties().get(PERFORMANCE_ASSERTIONS);
|
||||
if (effective == null || !Boolean.parseBoolean(String.valueOf(effective).trim())) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ laneName
|
||||
+ "' in "
|
||||
+ ownerPath
|
||||
+ " is a performance lane, but its test JVM would get "
|
||||
+ PERFORMANCE_ASSERTIONS
|
||||
+ "="
|
||||
+ effective
|
||||
+ " from this project's build (a lane systemProperty or jvmArgs, or a block that"
|
||||
+ " configures the task). The strict-lane convention sets it to true for every"
|
||||
+ " performance lane; delete the override.");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean startsARealServer(StrictTestLaneSpec lane) {
|
||||
return lane.getCategory() != TestLaneCategory.TEST
|
||||
&& lane.getCategory() != TestLaneCategory.ARCHITECTURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Why this lane's earlier result may not stand for this run, or {@code null} when it may.
|
||||
*
|
||||
* <ul>
|
||||
* <li>INTEGRATION, SYSTEM, PERFORMANCE: a container image pulled by tag, the network, the clock
|
||||
* and the machine's load are not task inputs, so the same inputs prove nothing about the
|
||||
* same result.
|
||||
* <li>A main-stage lane: it compares the leaf with repository documents it does not declare as
|
||||
* inputs, and it is the stage whose run is the evidence.
|
||||
* </ul>
|
||||
*/
|
||||
private static String rerunReason(StrictTestLaneSpec lane) {
|
||||
if (startsARealServer(lane)) {
|
||||
return "a "
|
||||
+ lane.getCategory()
|
||||
+ " lane depends on images, network and time that are not task inputs";
|
||||
}
|
||||
if (lane.isMainStage()) {
|
||||
return "a main-stage lane reads repository documents that are not task inputs";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isOwnSuiteTask(Project project, StrictTestLaneSpec lane) {
|
||||
TestingExtension testing = project.getExtensions().findByType(TestingExtension.class);
|
||||
return testing != null
|
||||
&& lane.getName().equals(lane.getSourceSet())
|
||||
&& testing.getSuites().getNames().contains(lane.getName())
|
||||
&& project.getTasks().getNames().contains(lane.getName());
|
||||
}
|
||||
|
||||
private static void validateLane(Project project, StrictTestLaneSpec lane) {
|
||||
boolean hasTag = lane.getTag() != null && !lane.getTag().trim().isEmpty();
|
||||
boolean hasRequired = !lane.getRequiredTests().isEmpty();
|
||||
if (!hasTag && !hasRequired && lane.getSourceSet().equals("test")) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ project.getPath()
|
||||
+ " selects nothing while running over the shared 'test' source set; it would run the entire suite under a name that claims it ran one thing. Give it a tag, a set of required tests, or a source set of its own.");
|
||||
}
|
||||
if (hasTag && hasRequired) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ project.getPath()
|
||||
+ " declares both a tag and required tests; pick one selection.");
|
||||
}
|
||||
if (lane.getDescription() == null || lane.getDescription().trim().isEmpty()) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ project.getPath()
|
||||
+ " declares no description");
|
||||
}
|
||||
if (project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().findByName(lane.getSourceSet()) == null) {
|
||||
throw new GradleException(
|
||||
"strict test lane '"
|
||||
+ lane.getName()
|
||||
+ "' in "
|
||||
+ project.getPath()
|
||||
+ " references unknown source set '"
|
||||
+ lane.getSourceSet()
|
||||
+ "'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Named;
|
||||
import org.gradle.api.tasks.testing.Test;
|
||||
|
||||
public class StrictTestLaneSpec implements Named {
|
||||
private final String name;
|
||||
private String tag;
|
||||
private String description;
|
||||
private String group;
|
||||
private String sourceSet = "test";
|
||||
private String maxHeapSize;
|
||||
private boolean rejectSkipped;
|
||||
private boolean mainStage;
|
||||
private String explicitOnlyReason;
|
||||
private TestLaneCategory category = TestLaneCategory.TEST;
|
||||
private final List<String> requiredTests = new ArrayList<>();
|
||||
private final List<String> jvmArgs = new ArrayList<>();
|
||||
private final List<String> shouldRunAfter = new ArrayList<>();
|
||||
private final List<String> dependsOn = new ArrayList<>();
|
||||
private final List<File> inputDirectories = new ArrayList<>();
|
||||
private final Map<String, String> systemProperties = new LinkedHashMap<>();
|
||||
private Action<? super Test> customize;
|
||||
|
||||
public StrictTestLaneSpec(String name) {
|
||||
this.name = Objects.requireNonNull(name, "name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getSourceSet() {
|
||||
return sourceSet;
|
||||
}
|
||||
|
||||
public void setSourceSet(String sourceSet) {
|
||||
this.sourceSet = sourceSet;
|
||||
}
|
||||
|
||||
public String getMaxHeapSize() {
|
||||
return maxHeapSize;
|
||||
}
|
||||
|
||||
public void setMaxHeapSize(String maxHeapSize) {
|
||||
this.maxHeapSize = maxHeapSize;
|
||||
}
|
||||
|
||||
public boolean isRejectSkipped() {
|
||||
return rejectSkipped;
|
||||
}
|
||||
|
||||
public void setRejectSkipped(boolean rejectSkipped) {
|
||||
this.rejectSkipped = rejectSkipped;
|
||||
}
|
||||
|
||||
public boolean isMainStage() {
|
||||
return mainStage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs this lane in the leaf's {@code mainCheck} instead of its {@code test}: the lane's tag is
|
||||
* excluded from {@code test}. For checks that compare a leaf with documents or registries, which
|
||||
* are not worth a pull request's wait (review 2026-09-24 BUILD-계획-B4-27).
|
||||
*/
|
||||
public void mainStage() {
|
||||
mainStage = true;
|
||||
}
|
||||
|
||||
public String getExplicitOnlyReason() {
|
||||
return explicitOnlyReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps this lane out of every aggregate ({@code strictTestLaneCheck}, {@code
|
||||
* integrationTestLaneCheck}, ...): it runs only when named. For a lane that cannot pass without
|
||||
* an input the aggregate's caller does not have — protected credentials, an external topology —
|
||||
* so that the aggregate states the gap instead of failing on it (review NEW-16).
|
||||
*/
|
||||
public void explicitOnly(String reason) {
|
||||
explicitOnlyReason = Objects.requireNonNull(reason, "reason");
|
||||
}
|
||||
|
||||
public TestLaneCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(TestLaneCategory category) {
|
||||
this.category = Objects.requireNonNull(category, "category");
|
||||
}
|
||||
|
||||
public void test() {
|
||||
category = TestLaneCategory.TEST;
|
||||
}
|
||||
|
||||
public void integration() {
|
||||
category = TestLaneCategory.INTEGRATION;
|
||||
}
|
||||
|
||||
public void system() {
|
||||
category = TestLaneCategory.SYSTEM;
|
||||
}
|
||||
|
||||
public void architecture() {
|
||||
category = TestLaneCategory.ARCHITECTURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* A lane whose tests are resource or latency bounds. Besides rerunning every time and taking the
|
||||
* build-wide real-server slot, it rejects skipped tests and always runs with its bounds asserted:
|
||||
* the convention sets {@code performance.assertions.enabled=true}, and a build or lane that sets
|
||||
* it to anything else fails before a test runs.
|
||||
*/
|
||||
public void performance() {
|
||||
category = TestLaneCategory.PERFORMANCE;
|
||||
}
|
||||
|
||||
public List<String> getRequiredTests() {
|
||||
return List.copyOf(requiredTests);
|
||||
}
|
||||
|
||||
public void requires(String... selectors) {
|
||||
requiredTests.addAll(List.of(selectors));
|
||||
}
|
||||
|
||||
public List<String> getJvmArgs() {
|
||||
return List.copyOf(jvmArgs);
|
||||
}
|
||||
|
||||
public void jvmArgs(String... arguments) {
|
||||
jvmArgs.addAll(List.of(arguments));
|
||||
}
|
||||
|
||||
public List<String> getShouldRunAfter() {
|
||||
return List.copyOf(shouldRunAfter);
|
||||
}
|
||||
|
||||
public void shouldRunAfter(String... taskNames) {
|
||||
shouldRunAfter.addAll(List.of(taskNames));
|
||||
}
|
||||
|
||||
public List<String> getDependsOn() {
|
||||
return List.copyOf(dependsOn);
|
||||
}
|
||||
|
||||
public void dependsOn(String... taskNames) {
|
||||
dependsOn.addAll(List.of(taskNames));
|
||||
}
|
||||
|
||||
public Map<String, String> getSystemProperties() {
|
||||
return Map.copyOf(systemProperties);
|
||||
}
|
||||
|
||||
public void systemProperty(String name, String value) {
|
||||
systemProperties.put(Objects.requireNonNull(name, "name"), Objects.requireNonNull(value, "value"));
|
||||
}
|
||||
|
||||
public List<File> getInputDirectories() {
|
||||
return List.copyOf(inputDirectories);
|
||||
}
|
||||
|
||||
public void inputDirectory(File directory) {
|
||||
inputDirectories.add(Objects.requireNonNull(directory, "directory"));
|
||||
}
|
||||
|
||||
public Action<? super Test> getCustomize() {
|
||||
return customize;
|
||||
}
|
||||
|
||||
public void setCustomize(Action<? super Test> customize) {
|
||||
this.customize = customize;
|
||||
}
|
||||
|
||||
public void customize(Action<? super Test> customize) {
|
||||
this.customize = customize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Which tasks a command line's {@code -x} selectors remove, matched the way Gradle matches them.
|
||||
*
|
||||
* <p>Gradle accepts an abbreviation wherever it accepts a task or project name: {@code -x
|
||||
* grpcPerformanceT} removes {@code grpcPerformanceTest}, and {@code :g-t:gPT} a task of {@code
|
||||
* :grpc-testkit}. The workflow reader compared names exactly, so an abbreviated {@code -x} — the
|
||||
* form people type in a terminal and paste into a workflow — removed a lane from Gradle's plan while
|
||||
* the stage check still counted it (review 2026-11-04 RR2-04-04).
|
||||
*
|
||||
* <p>The matching is a copy of Gradle's {@code org.gradle.util.internal.NameMatcher} (9.0): exact,
|
||||
* then case-insensitive, then camel-case, then kebab-case abbreviation. It is copied rather than
|
||||
* called because that class is internal API. Where Gradle would refuse the selector as ambiguous,
|
||||
* every candidate counts as removed: the command cannot run, so it covers none of them.
|
||||
*/
|
||||
final class TaskSelectors {
|
||||
private static final Pattern CAMEL_CASE_BOUNDARY =
|
||||
Pattern.compile(
|
||||
"((^|\\p{Punct})\\p{javaLowerCase}+)|((\\p{javaUpperCase}|\\p{Digit})\\p{javaLowerCase}*)");
|
||||
private static final Pattern KEBAB_BOUNDARY =
|
||||
Pattern.compile("((^|\\p{Punct})\\p{javaLowerCase}+)|(\\p{javaUpperCase}\\p{javaLowerCase}*)");
|
||||
|
||||
private TaskSelectors() {}
|
||||
|
||||
/**
|
||||
* The paths of the tasks the selectors remove from a command started at the root project.
|
||||
*
|
||||
* @param selectors the {@code -x} values, as written
|
||||
* @param tasksByProject each project's path ({@code :} for the root) and its task names
|
||||
* @return the removed task paths
|
||||
*/
|
||||
static Set<String> excludedPaths(
|
||||
List<String> selectors, Map<String, ? extends Collection<String>> tasksByProject) {
|
||||
Set<String> excluded = new LinkedHashSet<>();
|
||||
for (String selector : selectors) {
|
||||
excluded.addAll(selected(selector, tasksByProject));
|
||||
}
|
||||
return excluded;
|
||||
}
|
||||
|
||||
private static Set<String> selected(
|
||||
String selector, Map<String, ? extends Collection<String>> tasksByProject) {
|
||||
Set<String> paths = new LinkedHashSet<>();
|
||||
if (!selector.contains(":")) {
|
||||
// A bare name is matched against every task name in the build and removes the task of that
|
||||
// name in every project.
|
||||
Set<String> names = new TreeSet<>();
|
||||
tasksByProject.values().forEach(names::addAll);
|
||||
for (String name : matches(selector, names)) {
|
||||
tasksByProject.forEach(
|
||||
(project, tasks) -> {
|
||||
if (tasks.contains(name)) {
|
||||
paths.add(taskPath(project, name));
|
||||
}
|
||||
});
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
String relative = selector.startsWith(":") ? selector.substring(1) : selector;
|
||||
String[] segments = relative.split(":", -1);
|
||||
Set<String> projects = Set.of(":");
|
||||
for (int index = 0; index < segments.length - 1; index++) {
|
||||
Set<String> next = new LinkedHashSet<>();
|
||||
for (String project : projects) {
|
||||
for (String child : matches(segments[index], children(project, tasksByProject.keySet()))) {
|
||||
next.add(project.equals(":") ? ":" + child : project + ":" + child);
|
||||
}
|
||||
}
|
||||
projects = next;
|
||||
}
|
||||
String taskName = segments[segments.length - 1];
|
||||
for (String project : projects) {
|
||||
Collection<String> tasks = tasksByProject.get(project);
|
||||
for (String name : matches(taskName, tasks == null ? List.of() : tasks)) {
|
||||
paths.add(taskPath(project, name));
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
private static Set<String> children(String project, Set<String> projects) {
|
||||
String prefix = project.equals(":") ? ":" : project + ":";
|
||||
Set<String> children = new TreeSet<>();
|
||||
for (String candidate : projects) {
|
||||
if (candidate.startsWith(prefix) && candidate.length() > prefix.length()) {
|
||||
String rest = candidate.substring(prefix.length());
|
||||
if (!rest.contains(":")) {
|
||||
children.add(rest);
|
||||
}
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
private static String taskPath(String project, String name) {
|
||||
return project.equals(":") ? ":" + name : project + ":" + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The names {@code pattern} selects among {@code items}: one when Gradle would accept it, several
|
||||
* when Gradle would refuse it as ambiguous, none when nothing matches.
|
||||
*/
|
||||
static Set<String> matches(String pattern, Collection<String> items) {
|
||||
if (items.contains(pattern)) {
|
||||
return Set.of(pattern);
|
||||
}
|
||||
if (pattern.isEmpty()) {
|
||||
return Set.of();
|
||||
}
|
||||
Pattern camelCase = Pattern.compile(camelCasePattern(pattern));
|
||||
Pattern camelCaseIgnoringCase =
|
||||
Pattern.compile(camelCasePattern(pattern), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
|
||||
String kebabCasePattern = kebabCasePattern(pattern);
|
||||
Pattern kebabCase = Pattern.compile(kebabCasePattern);
|
||||
Pattern kebabCasePrefix = Pattern.compile(kebabCasePattern + "[\\p{javaLowerCase}\\p{Digit}-]*");
|
||||
Set<String> ignoringCase = new TreeSet<>();
|
||||
Set<String> camelCaseWhole = new TreeSet<>();
|
||||
Set<String> camelCaseStart = new TreeSet<>();
|
||||
Set<String> camelCaseStartIgnoringCase = new TreeSet<>();
|
||||
Set<String> kebabCaseWhole = new TreeSet<>();
|
||||
Set<String> kebabCaseStart = new TreeSet<>();
|
||||
for (String candidate : items) {
|
||||
if (candidate.equalsIgnoreCase(pattern)) {
|
||||
ignoringCase.add(candidate);
|
||||
}
|
||||
if (camelCase.matcher(candidate).matches()) {
|
||||
camelCaseWhole.add(candidate);
|
||||
}
|
||||
if (camelCase.matcher(candidate).lookingAt()) {
|
||||
camelCaseStart.add(candidate);
|
||||
}
|
||||
if (camelCaseIgnoringCase.matcher(candidate).lookingAt()) {
|
||||
camelCaseStartIgnoringCase.add(candidate);
|
||||
}
|
||||
if (kebabCase.matcher(candidate).matches()) {
|
||||
kebabCaseWhole.add(candidate);
|
||||
}
|
||||
if (kebabCasePrefix.matcher(candidate).matches()) {
|
||||
kebabCaseStart.add(candidate);
|
||||
}
|
||||
}
|
||||
Set<String> matches = new TreeSet<>();
|
||||
if (!ignoringCase.isEmpty()) {
|
||||
matches.addAll(ignoringCase);
|
||||
} else if (!camelCaseWhole.isEmpty()) {
|
||||
matches.addAll(camelCaseWhole);
|
||||
} else if (!camelCaseStart.isEmpty()) {
|
||||
matches.addAll(camelCaseStart);
|
||||
} else if (kebabCaseWhole.isEmpty() && kebabCaseStart.isEmpty()) {
|
||||
matches.addAll(camelCaseStartIgnoringCase);
|
||||
}
|
||||
if (!kebabCaseWhole.isEmpty()) {
|
||||
matches.addAll(kebabCaseWhole);
|
||||
} else if (!kebabCaseStart.isEmpty()) {
|
||||
matches.addAll(kebabCaseStart);
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
private static String camelCasePattern(String name) {
|
||||
return pattern(
|
||||
name,
|
||||
CAMEL_CASE_BOUNDARY,
|
||||
(builder, position, part) ->
|
||||
builder.append(Pattern.quote(part)).append("[\\p{javaLowerCase}]*"));
|
||||
}
|
||||
|
||||
private static String kebabCasePattern(String name) {
|
||||
return pattern(
|
||||
name,
|
||||
KEBAB_BOUNDARY,
|
||||
(builder, position, part) -> {
|
||||
if (position > 0) {
|
||||
builder.append('-');
|
||||
}
|
||||
builder
|
||||
.append(Pattern.quote(part.toLowerCase(Locale.ROOT)))
|
||||
.append("[\\p{javaLowerCase}\\p{Digit}]*");
|
||||
});
|
||||
}
|
||||
|
||||
private interface PartWriter {
|
||||
void write(StringBuilder builder, int position, String part);
|
||||
}
|
||||
|
||||
private static String pattern(String name, Pattern boundary, PartWriter writer) {
|
||||
Matcher matcher = boundary.matcher(name);
|
||||
int position = 0;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while (matcher.find()) {
|
||||
String prefix = name.substring(position, matcher.start());
|
||||
if (!prefix.isEmpty()) {
|
||||
builder.append(Pattern.quote(prefix));
|
||||
}
|
||||
writer.write(builder, position, matcher.group());
|
||||
position = matcher.end();
|
||||
}
|
||||
if (position < name.length()) {
|
||||
builder.append(Pattern.quote(name.substring(position)));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
public enum TestLaneCategory {
|
||||
TEST,
|
||||
INTEGRATION,
|
||||
SYSTEM,
|
||||
ARCHITECTURE,
|
||||
PERFORMANCE
|
||||
}
|
||||
+1410
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user