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 6da16e2 commit b260707
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions pkg/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func findLocal(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.I
operatorID := defaults.OperatorID()
if operatorID != "" {
if p, err := get(ctx, c, operatorNamespace, operatorID); err == nil {
log.Debugf("Found integration platform %s for operator %s in namespace %s", operatorID, operatorID, operatorNamespace)
return p, nil
}
}
Expand All @@ -156,15 +157,15 @@ func findLocal(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.I
for _, platform := range lst.Items {
platform := platform // pin
if IsActive(&platform) {
log.Debugf("Found active integration platform %s", platform.Name)
log.Debugf("Found active integration platform %s in namespace %s", platform.Name, namespace)
return &platform, nil
} else {
fallback = &platform
}
}

if fallback != nil {
log.Debugf("Found inactive integration platform %s", fallback.Name)
log.Debugf("Found inactive integration platform %s in namespace %s", fallback.Name, namespace)
return fallback, nil
}

Expand Down
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 b260707

Please sign in to comment.