@@ -491,6 +491,15 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
491491 }
492492 }()
493493
494+ m2Repo := getMavenLocalRepoPath (mavenSettingsFile )
495+
496+ mavenIndexPath := ""
497+ if val , ok := config .ProviderSpecificConfig [providerSpecificConfigOpenSourceDepListKey ]; ok {
498+ if strVal , ok := val .(string ); ok {
499+ mavenIndexPath = strVal
500+ }
501+ }
502+
494503 svcClient := javaServiceClient {
495504 rpc : rpc ,
496505 cancelFunc : cancelFunc ,
@@ -503,6 +512,8 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
503512 isLocationBinary : isBinary ,
504513 mvnInsecure : mavenInsecure ,
505514 mvnSettingsFile : mavenSettingsFile ,
515+ mvnLocalRepo : m2Repo ,
516+ mvnIndexPath : mavenIndexPath ,
506517 globalSettings : globalSettingsFile ,
507518 depsLocationCache : make (map [string ]int ),
508519 includedPaths : provider .GetIncludedPathsFromConfig (config , false ),
@@ -514,7 +525,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide
514525 // we need to do this for jdtls to correctly recognize source attachment for dep
515526 switch svcClient .GetBuildTool () {
516527 case maven :
517- err := resolveSourcesJarsForMaven (ctx , log , fernflower , config .Location , mavenSettingsFile , mavenInsecure )
528+ err := resolveSourcesJarsForMaven (ctx , log , fernflower , config .Location , mavenSettingsFile , m2Repo , mavenInsecure )
518529 if err != nil {
519530 // TODO (pgaikwad): should we ignore this failure?
520531 log .Error (err , "failed to resolve maven sources jar for location" , "location" , config .Location )
@@ -790,11 +801,16 @@ func (j *javaProvider) GetLocation(ctx context.Context, dep konveyor.Dep, file s
790801
791802// resolveSourcesJarsForMaven for a given source code location, runs maven to find
792803// deps that don't have sources attached and decompiles them
793- func resolveSourcesJarsForMaven (ctx context.Context , log logr.Logger , fernflower , location , mavenSettings string , mvnInsecure bool ) error {
804+ func resolveSourcesJarsForMaven (ctx context.Context , log logr.Logger , fernflower , location , mavenSettings , mavenLocalRepo string , mvnInsecure bool ) error {
794805 // TODO (pgaikwad): when we move to external provider, inherit context from parent
795806 ctx , span := tracing .StartNewSpan (ctx , "resolve-sources" )
796807 defer span .End ()
797808
809+ if mavenLocalRepo == "" {
810+ log .V (5 ).Info ("unable to discover dependency sources as maven local repo path is unknown" )
811+ return nil
812+ }
813+
798814 decompileJobs := []decompileJob {}
799815
800816 log .Info ("resolving dependency sources" )
@@ -824,10 +840,6 @@ func resolveSourcesJarsForMaven(ctx context.Context, log logr.Logger, fernflower
824840 return err
825841 }
826842
827- m2Repo := getMavenLocalRepoPath (mavenSettings )
828- if m2Repo == "" {
829- return nil
830- }
831843 for _ , artifact := range artifacts {
832844 log .WithValues ("artifact" , artifact ).Info ("sources for artifact not found, decompiling..." )
833845
@@ -837,9 +849,9 @@ func resolveSourcesJarsForMaven(ctx context.Context, log logr.Logger, fernflower
837849 decompileJobs = append (decompileJobs , decompileJob {
838850 artifact : artifact ,
839851 inputPath : filepath .Join (
840- m2Repo , groupDirs , artifactDirs , artifact .Version , jarName ),
852+ mavenLocalRepo , groupDirs , artifactDirs , artifact .Version , jarName ),
841853 outputPath : filepath .Join (
842- m2Repo , groupDirs , artifactDirs , artifact .Version , "decompiled" , jarName ),
854+ mavenLocalRepo , groupDirs , artifactDirs , artifact .Version , "decompiled" , jarName ),
843855 })
844856 }
845857 err = decompile (ctx , log , alwaysDecompileFilter (true ), 10 , decompileJobs , fernflower , "" )
0 commit comments