-
Notifications
You must be signed in to change notification settings - Fork 53
✨ Add Maven index search functionality #921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,6 +286,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide | |
| } | ||
|
|
||
| disableMavenSearch, ok := config.ProviderSpecificConfig[DISABLE_MAVEN_SEARCH].(bool) | ||
| mavenIndexPath, ok := config.ProviderSpecificConfig[providerSpecificConfigMavenIndexPath].(string) | ||
|
Comment on lines
288
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify handling of missing or empty The Consider adding validation and logging: disableMavenSearch, ok := config.ProviderSpecificConfig[DISABLE_MAVEN_SEARCH].(bool)
-mavenIndexPath, ok := config.ProviderSpecificConfig[providerSpecificConfigMavenIndexPath].(string)
+mavenIndexPath, ok := config.ProviderSpecificConfig[providerSpecificConfigMavenIndexPath].(string)
+if !ok || mavenIndexPath == "" {
+ log.V(5).Info("mavenIndexPath not configured, index-based dependency resolution will be unavailable")
+}Run this script to verify how downstream code handles an empty 🏁 Script executed: #!/bin/bash
# Description: Check how decompileJava and decompile functions handle empty mavenIndexPath
# Search for decompileJava function definition and usage
ast-grep --pattern $'func decompileJava($$$, mavenIndexPath string) $$$'
# Search for decompile function definition and usage
ast-grep --pattern $'func decompile($$$, mavenIndexPath string) $$$'
# Check if there are any validation checks for empty mavenIndexPath
rg -nP --type=go 'mavenIndexPath\s*(==|!=)\s*""' -A3 -B3Length of output: 0 Length of output: 11596 Length of output: 5021 Fix critical bug: Line 369 passes At line 366, Line 369 incorrectly passes depLocation, sourceLocation, err := decompileJava(ctx, log, fernflower,
config.Location, getMavenLocalRepoPath(mavenSettingsFile), ok, mavenIndexPath)This should pass Regarding the original 🤖 Prompt for AI Agents |
||
|
|
||
| isBinary := false | ||
| var returnErr error | ||
|
|
@@ -365,7 +366,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide | |
| cleanBin, ok := config.ProviderSpecificConfig[CLEAN_EXPLODED_BIN_OPTION].(bool) | ||
|
|
||
| depLocation, sourceLocation, err := decompileJava(ctx, log, fernflower, | ||
| config.Location, getMavenLocalRepoPath(mavenSettingsFile), ok, openSourceDepLabels, disableMavenSearch) | ||
| config.Location, getMavenLocalRepoPath(mavenSettingsFile), ok, mavenIndexPath) | ||
| if err != nil { | ||
| cancelFunc() | ||
| return nil, additionalBuiltinConfig, err | ||
|
|
@@ -506,13 +507,6 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide | |
|
|
||
| m2Repo := getMavenLocalRepoPath(mavenSettingsFile) | ||
|
|
||
| mavenIndexPath := "" | ||
| if val, ok := config.ProviderSpecificConfig[providerSpecificConfigOpenSourceDepListKey]; ok { | ||
| if strVal, ok := val.(string); ok { | ||
| mavenIndexPath = strVal | ||
| } | ||
| } | ||
|
|
||
| svcClient := javaServiceClient{ | ||
| rpc: rpc, | ||
| cancelFunc: cancelFunc, | ||
|
|
@@ -539,7 +533,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide | |
| // we need to do this for jdtls to correctly recognize source attachment for dep | ||
| switch svcClient.GetBuildTool() { | ||
| case maven: | ||
| err := svcClient.resolveSourcesJarsForMaven(ctx, fernflower, disableMavenSearch) | ||
| err := svcClient.resolveSourcesJarsForMaven(ctx, fernflower, mavenIndexPath) | ||
| if err != nil { | ||
| // TODO (pgaikwad): should we ignore this failure? | ||
| log.Error(err, "failed to resolve maven sources jar for location", "location", config.Location) | ||
|
|
@@ -549,7 +543,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide | |
| if !ok { | ||
| gradleTaskFile = "" | ||
| } | ||
| err = svcClient.resolveSourcesJarsForGradle(ctx, fernflower, disableMavenSearch, gradleTaskFile.(string)) | ||
| err = svcClient.resolveSourcesJarsForGradle(ctx, fernflower, disableMavenSearch, gradleTaskFile.(string), mavenIndexPath) | ||
| if err != nil { | ||
| log.Error(err, "failed to resolve gradle sources jar for location", "location", config.Location) | ||
| } | ||
|
|
@@ -593,7 +587,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide | |
| return &svcClient, additionalBuiltinConfig, returnErr | ||
| } | ||
|
|
||
| func (s *javaServiceClient) resolveSourcesJarsForGradle(ctx context.Context, fernflower string, disableMavenSearch bool, taskFile string) error { | ||
| func (s *javaServiceClient) resolveSourcesJarsForGradle(ctx context.Context, fernflower string, disableMavenSearch bool, taskFile string, mavenIndexPath string) error { | ||
| ctx, span := tracing.StartNewSpan(ctx, "resolve-sources") | ||
| defer span.End() | ||
|
|
||
|
|
@@ -702,7 +696,7 @@ func (s *javaServiceClient) resolveSourcesJarsForGradle(ctx context.Context, fer | |
| outputPath: filepath.Join(filepath.Dir(artifactPath), "decompiled", jarName), | ||
| }) | ||
| } | ||
| err = decompile(ctx, s.log, alwaysDecompileFilter(true), 10, decompileJobs, fernflower, "", s.depToLabels, disableMavenSearch) | ||
| err = decompile(ctx, s.log, alwaysDecompileFilter(true), 10, decompileJobs, fernflower, "", mavenIndexPath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -849,7 +843,7 @@ func (j *javaProvider) GetLocation(ctx context.Context, dep konveyor.Dep, file s | |
|
|
||
| // resolveSourcesJarsForMaven for a given source code location, runs maven to find | ||
| // deps that don't have sources attached and decompiles them | ||
| func (s *javaServiceClient) resolveSourcesJarsForMaven(ctx context.Context, fernflower string, disableMavenSearch bool) error { | ||
| func (s *javaServiceClient) resolveSourcesJarsForMaven(ctx context.Context, fernflower string, mavenIndexPath string) error { | ||
| // TODO (pgaikwad): when we move to external provider, inherit context from parent | ||
| ctx, span := tracing.StartNewSpan(ctx, "resolve-sources") | ||
| defer span.End() | ||
|
|
@@ -902,7 +896,7 @@ func (s *javaServiceClient) resolveSourcesJarsForMaven(ctx context.Context, fern | |
| s.mvnLocalRepo, groupDirs, artifactDirs, artifact.Version, "decompiled", jarName), | ||
| }) | ||
| } | ||
| err = decompile(ctx, s.log, alwaysDecompileFilter(true), 10, decompileJobs, fernflower, "", s.depToLabels, disableMavenSearch) | ||
| err = decompile(ctx, s.log, alwaysDecompileFilter(true), 10, decompileJobs, fernflower, "", mavenIndexPath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.