snyk / snyk-gradle-plugin

Basic Snyk CLI plugin for Gradle support
Other
25 stars 19 forks source link

Use gradle wrapper from root project when starting snyk cli in a sub project directory #196

Closed Larusso closed 11 months ago

Larusso commented 2 years ago

If one executes snyk in a directory of a gradle sub project snyk won't use the gradle wrapper but falls back to the system gradle. Our CI system has no gradle installed and fails in these situations. The only workaround is to call snyk from the project root and set either the subproject name with --sub-project or the path to the build.gradle file with --file.

Expected behaviour

The snyk cli should check for a settings.gradle file in the current directory and if this can't be found walk up the file herachy until it finds one. Every gradle project should have a settings.gradle file and this file declares the project root. If this location has been found, the cli should check for a gradle wrapper in that directory and use it.

Actual behaviour

The snyk cli only checks in the current directory for the gradle wrapper and falls back to plain gradle if it can not be found.

See the code in question which only works when snyk cli is executed at project root.

https://github.com/snyk/snyk-gradle-plugin/blob/9989b21137695bedc5182f551e6d3299e6eebb23/lib/index.ts#L701-L720

mcooper7290 commented 1 year ago

We are seeing the same problem. The suggested solution would be ideal.