This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 8403c2994 fix(maven): move check for MAVEN_CMD before maven wrapper
setup
8403c2994 is described below
commit 8403c29944cf0aac8f47c67d8c8408655844dc98
Author: Luca Burgazzoli <[email protected]>
AuthorDate: Wed May 8 12:43:18 2024 +0200
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/platform/platform.go | 5 +++--
pkg/util/maven/maven_command.go | 22 +++++++++++++---------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index e4f655bd0..c9ba4ea64 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -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
}
}
@@ -156,7 +157,7 @@ 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
@@ -164,7 +165,7 @@ func findLocal(ctx context.Context, c k8sclient.Reader,
namespace string) (*v1.I
}
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
}
diff --git a/pkg/util/maven/maven_command.go b/pkg/util/maven/maven_command.go
index df7e0856b..acaeb6c1f 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...)