fix(run): detect Spring Boot apps that inherit the plugin or use a meta-annotation (#3995)

Project detection only treated a module as Spring Boot when its own build file
applied the plugin, so microservice modules that inherit spring-boot-maven-plugin
from the parent POM's <build><plugins> (or Gradle's subprojects block) were missing
from Run configurations and Services until their main class was run once. And only
the literal @SpringBootApplication marked an application class, not
@SpringCloudApplication or a project annotation carrying @SpringBootApplication, so
the gutter's Run created a plain Application configuration.

A module now applies Spring Boot through its own build or a build above it
(pluginManagement alone doesn't apply it). Application classes are recognised by
@SpringBootApplication, @SpringCloudApplication, or a project annotation declared
with either (resolved through imports and the modules' main source roots). The
gutter reuses the Spring Boot kind of the detected configuration with the same id.

Fixes #3916
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-17 20:10:43 +08:00
1 джерело cb7bddec14
коміт bacdd3e5c3
5 files changed
+263 -51

No files matched your search

+25
Переглянути файл
@@ -235,6 +235,31 @@ describe("application configurations", () => {
});
});
it("runs a main class as Spring Boot when the annotation carries @SpringBootApplication", () => {
const rel = "src/main/java/shop/GatewayApp.java";
const cloud =
"package shop;\n@SpringCloudApplication\nclass GatewayApp {\n public static void main(String[] a) {}\n}";
expect(
targetConfig(
detectRunTargets(cloud, rel).find((t) => t.kind === "main")!,
rel,
maven,
cloud,
),
).toMatchObject({
kind: "spring-boot",
});
// A project annotation: project detection found the application.
const own = "package shop;\n@ShopApplication\nclass GatewayApp {\n public static void main(String[] a) {}\n}";
const main = detectRunTargets(own, rel).find((t) => t.kind === "main")!;
expect(targetConfig(main, rel, maven, own)).toMatchObject({ kind: "application" });
const detected = { ...applicationConfig({ className: "shop.GatewayApp" }, rel), kind: "spring-boot" as const };
expect(targetConfig(main, rel, [...maven, detected], own)).toMatchObject({
id: "application:shop.GatewayApp",
kind: "spring-boot",
});
});
it("scopes Maven and Gradle test configs to a class or method", () => {
const file = cfg({ id: "f", kind: "maven", args: ["test", "-Dtest=OrderTest"], isTest: true });
expect(jvmTestConfig(file, "a.OrderTest$Nested", "fails")).toMatchObject({