From 17a5d854e1c7cd293a6e84b5b2287d77ac75fc22 Mon Sep 17 00:00:00 2001 From: "konveyor-ci-bot[bot]" <159171263+konveyor-ci-bot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:39:37 +0100 Subject: [PATCH] :sparkles: Print maven output on Maven error (#709) (#747) Fixes https://github.com/konveyor/analyzer-lsp/issues/696 --------- Signed-off-by: Juan Manuel Leflet Estrada Signed-off-by: Cherry Picker Signed-off-by: Juan Manuel Leflet Estrada Signed-off-by: Cherry Picker Co-authored-by: Juan Manuel Leflet Estrada --- .../pkg/java_external_provider/dependency.go | 4 ++-- .../pkg/java_external_provider/provider.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/external-providers/java-external-provider/pkg/java_external_provider/dependency.go b/external-providers/java-external-provider/pkg/java_external_provider/dependency.go index 3569d6d8..6d6d00a0 100644 --- a/external-providers/java-external-provider/pkg/java_external_provider/dependency.go +++ b/external-providers/java-external-provider/pkg/java_external_provider/dependency.go @@ -177,7 +177,7 @@ func getMavenLocalRepoPath(mvnSettingsFile string) string { } // check errors - return string(outb.String()) + return outb.String() } func (p *javaServiceClient) GetDependenciesFallback(ctx context.Context, location string) (map[uri.URI][]*provider.Dep, error) { @@ -329,7 +329,7 @@ func (p *javaServiceClient) getDependenciesForMaven(_ context.Context) (map[uri. cmd.Dir = moddir mvnOutput, err := cmd.CombinedOutput() if err != nil { - return nil, err + return nil, fmt.Errorf("maven dependency:tree command failed with error %w, maven output: %s", err, string(mvnOutput)) } lines := strings.Split(string(mvnOutput), "\n") diff --git a/external-providers/java-external-provider/pkg/java_external_provider/provider.go b/external-providers/java-external-provider/pkg/java_external_provider/provider.go index b5f27481..6b06ef70 100644 --- a/external-providers/java-external-provider/pkg/java_external_provider/provider.go +++ b/external-providers/java-external-provider/pkg/java_external_provider/provider.go @@ -299,7 +299,7 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide mvnOutput, err := cmd.CombinedOutput() if err != nil { cancelFunc() - return nil, additionalBuiltinConfig, fmt.Errorf("error downloading java artifact %s - %w", mvnUri, err) + return nil, additionalBuiltinConfig, fmt.Errorf("error downloading java artifact %s - maven output: %s - with error %w", mvnUri, string(mvnOutput), err) } downloadedPath := filepath.Join(outputDir, fmt.Sprintf("%s.jar", strings.Join(mvnCoordinatesParts[1:3], "-"))) @@ -714,7 +714,7 @@ func resolveSourcesJarsForMaven(ctx context.Context, log logr.Logger, fernflower cmd.Dir = location mvnOutput, err := cmd.CombinedOutput() if err != nil { - return err + return fmt.Errorf("maven downloadSources command failed with error %w, maven output: %s", err, string(mvnOutput)) } reader := bytes.NewReader(mvnOutput)