fix(manifest): detect Gradle projects by build script, not gradlew wrapper (REA-622)#1399
Conversation
…apper detectManifestActions gated Gradle auto-detection on `gradlew`, so `scan create --auto-manifest` and `socket manifest auto` skipped a Gradle project that builds with `gradle` on PATH (no wrapper) — inconsistent with `socket manifest gradle`, whose bin already falls back to gradle on PATH. Detect by `build.gradle`/`build.gradle.kts` instead, mirroring `pom.xml` (Maven) and `build.sbt` (sbt).
|
One case this regresses: Gradle only requires a settings file at the build root — a root The corpus check in the PR body (kafka, RxJava, elasticsearch, okhttp, …) skews toward older/Groovy-heavy projects that do keep a root build script, so it doesn't cover this layout. Suggestion: add |
A Kotlin-DSL multi-module root can have only a settings file and no root build.gradle; such a project (with a gradlew wrapper) was detected before the build-script change and would otherwise regress to undetected. settings.gradle is Gradle's build-root marker, so detect it alongside build.gradle(.kts).
|
You're right, and my corpus (older/Groovy-heavy projects) masked it — a Kotlin-DSL multi-module root can have only Fixed in 2ca6f43: detection now also checks The |
…anifest-detect-gradle-projects-by-build-script-not-by # Conflicts: # CHANGELOG.md
Problem
scan create . --auto-manifest(andsocket manifest auto) skipped Gradle projects unless agradlewwrapper was present —detectManifestActionsgated Gradle detection solely onexistsSync(cwd/'gradlew'). This is inconsistent withsocket manifest gradle, whose bin already falls back togradleon PATH when there's no wrapper. So a wrapper-less Gradle project worked withsocket manifest gradlebut was silently ignored by--auto-manifest, regardless of anybinset insocket.json(detection never passed, so generation was never reached).Fix
Detect Gradle by its build script —
build.gradle/build.gradle.kts— instead of the wrapper, mirroring how the other ecosystems are detected (pom.xmlfor Maven,build.sbtfor sbt). The wrapper is not a build descriptor; the Maven analog would bemvnw, which we deliberately don't check.Empirically validated against a corpus of real Gradle/Kotlin projects (kafka, RxJava, elasticsearch, okhttp, leakcanary, Kotson, klaxon): every Gradle root/subproject has a
build.gradle(.kts) — 0 of 15settings.gradledirs lacked one — sosettings.gradleisn't needed as an extra marker and dropping thegradlewrequirement regresses no real project.Testing
detect-manifest-actions.test.mts: detectsbuild.gradle/build.gradle.kts, detects a wrapper-less project, does not detect from a baregradlew, and honors thedisabledflag. Updated the existing bazel+gradle co-detect test to usebuild.gradle.socket manifest autoon a wrapper-lessbuild.gradleproject now detects Gradle and writes.socket.facts.json(8 components); previously it was skipped.pnpm check:tscclean; 11/11 detector tests pass.Closes REA-622. Part of the same Unreleased version as the REA-519 config-transparency PR (#1398).
Note
Low Risk
Narrow change to manifest auto-detection heuristics with tests; may surface Gradle generation on dirs that previously had only gradlew without a root build script.
Overview
Gradle auto-manifest detection now keys off
build.gradle/build.gradle.ktsinstead of agradlewwrapper, sosocket manifest autoandscan create --auto-manifesttreat wrapper-less projects the same as explicitsocket manifest gradle(which can usegradleon PATH).A repo with only
gradlewand no build script is no longer flagged as Gradle. The Unreleased changelog documents the behavior change, and unit tests cover both scripts, wrapper-only negatives, and thesocket.jsondisable flag.Reviewed by Cursor Bugbot for commit 10a0aa8. Configure here.