Skip to content

Commit

Permalink
Add check for gradle wrapper
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
  • Loading branch information
jmle committed May 20, 2024
1 parent 017dea3 commit fc46599
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ func (p *javaServiceClient) getDependenciesForMaven(ctx context.Context) (map[ur
}

// getDependenciesForGradle invokes the Gradle wrapper to get the dependency tree and returns all project dependencies
// TODO: what if no wrapper?
func (p *javaServiceClient) getDependenciesForGradle(ctx context.Context) (map[uri.URI][]provider.DepDAGItem, error) {
subprojects, err := p.getGradleSubprojects()
if err != nil {
Expand All @@ -355,6 +354,9 @@ func (p *javaServiceClient) getDependenciesForGradle(ctx context.Context) (map[u
if err != nil {
return nil, fmt.Errorf("error calculating gradle wrapper path")
}
if _, err = os.Stat(exe); errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("a gradle wrapper must be present in the project")
}
cmd := exec.Command(exe, args...)
cmd.Dir = p.config.Location
output, err := cmd.CombinedOutput()
Expand Down Expand Up @@ -392,6 +394,9 @@ func (p *javaServiceClient) getGradleSubprojects() ([]string, error) {
if err != nil {
return nil, fmt.Errorf("error calculating gradle wrapper path")
}
if _, err = os.Stat(exe); errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("a gradle wrapper must be present in the project")
}
cmd := exec.Command(exe, args...)
cmd.Dir = p.config.Location
output, err := cmd.CombinedOutput()
Expand Down

0 comments on commit fc46599

Please sign in to comment.