Files
openidea/src/platform/buildFiles.test.ts
T
Zhu Minhaoandzmh69695328 dfa610beb0 fix(gradle): read dependencies from scripts a build applies (#2277)
Dependencies declared in a script pulled in with `apply from:` never reached External Libraries, and `"g🅰️${v}"` versions were dropped because statement splitting at `{` cut them in half. The scan now follows `apply from` recursively (Groovy and Kotlin DSL; `$rootDir`, `$projectDir`, `rootProject.projectDir`; relative paths from the project directory, then beside the applying script; URLs and missing files skipped; cycles and aliases cut by canonical path, bounded at 256 scripts and 32 levels). It fills `ext`/`extra` values (`ext.x`, `ext { }`, `ext["x"]`, `extra["x"]`, `val x by extra(...)`) into `${...}` versions with gradle.properties taking precedence, and counts applied scripts as build inputs, so editing one invalidates the cached model and refreshes the Build tool window and External Libraries.

Co-authored-by: zmh69695328 <18231787+zmh69695328@users.noreply.github.com>
2026-11-09 17:05:20 +08:00

19 lines
659 B
TypeScript

import { expect, it } from "vitest";
import { isGradleBuildInput } from "./buildFiles";
it("recognizes applied scripts and Gradle properties for build and library refresh", () => {
for (const path of [
"/p/gradle/dependencies.gradle",
"/p/gradle/dependencies.gradle.kts",
"C:\\p\\gradle\\dependencies.gradle",
"/p/gradle.properties",
"/p/gradle/wrapper/gradle-wrapper.properties",
"/p/gradle/libs.versions.toml",
]) {
expect(isGradleBuildInput(path), path).toBe(true);
}
for (const path of ["/p/dependencies.gradle.bak", "/p/src/main.kt", "/p/README.md"]) {
expect(isGradleBuildInput(path), path).toBe(false);
}
});