Skip to content

Commit

Permalink
fix(maven): move check for MAVEN_CMD before maven wrapper setup
Browse files Browse the repository at this point in the history
MAVEN_CMD has the precendence over the maven wrapper, either set via the
MAVEN_WRAPPER env var or copied from a local path. This commit changes
the evaluation order to reflect ordering which avoid to perform a
useless file copy and also make it easy to run the operator off cluster
since the mvnw location may not exist
  • Loading branch information
lburgazzoli committed May 8, 2024
1 parent 8eeaf83 commit 6f038f3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkg/util/maven/maven_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,23 @@ func (c *Command) Do(ctx context.Context) error {
return err
}

if e, ok := os.LookupEnv("MAVEN_WRAPPER"); (ok && e == "true") || !ok {
// Prepare maven wrapper helps when running the builder as Pod as it makes
// the builder container, Maven agnostic
if err := c.prepareMavenWrapper(ctx); err != nil {
return err
}
}

mvnCmd := "./mvnw"
mvnCmd := ""
if c, ok := os.LookupEnv("MAVEN_CMD"); ok {
mvnCmd = c
}

if mvnCmd == "" {
if e, ok := os.LookupEnv("MAVEN_WRAPPER"); (ok && e == "true") || !ok {
// Prepare maven wrapper helps when running the builder as Pod as it makes
// the builder container, Maven agnostic
if err := c.prepareMavenWrapper(ctx); err != nil {
return err
}
}

mvnCmd = "./mvnw"
}

args := make([]string, 0)
args = append(args, c.context.AdditionalArguments...)

Expand Down

0 comments on commit 6f038f3

Please sign in to comment.