Skip to content

Commit

Permalink
🐛 Also download deps prior to downloading sources (#414)
Browse files Browse the repository at this point in the history
Fixes #406

Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad authored Nov 10, 2023
1 parent d295615 commit 16bc5b1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions provider/internal/java/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,20 @@ func resolveSourcesJars(ctx context.Context, log logr.Logger, location, mavenSet
}

args := []string{
"dependency:go-offline",
"-Djava.net.useSystemProxies=true",
}
if mavenSettings != "" {
args = append(args, "-s", mavenSettings)
}
cmd := exec.CommandContext(ctx, "mvn", args...)
cmd.Dir = location
err = cmd.Run()
if err != nil {
log.V(5).Error(err, "failed to download dependencies, continuing to download sources")
}

args = []string{
"-B",
"org.apache.maven.plugins:maven-dependency-plugin:3.6.2-SNAPSHOT:sources",
"-Djava.net.useSystemProxies=true",
Expand All @@ -346,7 +360,7 @@ func resolveSourcesJars(ctx context.Context, log logr.Logger, location, mavenSet
if mavenSettings != "" {
args = append(args, "-s", mavenSettings)
}
cmd := exec.CommandContext(ctx, "mvn", args...)
cmd = exec.CommandContext(ctx, "mvn", args...)
cmd.Dir = location
mvnOutput, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -387,9 +401,12 @@ func resolveSourcesJars(ctx context.Context, log logr.Logger, location, mavenSet
// move decompiled files to base location of the jar
for _, decompileJob := range decompileJobs {
jarName := strings.TrimSuffix(filepath.Base(decompileJob.inputPath), ".jar")
moveFile(decompileJob.outputPath,
err = moveFile(decompileJob.outputPath,
filepath.Join(filepath.Dir(decompileJob.inputPath),
fmt.Sprintf("%s-sources.jar", jarName)))
if err != nil {
log.V(5).Error(err, "failed to move decompiled file", "file", decompileJob.outputPath)
}
}
return nil
}
Expand Down

0 comments on commit 16bc5b1

Please sign in to comment.