Skip to content

Commit

Permalink
🐛 Only analyze dependencies if running on source-only mode (#429)
Browse files Browse the repository at this point in the history
API Tests PR: 55

Fixes #428

---------

Signed-off-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
  • Loading branch information
jmle authored Nov 15, 2023
1 parent 7ca4a43 commit 740142e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions provider/internal/java/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ func (p *javaProvider) ProviderInit(ctx context.Context) error {
}

func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provider.InitConfig) (provider.ServiceClient, error) {
//By default if nothing is set for analysis mode, in the config, we should default to full for external providers
var a provider.AnalysisMode = provider.AnalysisMode(config.AnalysisMode)
if a == provider.AnalysisMode("") {
a = provider.FullAnalysisMode
} else if !(a == provider.FullAnalysisMode || a == provider.SourceOnlyAnalysisMode) {
// By default, if nothing is set for analysis mode in the config, we should default to full for external providers
var mode provider.AnalysisMode = provider.AnalysisMode(config.AnalysisMode)
if mode == provider.AnalysisMode("") {
mode = provider.FullAnalysisMode
} else if !(mode == provider.FullAnalysisMode || mode == provider.SourceOnlyAnalysisMode) {
return nil, fmt.Errorf("invalid Analysis Mode")
}
log = log.WithValues("provider", "java")
Expand Down Expand Up @@ -233,12 +233,14 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
isBinary = true
}

// we attempt to decompile JARs of dependencies that don't have a sources JAR attached
// we need to do this for jdtls to correctly recognize source attachment for dep
err := resolveSourcesJars(ctx, log, config.Location, mavenSettingsFile)
if err != nil {
// TODO (pgaikwad): should we ignore this failure?
log.Error(err, "failed to resolve sources jar for location", "location", config.Location)
if mode == provider.FullAnalysisMode {
// we attempt to decompile JARs of dependencies that don't have a sources JAR attached
// we need to do this for jdtls to correctly recognize source attachment for dep
err := resolveSourcesJars(ctx, log, config.Location, mavenSettingsFile)
if err != nil {
// TODO (pgaikwad): should we ignore this failure?
log.Error(err, "failed to resolve sources jar for location", "location", config.Location)
}
}

// handle proxy settings
Expand Down

0 comments on commit 740142e

Please sign in to comment.