diff --git a/provider/internal/java/provider.go b/provider/internal/java/provider.go index 651451ea..d3e2c990 100644 --- a/provider/internal/java/provider.go +++ b/provider/internal/java/provider.go @@ -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") @@ -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