Skip to content

Commit f45ff37

Browse files
committed
fix: tool version config
1 parent d9e83dc commit f45ff37

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

module/maven/mvn_cmd_utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func CheckMvnCommand(ctx context.Context, isNoBuild bool) (info *MvnCommandInfo,
9191
info.Path = toolVer.Maven.MavenCommand
9292
if info.Path == "" {
9393
info.Path = getMvnCommandOs()
94+
logger.Sugar().Infof("Use system mvn command: %s", info.Path)
9495
}
9596
if info.Path == "" {
9697
return nil, ErrMvnNotFound

toolver/env.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import (
77
)
88

99
var envOnce sync.Once
10-
var envConfig *Config
10+
var envConfig Config
1111

1212
func getFromEnv() *Config {
1313
envOnce.Do(func() {
1414
var s = os.Getenv("AUTO_BUILD_TOOLCHAIN_CONFIG")
1515
if s != "" {
16-
var o Config
17-
if json.Unmarshal([]byte(s), &o) != nil {
18-
envConfig = &o
16+
if e := json.Unmarshal([]byte(s), &envConfig); e != nil {
17+
panic(e)
1918
}
2019
}
2120
})
22-
return envConfig
21+
return &envConfig
2322
}

toolver/get.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ var Default Config
99
var postprocessors []func(context.Context, *Config)
1010

1111
func Get(ctx context.Context) *Config {
12-
return mergeConfig(mergeConfig(&Default, getIntellijConfig()), getFromEnv())
12+
var r = mergeConfig(mergeConfig(&Default, getIntellijConfig()), getFromEnv())
13+
for _, it := range postprocessors {
14+
it(ctx, r)
15+
}
16+
return r
1317
}
1418

1519
func mergeConfig(old *Config, new *Config) *Config {

toolver/scae_predefined_config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package toolver
22

33
import (
44
"context"
5-
6-
"github.com/murphysecurity/murphysec/utils"
75
)
86

97
func init() {
@@ -29,7 +27,7 @@ func locateJavaHome(version string) string {
2927
case "jdk21":
3028
javaHome = "/opt/java/21"
3129
}
32-
if javaHome != "" && utils.IsDirResolveSymlink(javaHome) {
30+
if javaHome != "" {
3331
return javaHome
3432
}
3533
return ""
@@ -45,7 +43,7 @@ func locateMvnHome(version string) string {
4543
case "maven3.9.5":
4644
mvnHome = "/opt/maven/3.9.5"
4745
}
48-
if mvnHome != "" && utils.IsDirResolveSymlink(mvnHome) {
46+
if mvnHome != "" {
4947
return mvnHome
5048
}
5149
return ""

0 commit comments

Comments
 (0)