mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:52:12 +00:00
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:
1 parent
0c1a64bc2c
commit
bd424a3805
34 files changed
+1454
-110
No files matched your search
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
import { call, commands, IpcError, type JavaLaunchInfo, type RunConfig, type RequestId } from "@/platform/ipc";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useBuildPresentation } from "@/platform/projectPresentation";
|
||||
|
||||
export const CLASSPATH = "${classpath}";
|
||||
export const TEST_CLASSPATH = "${testClasspath}";
|
||||
@@ -117,11 +118,19 @@ export function jdwpListeningPort(line: string): number | null {
|
||||
}
|
||||
|
||||
/**
|
||||
* Module directory (relative to the project root, `""` for the root) of a JVM
|
||||
* source file: the part before `src/{main,test}/…`, else the working directory
|
||||
* of the closest Maven / Gradle configuration.
|
||||
* Module directory (relative to the project root, `""` for the root; absolute for a
|
||||
* module outside it) of a JVM source file. Like IDEA's `ProjectFileIndex.getModuleForFile`:
|
||||
* the innermost Maven / Gradle module folder holding the file, as the build model knows
|
||||
* them (`modules`). Before a model knows a deeper one: the part before
|
||||
* `src/{main,test}/…`, else the working directory of the closest Maven / Gradle configuration.
|
||||
*/
|
||||
export function jvmModuleDir(relPath: string, configs: readonly RunConfig[] = []): string {
|
||||
export function jvmModuleDir(
|
||||
relPath: string,
|
||||
configs: readonly RunConfig[] = [],
|
||||
modules: Iterable<string> = useBuildPresentation.getState().modules.keys(),
|
||||
): string {
|
||||
const owner = [...modules].filter((d) => d && relPath.startsWith(d + "/")).sort((a, b) => b.length - a.length)[0];
|
||||
if (owner) return owner;
|
||||
const m = /^(?:(.*)\/)?src\/(?:main|test|[\w-]+)\/(?:java|kotlin|scala|groovy)\//.exec(relPath);
|
||||
if (m) return m[1] ?? "";
|
||||
const cwds = configs
|
||||
|
||||
Reference in new issue
Block a user