Skip to content

Detect Java in Gradle projects regardless of build script DSL#87

Open
andrew wants to merge 1 commit into
mainfrom
fix-gradle-java-detection
Open

Detect Java in Gradle projects regardless of build script DSL#87
andrew wants to merge 1 commit into
mainfrom
fix-gradle-java-detection

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented May 23, 2026

A fresh gradle init Java project was reported as Kotlin (Kotlin DSL) or as nothing at all (Groovy DSL).

Two things were going wrong. The extension scan in loadFileExts stopped at directory depth 4, so app/src/main/java/org/example/App.java was never reached and **/*.java found nothing; with no JVM language detected the ecosystem gate then filtered out Gradle even though settings.gradle was sitting at the root. Separately, Kotlin's detect.files included *.kts, which globbed settings.gradle.kts and claimed the project as Kotlin.

This replaces the depth-4 default with a 10000-file cap so deep package paths are reached while the walk stays bounded on large trees (-scan-depth still applies when set explicitly). Gradle build script patterns are dropped from the Java and Kotlin language definitions since a Gradle build script says nothing about which JVM language the source is in. testdata is added to skipDirs so the new .java fixtures do not leak into the host project's language list.

Fixes #84.

The default extension scan stopped at depth 4, which misses
app/src/main/java/<pkg>/ in the layout that gradle init produces, so
**/*.java found nothing and the ecosystem gate then filtered out Gradle
itself. At the same time *.kts in Kotlin's detect.files matched
settings.gradle.kts at the root and reported the project as Kotlin.

Replace the depth bound with a 10000-file cap (ScanDepth still applies
when set explicitly), drop Gradle build script patterns from the Java
and Kotlin language definitions, and add testdata to skipDirs so fixture
source does not leak into the host project's language list.

Fixes #84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

brief detects Java project with Kotlin-based Gradle build file as Kotlin

1 participant