diff --git a/CHANGELOG.md b/CHANGELOG.md index 042a20560..72d95bfdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). the run unless you pass `--ignore-unresolved`, so an incomplete scan can't slip by unnoticed. Benign variant-selection ambiguity stays a one-line notice. +### Fixed +- `socket manifest auto` and `scan create --auto-manifest` now detect a Gradle + project by its build files (`build.gradle`/`.kts` or `settings.gradle`/`.kts`) + instead of requiring a `gradlew` wrapper, so a project that builds with + `gradle` on your PATH — including a settings-only multi-module root — is no + longer skipped. + ## [1.1.135](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.135) - 2026-07-01 ### Changed diff --git a/src/commands/manifest/detect-manifest-actions.mts b/src/commands/manifest/detect-manifest-actions.mts index 7be3f7330..e5f65e77f 100644 --- a/src/commands/manifest/detect-manifest-actions.mts +++ b/src/commands/manifest/detect-manifest-actions.mts @@ -72,7 +72,14 @@ export async function detectManifestActions( 'notice', `[DEBUG] - gradle auto-detection is disabled in ${SOCKET_JSON}`, ) - } else if (existsSync(path.join(cwd, 'gradlew'))) { + } else if ( + existsSync(path.join(cwd, 'build.gradle')) || + existsSync(path.join(cwd, 'build.gradle.kts')) || + existsSync(path.join(cwd, 'settings.gradle')) || + existsSync(path.join(cwd, 'settings.gradle.kts')) + ) { + // Detect by build descriptor, not the `gradlew` wrapper (a project can build via + // `gradle` on PATH). `settings.gradle(.kts)` covers Kotlin-DSL roots with no root build script. debugLog('notice', '[DEBUG] - Detected a gradle build file') output.gradle = true output.count += 1 diff --git a/src/commands/manifest/detect-manifest-actions.test.mts b/src/commands/manifest/detect-manifest-actions.test.mts index 116d50d70..2ae961553 100644 --- a/src/commands/manifest/detect-manifest-actions.test.mts +++ b/src/commands/manifest/detect-manifest-actions.test.mts @@ -66,10 +66,75 @@ describe('detectManifestActions — bazel detector', () => { it('co-detects bazel and gradle when both markers are present', async () => { touch(cwd, 'MODULE.bazel') - touch(cwd, 'gradlew') + touch(cwd, 'build.gradle') const result = await detectManifestActions(null, cwd) expect(result.bazel).toBe(true) expect(result.gradle).toBe(true) expect(result.count).toBe(2) }) }) + +describe('detectManifestActions — gradle detector', () => { + let cwd: string + + beforeEach(() => { + cwd = mkTmp() + }) + + afterEach(() => { + rmSync(cwd, { recursive: true, force: true }) + }) + + it('detects build.gradle', async () => { + touch(cwd, 'build.gradle') + const result = await detectManifestActions(null, cwd) + expect(result.gradle).toBe(true) + expect(result.count).toBe(1) + }) + + it('detects build.gradle.kts', async () => { + touch(cwd, 'build.gradle.kts') + const result = await detectManifestActions(null, cwd) + expect(result.gradle).toBe(true) + expect(result.count).toBe(1) + }) + + it('detects settings.gradle', async () => { + touch(cwd, 'settings.gradle') + const result = await detectManifestActions(null, cwd) + expect(result.gradle).toBe(true) + expect(result.count).toBe(1) + }) + + it('detects a settings-only Kotlin-DSL root (settings.gradle.kts, no build.gradle)', async () => { + touch(cwd, 'settings.gradle.kts') + touch(cwd, 'gradlew') + const result = await detectManifestActions(null, cwd) + expect(result.gradle).toBe(true) + }) + + it('detects a wrapper-less gradle project (build.gradle, no gradlew)', async () => { + touch(cwd, 'build.gradle') + const result = await detectManifestActions(null, cwd) + expect(result.gradle).toBe(true) + }) + + it('does not detect gradle from a gradlew wrapper alone', async () => { + touch(cwd, 'gradlew') + const result = await detectManifestActions(null, cwd) + expect(result.gradle).toBe(false) + expect(result.count).toBe(0) + }) + + it('skips gradle when defaults.manifest.gradle.disabled is true', async () => { + touch(cwd, 'build.gradle') + const result = await detectManifestActions( + { + defaults: { manifest: { gradle: { disabled: true } } }, + } as SocketJson, + cwd, + ) + expect(result.gradle).toBe(false) + expect(result.count).toBe(0) + }) +})