From 6f038f3465478e732170f29752dc3fc6d27075f6 Mon Sep 17 00:00:00 2001 From: Luca Burgazzoli Date: Wed, 8 May 2024 12:43:18 +0200 Subject: [PATCH] fix(maven): move check for MAVEN_CMD before maven wrapper setup 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 --- pkg/util/maven/maven_command.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/util/maven/maven_command.go b/pkg/util/maven/maven_command.go index df7e0856b0..acaeb6c1fd 100644 --- a/pkg/util/maven/maven_command.go +++ b/pkg/util/maven/maven_command.go @@ -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...)