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 { /** * 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); })); } }