Skip to content

Commit a687d37

Browse files
author
Mark Pollack
committed
Spring Boot: write the configuration metadata on JDK 21+
The errorprone profile's annotationProcessorPaths turned off classpath discovery of Spring Boot's processors, so a JDK 21 build wrote neither spring-configuration-metadata.json nor spring-autoconfigure-metadata.properties. Name both processors on the module's processor path.
1 parent 0fb5e9e commit a687d37

3 files changed

Lines changed: 112 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,14 @@ Found by measuring coverage with JaCoCo; each has a test.
16631663

16641664
### Build
16651665

1666+
- **Spring Boot's configuration metadata is written on JDK 21 and later too.** The `errorprone`
1667+
profile (JDK 21+) sets the compiler's processor path to Error Prone and NullAway, which turns off
1668+
discovering processors on the classpath, so `acp-spring-boot-autoconfigure` built on JDK 21 had
1669+
no `META-INF/spring-configuration-metadata.json` (no IDE completion or descriptions for the 32
1670+
`spring.acp.*` properties) and no `spring-autoconfigure-metadata.properties`. The module now
1671+
names `spring-boot-configuration-processor` and `spring-boot-autoconfigure-processor` on its
1672+
processor path, so every JDK writes both. Released jars, built on JDK 17, were not affected.
1673+
16661674
- **The Javadoc build knows the `@apiNote`, `@implSpec` and `@implNote` tags.** They were not
16671675
registered with the javadoc plugin, so their text was silently left out of the generated pages
16681676
(and doclint reports them as unknown tags). The parent POM now registers them, with the JDK's

‎acp-spring-boot-autoconfigure/pom.xml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,37 @@
177177
<scope>test</scope>
178178
</dependency>
179179
</dependencies>
180+
181+
<build>
182+
<plugins>
183+
<!-- Spring Boot's processors write META-INF/spring-configuration-metadata.json and
184+
spring-autoconfigure-metadata.properties. Named on the processor path, not found
185+
on the classpath: in the errorprone profile (JDK 21+) the parent's processor path
186+
(Error Prone, NullAway) turns classpath discovery off, so neither file was written.
187+
Appended, so they run beside Error Prone there and alone on JDK 17. -->
188+
<plugin>
189+
<groupId>org.apache.maven.plugins</groupId>
190+
<artifactId>maven-compiler-plugin</artifactId>
191+
<executions>
192+
<execution>
193+
<id>default-compile</id>
194+
<configuration>
195+
<annotationProcessorPaths combine.children="append">
196+
<path>
197+
<groupId>org.springframework.boot</groupId>
198+
<artifactId>spring-boot-configuration-processor</artifactId>
199+
<version>${spring-boot.version}</version>
200+
</path>
201+
<path>
202+
<groupId>org.springframework.boot</groupId>
203+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
204+
<version>${spring-boot.version}</version>
205+
</path>
206+
</annotationProcessorPaths>
207+
</configuration>
208+
</execution>
209+
</executions>
210+
</plugin>
211+
</plugins>
212+
</build>
180213
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2025-2026 the original author or authors.
3+
*/
4+
5+
package com.agentclientprotocol.sdk.spring.boot.autoconfigure;
6+
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
11+
import java.nio.file.Files;
12+
import java.nio.file.Path;
13+
import java.util.ArrayList;
14+
import java.util.List;
15+
import java.util.Properties;
16+
17+
import com.agentclientprotocol.sdk.spring.boot.autoconfigure.client.AcpClientProperties;
18+
import org.junit.jupiter.api.Test;
19+
import tools.jackson.databind.JsonNode;
20+
import tools.jackson.databind.ObjectMapper;
21+
22+
import static org.assertj.core.api.Assertions.assertThat;
23+
24+
/**
25+
* The build writes Spring Boot's metadata into this module's classes on every JDK: the
26+
* configuration metadata IDEs complete {@code spring.acp.*} from, and the autoconfiguration
27+
* metadata Boot reads its conditions from early. On JDK 21 and later the {@code errorprone}
28+
* profile's processor path used to hide both processors, so neither file was written.
29+
*/
30+
class ConfigurationMetadataTests {
31+
32+
@Test
33+
void everySpringAcpPropertyIsDescribed() throws IOException {
34+
Path metadata = moduleClasses().resolve("META-INF/spring-configuration-metadata.json");
35+
assertThat(metadata).exists();
36+
JsonNode root = new ObjectMapper().readTree(metadata.toFile());
37+
List<String> names = new ArrayList<>();
38+
for (JsonNode property : root.get("properties")) {
39+
String name = property.get("name").asString();
40+
names.add(name);
41+
assertThat(property.path("description").asString()).as(name).isNotBlank();
42+
}
43+
assertThat(names).hasSize(32).allMatch(name -> name.startsWith("spring.acp."));
44+
assertThat(names).contains("spring.acp.agent.transport.http.shutdown-timeout",
45+
"spring.acp.client.transport.websocket.connect-timeout", "spring.acp.client.transport.stdio.env");
46+
}
47+
48+
@Test
49+
void theAutoConfigurationMetadataIsWritten() throws IOException {
50+
Path metadata = moduleClasses().resolve("META-INF/spring-autoconfigure-metadata.properties");
51+
assertThat(metadata).exists();
52+
Properties properties = new Properties();
53+
try (InputStream in = Files.newInputStream(metadata)) {
54+
properties.load(in);
55+
}
56+
assertThat(properties.stringPropertyNames()).anyMatch(key -> key.startsWith(
57+
"com.agentclientprotocol.sdk.spring.boot.autoconfigure.client.AcpClientAutoConfiguration."));
58+
}
59+
60+
/** This module's classes directory, not another jar's metadata of the same name. */
61+
private static Path moduleClasses() {
62+
try {
63+
URI location = AcpClientProperties.class.getProtectionDomain().getCodeSource().getLocation().toURI();
64+
return Path.of(location);
65+
}
66+
catch (URISyntaxException ex) {
67+
throw new IllegalStateException(ex);
68+
}
69+
}
70+
71+
}

0 commit comments

Comments
 (0)