{"id":18803,"library":"snyk-gradle-plugin","title":"Snyk Gradle Plugin","description":"Snyk CLI plugin for Gradle projects providing dependency metadata for vulnerability scanning. Current version 5.1.1 (Nov 2025), with a fast release cadence around 2-3 months. Supports Gradle 4-9, Node 16-20, and Windows/Linux/macOS. Key differentiator: integrates with Snyk CLI to automatically detect and fix vulnerabilities in Gradle dependencies, including multi-project builds and custom configuration matching.","status":"active","version":"5.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/snyk/snyk-gradle-plugin","tags":["javascript","typescript"],"install":[{"cmd":"npm install snyk-gradle-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add snyk-gradle-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add snyk-gradle-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Defines plugin interface and types for Snyk CLI interoperability","package":"@snyk/cli-interface","optional":false},{"reason":"Internal debugging support","package":"debug","optional":false}],"imports":[{"note":"ESM-only since v5.0.0; default export not available","wrong":"const inspect = require('snyk-gradle-plugin')","symbol":"inspect","correct":"import { inspect } from 'snyk-gradle-plugin'"},{"note":"Named export, not default export","wrong":"import buildDepTree from 'snyk-gradle-plugin'","symbol":"buildDepTree","correct":"import { buildDepTree } from 'snyk-gradle-plugin'"},{"note":"TypeScript type import, not a runtime value","wrong":"import { PluginOptions } from 'snyk-gradle-plugin'","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'snyk-gradle-plugin'"}],"quickstart":{"code":"import { inspect } from 'snyk-gradle-plugin';\n\nconst options = {\n  path: process.cwd(),\n  gradleSubProject: process.env.GRADLE_SUB_PROJECT || '',\n  allSubProjects: false,\n  configurationMatching: '^releaseRuntimeClasspath$',\n  configurationAttributes: 'buildtype:release,usage:java-runtime',\n};\n\nasync function run() {\n  try {\n    const result = await inspect(options);\n    console.log(JSON.stringify(result, null, 2));\n  } catch (error) {\n    console.error('Inspection failed:', error.message);\n  }\n}\n\nrun();","lang":"typescript","description":"Scans a Gradle project for vulnerabilities using the inspect function, with configuration matching for specific dependency configurations."},"warnings":[{"fix":"Update any code relying on node ID format; previously node IDs assumed only one artifact per resolved dependency","message":"Node IDs changed to uniquely identify all dependencies in v5.0.0","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use import statements: `import { inspect } from 'snyk-gradle-plugin'`","message":"CommonJS require() is deprecated; the package is ESM-only since v5.0.0","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Upgrade to v4.9.1 or later, or ensure paths have no spaces","message":"Spaces in project path on Windows cause errors (fixed in v4.9.1 but may appear in older versions)","severity":"gotcha","affected_versions":"<4.9.1"},{"fix":"Upgrade Node to version 16 or later","message":"v5.0.0 requires Node >=16 (drops Node 14 support)","severity":"breaking","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure package is installed: `npm install snyk-gradle-plugin`. Use `import` syntax, not `require`, as the package is ESM-only.","cause":"Package not installed or ESM import used in CJS context","error":"Error: Cannot find module 'snyk-gradle-plugin'"},{"fix":"Use named import: `import { inspect } from 'snyk-gradle-plugin'`","cause":"Incorrect import: using default import instead of named import","error":"TypeError: snyk_gradle_plugin_1.inspect is not a function"},{"fix":"Set `options.path` to the correct Gradle project directory containing build.gradle","cause":"Missing or misconfigured project path","error":"Error: ENOENT: no such file or directory, stat './build.gradle'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}