feat(gradle): import modules from Gradle itself (includeFlat, included builds, computed includes) (#715)

The Gradle model came from a static parse of settings.gradle, which cannot follow includeFlat, projectDir assignments, computed include lists or included builds, so those modules were missing from the Gradle tool window, the Project view, indexing and run. Sync now runs an init script that prints every evaluated project (identity path, directory, build directory, source sets with test classification, Java version) without resolving dependencies; the static parser stays as the fallback before the first sync. Modules outside the root become content roots, the Project view lists the build's module group above the project folder, an unsynced Gradle build is imported once when opened, and staleness ignores comments and whitespace in build scripts.

Application / Spring Boot configurations of a Gradle module run through a JavaExec task on the source set's runtime classpath by default (Settings › Build Tools › Gradle › Build and run using), with the debugger attached to the forked JVM. The build model reaches run and the Project view through a platform store rather than a cross-feature import.

Fixes #737
Fixes #861

Co-authored-by: ntbang0901 <[email protected]>
This commit is contained in:
ntbang0901 authored and GitHub committed 2026-11-04 01:09:07 +08:00
1 parent 0c1a64bc2c
commit bd424a3805
34 files changed
+1454 -110

No files matched your search

+11
View File
@@ -140,6 +140,17 @@ describe("application configurations", () => {
expect(jvmModuleDir("odd/App.java", [cfg({ id: "m", kind: "maven", cwd: "odd" })])).toBe("odd");
});
it("takes the innermost module the build model knows, like IDEA's file index", () => {
const modules = ["", "/w/billing", "/w/billing/modules/core", "legacy"];
// `sourceSets.main.java.srcDirs = ['src']`: no `src/main/java` to guess from.
expect(jvmModuleDir("legacy/src/a/App.java", [], modules)).toBe("legacy");
expect(jvmModuleDir("/w/billing/modules/core/src/main/java/a/App.java", [], modules)).toBe(
"/w/billing/modules/core",
);
// A module the model does not know yet (before the first sync): the source layout.
expect(jvmModuleDir("services/api/src/main/java/a/App.java", [], modules)).toBe("services/api");
});
it("adds JDWP to a script explicitly assigned the Kotlin debugger", () => {
const rc = cfg({ id: "kotlin-script", kind: "shell", command: "./run.sh", debugAdapter: "kotlin-debug-adapter" });
expect(jdwpLaunch(rc)?.env.JAVA_TOOL_OPTIONS).toContain("-agentlib:jdwp=");