Skip to content

Commit 1d6b828

Browse files
committed
Java 25 annotation processor usage. Consume Modulith process stdout.
Signed-off-by: BoykoAlex <alex.boyko@broadcom.com>
1 parent 26ae720 commit 1d6b828

File tree

37 files changed

+477
-113
lines changed

37 files changed

+477
-113
lines changed

eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/SpringBootLanguageServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private List<String> getJVMArgs() {
4242
// args.add("-Xrunjdwp:server=y,transport=dt_socket,address=1044,suspend=n");
4343
args.add("-Xmx1024m");
4444
args.add("-Dspring.config.location=classpath:/application.properties");
45+
args.add("-Djdk.util.zip.disableZip64ExtraFieldValidation=true");
4546

4647
// enable/disable embedded MCP server, depending on preference
4748
boolean mcpServerEnabled = BootLanguageServerPlugin.getDefault().getPreferenceStore().getBoolean(Constants.PREF_AI_MCP_ENABLED);

headless-services/spring-boot-language-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@
439439
<excludes>
440440
<exclude>test-projects/**</exclude>
441441
</excludes>
442-
<argLine>-Dorg.eclipse.jdt.disable_JRT_cache=true</argLine>
442+
<argLine>-Dorg.eclipse.jdt.disable_JRT_cache=true -Djdk.util.zip.disableZip64ExtraFieldValidation=true</argLine>
443443
</configuration>
444444
</plugin>
445445

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/modulith/ModulithService.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.springframework.ide.vscode.commons.protocol.java.Classpath;
5656
import org.springframework.ide.vscode.commons.protocol.java.Jre;
5757
import org.springframework.ide.vscode.commons.protocol.spring.BeansParams;
58+
import org.springframework.ide.vscode.commons.util.ExternalProcess;
5859
import org.springframework.ide.vscode.commons.util.text.TextDocument;
5960

6061
import com.google.gson.GsonBuilder;
@@ -353,29 +354,29 @@ private List<AppModule> computeAppModules(String projectName, String javaCmd,
353354
String cp, String pkg) {
354355
try {
355356
File outputFile = File.createTempFile(projectName + "-" + pkg, "json");
356-
Process process = Runtime.getRuntime()
357-
.exec(new String[] {
358-
javaCmd,
359-
"-cp",
360-
cp,
361-
"org.springframework.modulith.core.util.ApplicationModulesExporter",
362-
pkg,
363-
outputFile.toString()
364-
});
365-
StringBuilder builder = new StringBuilder();
366-
String line = null;
367-
while ((line = process.errorReader().readLine()) != null) {
368-
builder.append(line);
369-
builder.append(System.getProperty("line.separator"));
370-
}
357+
ProcessBuilder pb = new ProcessBuilder(
358+
javaCmd, "-cp", cp,
359+
"org.springframework.modulith.core.util.ApplicationModulesExporter",
360+
pkg, outputFile.toString());
361+
Process process = pb.start();
362+
// Both streams must be drained concurrently to prevent the OS pipe buffer
363+
// (~64KB) from filling up and deadlocking the subprocess. StreamGobler
364+
// starts a background reader thread immediately in its constructor.
365+
ExternalProcess.StreamGobler stdoutGobler = new ExternalProcess.StreamGobler(process.getInputStream());
366+
ExternalProcess.StreamGobler stderrGobler = new ExternalProcess.StreamGobler(process.getErrorStream());
371367
int exitValue = process.waitFor();
368+
String stdout = stdoutGobler.getContents();
369+
String stderr = stderrGobler.getContents();
372370
if (exitValue == 0) {
371+
if (stdout != null && !stdout.isBlank()) {
372+
log.debug("[ApplicationModulesExporter stdout]\n{}", stdout);
373+
}
373374
log.info("Updating Modulith metadata for project '" + projectName + "'");
374375
JsonObject json = JsonParser.parseReader(new FileReader(outputFile)).getAsJsonObject();
375376
log.info("Modulith metadata: " + new GsonBuilder().setPrettyPrinting().create().toJson(json));
376377
return loadAppModules(json);
377378
} else {
378-
log.error("Failed to generate modulith metadata for project '" + projectName + "'. Modulith Exporter process exited with code " + process.exitValue() + "\n" + builder.toString());
379+
log.error("Failed to generate modulith metadata for project '{}'. Modulith Exporter process exited with code {}\n--- stdout ---\n{}\n--- stderr ---\n{}", projectName, exitValue, stdout, stderr);
379380
}
380381
} catch (IOException | InterruptedException e) {
381382
log.error("", e);

headless-services/spring-boot-language-server/src/test/resources/test-projects/boot-1.2.0-properties-live-metadta/pom.xml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
<artifactId>spring-boot-starter-test</artifactId>
4040
<scope>test</scope>
4141
</dependency>
42-
43-
<dependency>
44-
<groupId>org.springframework.boot</groupId>
45-
<artifactId>spring-boot-configuration-processor</artifactId>
46-
<optional>true</optional>
47-
</dependency>
4842
</dependencies>
4943

5044
<properties>
@@ -54,6 +48,29 @@
5448
</properties>
5549

5650
<build>
51+
<pluginManagement>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-jar-plugin</artifactId>
56+
<version>3.3.0</version>
57+
</plugin>
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-compiler-plugin</artifactId>
61+
<version>3.13.0</version>
62+
<configuration>
63+
<annotationProcessorPaths>
64+
<path>
65+
<groupId>org.springframework.boot</groupId>
66+
<artifactId>spring-boot-configuration-processor</artifactId>
67+
<version>${project.parent.version}</version>
68+
</path>
69+
</annotationProcessorPaths>
70+
</configuration>
71+
</plugin>
72+
</plugins>
73+
</pluginManagement>
5774
<plugins>
5875
<plugin>
5976
<groupId>org.springframework.boot</groupId>
@@ -78,7 +95,7 @@
7895
<artifactId>maven-javadoc-plugin</artifactId>
7996
<version>3.2.0</version>
8097
</plugin>
81-
</plugins>
98+
</plugins>
8299
</reporting>
83100

84101
</project>

headless-services/spring-boot-language-server/src/test/resources/test-projects/boot-1.2.1-app-properties-list-of-pojo/pom.xml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
<groupId>org.springframework.boot</groupId>
3030
<artifactId>spring-boot-starter</artifactId>
3131
</dependency>
32-
<dependency>
33-
<groupId>org.springframework.boot</groupId>
34-
<artifactId>spring-boot-configuration-processor</artifactId>
35-
</dependency>
3632
<dependency>
3733
<groupId>org.springframework.boot</groupId>
3834
<artifactId>spring-boot-starter-test</artifactId>
@@ -41,6 +37,29 @@
4137
</dependencies>
4238

4339
<build>
40+
<pluginManagement>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<artifactId>maven-jar-plugin</artifactId>
45+
<version>3.3.0</version>
46+
</plugin>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-compiler-plugin</artifactId>
50+
<version>3.13.0</version>
51+
<configuration>
52+
<annotationProcessorPaths>
53+
<path>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-configuration-processor</artifactId>
56+
<version>${project.parent.version}</version>
57+
</path>
58+
</annotationProcessorPaths>
59+
</configuration>
60+
</plugin>
61+
</plugins>
62+
</pluginManagement>
4463
<plugins>
4564
<plugin>
4665
<groupId>org.springframework.boot</groupId>
@@ -102,7 +121,7 @@
102121
<artifactId>maven-javadoc-plugin</artifactId>
103122
<version>3.2.0</version>
104123
</plugin>
105-
</plugins>
124+
</plugins>
106125
</reporting>
107126

108127
</project>

headless-services/spring-boot-language-server/src/test/resources/test-projects/boot-1.3.0-app-sts-4231/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
</dependencyManagement>
5454

5555
<build>
56+
<pluginManagement>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-jar-plugin</artifactId>
61+
<version>3.3.0</version>
62+
</plugin>
63+
</plugins>
64+
</pluginManagement>
5665
<plugins>
5766
<plugin>
5867
<groupId>org.springframework.boot</groupId>

headless-services/spring-boot-language-server/src/test/resources/test-projects/boot-1.3.3-app-with-resource-prop/pom.xml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,32 @@
3838
<artifactId>spring-boot-starter-test</artifactId>
3939
<scope>test</scope>
4040
</dependency>
41-
<dependency>
42-
<groupId>org.springframework.boot</groupId>
43-
<artifactId>spring-boot-configuration-processor</artifactId>
44-
<optional>true</optional>
45-
</dependency>
4641
</dependencies>
4742

4843
<build>
44+
<pluginManagement>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-jar-plugin</artifactId>
49+
<version>3.3.0</version>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-compiler-plugin</artifactId>
54+
<version>3.13.0</version>
55+
<configuration>
56+
<annotationProcessorPaths>
57+
<path>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-configuration-processor</artifactId>
60+
<version>${project.parent.version}</version>
61+
</path>
62+
</annotationProcessorPaths>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</pluginManagement>
4967
<plugins>
5068
<plugin>
5169
<groupId>org.springframework.boot</groupId>
@@ -70,7 +88,7 @@
7088
<artifactId>maven-javadoc-plugin</artifactId>
7189
<version>3.2.0</version>
7290
</plugin>
73-
</plugins>
91+
</plugins>
7492
</reporting>
7593

7694
</project>

headless-services/spring-boot-language-server/src/test/resources/test-projects/boot-1.3.3-sts-4335/pom.xml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,32 @@
3838
<artifactId>spring-boot-starter-test</artifactId>
3939
<scope>test</scope>
4040
</dependency>
41-
<dependency>
42-
<groupId>org.springframework.boot</groupId>
43-
<artifactId>spring-boot-configuration-processor</artifactId>
44-
<optional>true</optional>
45-
</dependency>
4641
</dependencies>
4742

4843
<build>
44+
<pluginManagement>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-jar-plugin</artifactId>
49+
<version>3.3.0</version>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-compiler-plugin</artifactId>
54+
<version>3.13.0</version>
55+
<configuration>
56+
<annotationProcessorPaths>
57+
<path>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-configuration-processor</artifactId>
60+
<version>${project.parent.version}</version>
61+
</path>
62+
</annotationProcessorPaths>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</pluginManagement>
4967
<plugins>
5068
<plugin>
5169
<groupId>org.springframework.boot</groupId>
@@ -70,7 +88,7 @@
7088
<artifactId>maven-javadoc-plugin</artifactId>
7189
<version>3.2.0</version>
7290
</plugin>
73-
</plugins>
91+
</plugins>
7492
</reporting>
7593

7694
</project>

headless-services/spring-boot-language-server/src/test/resources/test-projects/cloud-rabbit-project/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@
6868
</dependencyManagement>
6969

7070
<build>
71+
<pluginManagement>
72+
<plugins>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-jar-plugin</artifactId>
76+
<version>3.3.0</version>
77+
</plugin>
78+
</plugins>
79+
</pluginManagement>
7180
<plugins>
7281
<plugin>
7382
<groupId>org.springframework.boot</groupId>

headless-services/spring-boot-language-server/src/test/resources/test-projects/custom-properties-boot-project/pom.xml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,36 @@
3535
<artifactId>spring-boot-starter-test</artifactId>
3636
<scope>test</scope>
3737
</dependency>
38-
<dependency>
39-
<groupId>org.springframework.boot</groupId>
40-
<artifactId>spring-boot-configuration-processor</artifactId>
41-
<optional>true</optional>
42-
</dependency>
4338
<dependency>
4439
<groupId>org.springframework.boot</groupId>
4540
<artifactId>spring-boot-starter-actuator</artifactId>
4641
</dependency>
4742
</dependencies>
4843

4944
<build>
45+
<pluginManagement>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-jar-plugin</artifactId>
50+
<version>3.3.0</version>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-compiler-plugin</artifactId>
55+
<version>3.13.0</version>
56+
<configuration>
57+
<annotationProcessorPaths>
58+
<path>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-configuration-processor</artifactId>
61+
<version>${project.parent.version}</version>
62+
</path>
63+
</annotationProcessorPaths>
64+
</configuration>
65+
</plugin>
66+
</plugins>
67+
</pluginManagement>
5068
<plugins>
5169
<plugin>
5270
<groupId>org.springframework.boot</groupId>
@@ -88,7 +106,7 @@
88106
<artifactId>maven-javadoc-plugin</artifactId>
89107
<version>3.2.0</version>
90108
</plugin>
91-
</plugins>
109+
</plugins>
92110
</reporting>
93111

94112
</project>

0 commit comments

Comments
 (0)