Skip to content

Commit

Permalink
feat(gradle): adjust JAVA_HOME by IDEA_MAVEN_JRE
Browse files Browse the repository at this point in the history
  • Loading branch information
iseki-working committed Aug 11, 2023
1 parent 43e313c commit 18cb3a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions module/gradle/gradle_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"github.com/murphysecurity/murphysec/env"
"github.com/murphysecurity/murphysec/infra/logctx"
"github.com/murphysecurity/murphysec/utils"
"os"
"os/exec"
"strings"
)

//goland:noinspection GoNameStartsWithPackageName
Expand Down Expand Up @@ -101,6 +103,14 @@ func evalVersionError(e error) error {

func fixGradleCommandEnv(ctx context.Context, cmd *exec.Cmd) *exec.Cmd {
if env.IdeaMavenJre != "" {
if cmd.Env == nil {
for _, it := range os.Environ() {
if strings.HasPrefix(it, "JAVA_HOME=") {
continue
}
cmd.Env = append(cmd.Env, it)
}
}
cmd.Env = append(cmd.Env, "JAVA_HOME="+env.IdeaMavenJre)
logctx.Use(ctx).Sugar().Debugf("adjust JAVA_HOME environment by IDEA_MAVEN_JRE")
}
Expand Down

0 comments on commit 18cb3a9

Please sign in to comment.