From 8a9c64049c8ea1a3e9a294abe908b881bfc8ddab Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Thu, 1 Aug 2024 09:32:10 -0400 Subject: [PATCH] :bug: fix maven download of deps when they are downloaded to a different location Signed-off-by: Pranav Gaikwad --- external-providers/dotnet-external-provider/go.mod | 2 +- external-providers/dotnet-external-provider/go.sum | 2 ++ external-providers/generic-external-provider/go.mod | 2 +- external-providers/generic-external-provider/go.sum | 2 ++ external-providers/golang-dependency-provider/go.mod | 2 +- external-providers/golang-dependency-provider/go.sum | 2 ++ external-providers/java-external-provider/go.mod | 2 +- external-providers/java-external-provider/go.sum | 2 ++ .../pkg/java_external_provider/provider.go | 12 +++++++++++- external-providers/yq-external-provider/go.mod | 4 ++-- external-providers/yq-external-provider/go.sum | 8 ++++---- 11 files changed, 29 insertions(+), 11 deletions(-) diff --git a/external-providers/dotnet-external-provider/go.mod b/external-providers/dotnet-external-provider/go.mod index 05452d45..247155bf 100644 --- a/external-providers/dotnet-external-provider/go.mod +++ b/external-providers/dotnet-external-provider/go.mod @@ -3,7 +3,7 @@ module github.com/konveyor/dotnet-external-provider go 1.20 require ( - github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59 + github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd go.lsp.dev/jsonrpc2 v0.10.0 go.lsp.dev/protocol v0.12.0 go.lsp.dev/uri v0.3.0 diff --git a/external-providers/dotnet-external-provider/go.sum b/external-providers/dotnet-external-provider/go.sum index 7909ca73..eeb5488f 100644 --- a/external-providers/dotnet-external-provider/go.sum +++ b/external-providers/dotnet-external-provider/go.sum @@ -26,6 +26,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd h1:mDu+2r8AIDxoIQ8UrGFT3AYygPBZFfQOVL3YfJIPkMw= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd/go.mod h1:Gqj6MRUA2Jjjw19tUguJB6Bqj4dLwZzb68FmAUok0ac= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= diff --git a/external-providers/generic-external-provider/go.mod b/external-providers/generic-external-provider/go.mod index 2df3cd5b..c7ab8b09 100644 --- a/external-providers/generic-external-provider/go.mod +++ b/external-providers/generic-external-provider/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/bombsimon/logrusr/v3 v3.1.0 github.com/go-logr/logr v1.2.4 - github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59 + github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd github.com/sirupsen/logrus v1.9.3 github.com/swaggest/openapi-go v0.2.45 go.lsp.dev/uri v0.3.0 diff --git a/external-providers/generic-external-provider/go.sum b/external-providers/generic-external-provider/go.sum index aa8f9f39..dc428160 100644 --- a/external-providers/generic-external-provider/go.sum +++ b/external-providers/generic-external-provider/go.sum @@ -26,6 +26,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd h1:mDu+2r8AIDxoIQ8UrGFT3AYygPBZFfQOVL3YfJIPkMw= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd/go.mod h1:Gqj6MRUA2Jjjw19tUguJB6Bqj4dLwZzb68FmAUok0ac= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= diff --git a/external-providers/golang-dependency-provider/go.mod b/external-providers/golang-dependency-provider/go.mod index 96cdc63a..571533e8 100644 --- a/external-providers/golang-dependency-provider/go.mod +++ b/external-providers/golang-dependency-provider/go.mod @@ -3,7 +3,7 @@ module github.com/konveyor/golang-dependency-provider go 1.19 require ( - github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59 + github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd go.lsp.dev/uri v0.3.0 google.golang.org/grpc v1.62.1 // indirect ) diff --git a/external-providers/golang-dependency-provider/go.sum b/external-providers/golang-dependency-provider/go.sum index 60c8aade..6e7c00a8 100644 --- a/external-providers/golang-dependency-provider/go.sum +++ b/external-providers/golang-dependency-provider/go.sum @@ -23,6 +23,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd h1:mDu+2r8AIDxoIQ8UrGFT3AYygPBZFfQOVL3YfJIPkMw= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd/go.mod h1:Gqj6MRUA2Jjjw19tUguJB6Bqj4dLwZzb68FmAUok0ac= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= diff --git a/external-providers/java-external-provider/go.mod b/external-providers/java-external-provider/go.mod index 982c95be..3e2a902f 100644 --- a/external-providers/java-external-provider/go.mod +++ b/external-providers/java-external-provider/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/go-logr/logr v1.4.1 - github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59 + github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd github.com/swaggest/openapi-go v0.2.50 go.lsp.dev/uri v0.3.0 go.opentelemetry.io/otel v1.11.2 diff --git a/external-providers/java-external-provider/go.sum b/external-providers/java-external-provider/go.sum index 2a45f41b..0aefbe68 100644 --- a/external-providers/java-external-provider/go.sum +++ b/external-providers/java-external-provider/go.sum @@ -28,6 +28,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd h1:mDu+2r8AIDxoIQ8UrGFT3AYygPBZFfQOVL3YfJIPkMw= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd/go.mod h1:Gqj6MRUA2Jjjw19tUguJB6Bqj4dLwZzb68FmAUok0ac= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 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 a06029d2..cb3bfb16 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 @@ -272,7 +272,8 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide log.Info("downloading maven artifact", "artifact", mvnCoordinates, "options", mvnOptions) cmd := exec.CommandContext(ctx, "mvn", mvnOptions...) cmd.Dir = outputDir - if err := cmd.Run(); err != nil { + mvnOutput, err := cmd.CombinedOutput() + if err != nil { cancelFunc() return nil, additionalBuiltinConfig, fmt.Errorf("error downloading java artifact %s - %w", mvnUri, err) } @@ -282,6 +283,15 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide downloadedPath = filepath.Join(outputDir, fmt.Sprintf("%s.%s", strings.Join(mvnCoordinatesParts[1:3], "-"), strings.ToLower(mvnCoordinatesParts[3]))) } + outputLinePattern := regexp.MustCompile(`.*?Copying.*?to (.*)`) + for _, line := range strings.Split(string(mvnOutput), "\n") { + if outputLinePattern.MatchString(line) { + match := outputLinePattern.FindStringSubmatch(line) + if match != nil { + downloadedPath = match[1] + } + } + } if _, err := os.Stat(downloadedPath); err != nil { cancelFunc() return nil, additionalBuiltinConfig, fmt.Errorf("failed to download maven artifact to path %s - %w", downloadedPath, err) diff --git a/external-providers/yq-external-provider/go.mod b/external-providers/yq-external-provider/go.mod index eaacaa89..f0741612 100644 --- a/external-providers/yq-external-provider/go.mod +++ b/external-providers/yq-external-provider/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/bombsimon/logrusr/v3 v3.1.0 github.com/go-logr/logr v1.2.4 - github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59 + github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd github.com/sirupsen/logrus v1.9.3 github.com/swaggest/openapi-go v0.2.45 go.lsp.dev/uri v0.3.0 @@ -34,7 +34,7 @@ require ( go.opentelemetry.io/otel/trace v1.11.2 // indirect golang.org/x/mod v0.8.0 golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 // indirect ) diff --git a/external-providers/yq-external-provider/go.sum b/external-providers/yq-external-provider/go.sum index 2e09fb6b..f3ef41d3 100644 --- a/external-providers/yq-external-provider/go.sum +++ b/external-providers/yq-external-provider/go.sum @@ -25,8 +25,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59 h1:ybaunU+d9G4yMU2rhYVmO624QupG5JjiOA1rNCMh38o= -github.com/konveyor/analyzer-lsp v0.4.0-alpha.1.0.20240520232004-8af6f5c84a59/go.mod h1:GXkSykQ84oE1SyMvFko9s9wRn/FMdl4efLLWSjMX2nU= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd h1:mDu+2r8AIDxoIQ8UrGFT3AYygPBZFfQOVL3YfJIPkMw= +github.com/konveyor/analyzer-lsp v0.5.0-rc.1.0.20240729200152-daea76a602fd/go.mod h1:Gqj6MRUA2Jjjw19tUguJB6Bqj4dLwZzb68FmAUok0ac= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= @@ -66,8 +66,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=