You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2022/01/17 14:27:01 UTC

[camel-k] 01/03: feat(maven): Configurable Maven CLI options

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 9130ae2d2cbac7f8b38d1d5235596aba548d9508
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 14 17:12:59 2022 +0100

    feat(maven): Configurable Maven CLI options
---
 config/crd/bases/camel.apache.org_builds.yaml              |  7 +++++++
 .../crd/bases/camel.apache.org_integrationplatforms.yaml   | 14 ++++++++++++++
 helm/camel-k/crds/crd-build.yaml                           |  7 +++++++
 helm/camel-k/crds/crd-integration-platform.yaml            | 14 ++++++++++++++
 pkg/apis/camel/v1/maven_types.go                           |  4 ++++
 pkg/builder/quarkus.go                                     |  2 ++
 pkg/platform/defaults.go                                   |  7 +++++++
 pkg/resources/resources.go                                 |  8 ++++----
 pkg/trait/openapi.go                                       |  1 +
 pkg/util/camel/catalog.go                                  |  1 +
 pkg/util/maven/maven_command.go                            |  4 +---
 11 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/config/crd/bases/camel.apache.org_builds.yaml b/config/crd/bases/camel.apache.org_builds.yaml
index d678755..19d90c8 100644
--- a/config/crd/bases/camel.apache.org_builds.yaml
+++ b/config/crd/bases/camel.apache.org_builds.yaml
@@ -161,6 +161,13 @@ spec:
                               required:
                               - key
                               type: object
+                            cliOptions:
+                              description: The CLI options that are appended to the
+                                list of arguments for Maven commands, e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+                                See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+                              items:
+                                type: string
+                              type: array
                             extension:
                               description: The Maven build extensions. See https://maven.apache.org/guides/mini/guide-using-extensions.html.
                               items:
diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
index 699fcd8..217399c 100644
--- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml
+++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
@@ -105,6 +105,13 @@ spec:
                         required:
                         - key
                         type: object
+                      cliOptions:
+                        description: The CLI options that are appended to the list
+                          of arguments for Maven commands, e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+                          See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+                        items:
+                          type: string
+                        type: array
                       extension:
                         description: The Maven build extensions. See https://maven.apache.org/guides/mini/guide-using-extensions.html.
                         items:
@@ -305,6 +312,13 @@ spec:
                         required:
                         - key
                         type: object
+                      cliOptions:
+                        description: The CLI options that are appended to the list
+                          of arguments for Maven commands, e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+                          See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+                        items:
+                          type: string
+                        type: array
                       extension:
                         description: The Maven build extensions. See https://maven.apache.org/guides/mini/guide-using-extensions.html.
                         items:
diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml
index d678755..19d90c8 100644
--- a/helm/camel-k/crds/crd-build.yaml
+++ b/helm/camel-k/crds/crd-build.yaml
@@ -161,6 +161,13 @@ spec:
                               required:
                               - key
                               type: object
+                            cliOptions:
+                              description: The CLI options that are appended to the
+                                list of arguments for Maven commands, e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+                                See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+                              items:
+                                type: string
+                              type: array
                             extension:
                               description: The Maven build extensions. See https://maven.apache.org/guides/mini/guide-using-extensions.html.
                               items:
diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml
index 699fcd8..217399c 100644
--- a/helm/camel-k/crds/crd-integration-platform.yaml
+++ b/helm/camel-k/crds/crd-integration-platform.yaml
@@ -105,6 +105,13 @@ spec:
                         required:
                         - key
                         type: object
+                      cliOptions:
+                        description: The CLI options that are appended to the list
+                          of arguments for Maven commands, e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+                          See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+                        items:
+                          type: string
+                        type: array
                       extension:
                         description: The Maven build extensions. See https://maven.apache.org/guides/mini/guide-using-extensions.html.
                         items:
@@ -305,6 +312,13 @@ spec:
                         required:
                         - key
                         type: object
+                      cliOptions:
+                        description: The CLI options that are appended to the list
+                          of arguments for Maven commands, e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+                          See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+                        items:
+                          type: string
+                        type: array
                       extension:
                         description: The Maven build extensions. See https://maven.apache.org/guides/mini/guide-using-extensions.html.
                         items:
diff --git a/pkg/apis/camel/v1/maven_types.go b/pkg/apis/camel/v1/maven_types.go
index 569336c..bb890b0 100644
--- a/pkg/apis/camel/v1/maven_types.go
+++ b/pkg/apis/camel/v1/maven_types.go
@@ -43,6 +43,10 @@ type MavenSpec struct {
 	// The Maven build extensions.
 	// See https://maven.apache.org/guides/mini/guide-using-extensions.html.
 	Extension []MavenArtifact `json:"extension,omitempty"`
+	// The CLI options that are appended to the list of arguments for Maven commands,
+	// e.g., `-V,--no-transfer-progress,-Dstyle.color=never`.
+	// See https://maven.apache.org/ref/3.8.4/maven-embedder/cli.html.
+	CLIOptions []string `json:"cliOptions,omitempty"`
 }
 
 // Repository defines a Maven repository
diff --git a/pkg/builder/quarkus.go b/pkg/builder/quarkus.go
index 7189c1a..6f2d2d2 100644
--- a/pkg/builder/quarkus.go
+++ b/pkg/builder/quarkus.go
@@ -154,6 +154,7 @@ func buildQuarkusRunner(ctx *builderContext) error {
 	mc.GlobalSettings = ctx.Maven.GlobalSettings
 	mc.UserSettings = ctx.Maven.UserSettings
 	mc.LocalRepository = ctx.Build.Maven.LocalRepository
+	mc.AdditionalArguments = ctx.Build.Maven.CLIOptions
 
 	if ctx.Maven.TrustStoreName != "" {
 		mc.ExtraMavenOpts = append(mc.ExtraMavenOpts,
@@ -200,6 +201,7 @@ func computeQuarkusDependencies(ctx *builderContext) error {
 	mc.GlobalSettings = ctx.Maven.GlobalSettings
 	mc.UserSettings = ctx.Maven.UserSettings
 	mc.LocalRepository = ctx.Build.Maven.LocalRepository
+	mc.AdditionalArguments = ctx.Build.Maven.CLIOptions
 
 	// Process artifacts list and add it to existing artifacts
 	artifacts, err := ProcessQuarkusTransitiveDependencies(mc)
diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go
index 29c5dd0..0f0eb25 100644
--- a/pkg/platform/defaults.go
+++ b/pkg/platform/defaults.go
@@ -162,6 +162,13 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error {
 	if p.Status.Build.Maven.LocalRepository == "" {
 		p.Status.Build.Maven.LocalRepository = defaults.LocalRepository
 	}
+	if len(p.Status.Build.Maven.CLIOptions) == 0 {
+		p.Status.Build.Maven.CLIOptions = []string{
+			"-V",
+			"--no-transfer-progress",
+			"-Dstyle.color=never",
+		}
+	}
 	if p.Status.Build.PersistentVolumeClaim == "" {
 		p.Status.Build.PersistentVolumeClaim = p.Name
 	}
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 12c54ae..1b28822 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -117,9 +117,9 @@ var assets = func() http.FileSystem {
 		"/crd/bases/camel.apache.org_builds.yaml": &vfsgen۰CompressedFileInfo{
 			name:             "camel.apache.org_builds.yaml",
 			modTime:          time.Time{},
-			uncompressedSize: 26973,
+			uncompressedSize: 27442,
 
-			compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x3d\x5d\x73\xe3\x38\x72\xef\xfa\x15\x5d\xe3\x87\x99\xa9\xb2\xa8\xdd\xbd\xbb\x64\xa3\x3c\xa4\x74\xf2\x4c\x45\x99\x19\xdb\x65\x79\xf7\x72\x8f\x10\xd9\xa2\x70\x22\x01\x06\x00\x2d\xeb\x52\xf9\xef\x29\x7c\x90\x22\x25\x7e\x80\xb2\x7c\x3b\x57\x6b\xbc\xcc\x88\x04\x1a\xfd\x85\xee\x46\x03\x6c\x5f\xc1\xf8\x72\x6d\x74\x05\x5f\x69\x88\x4c\x62\x04\x8a\x83\xda\x20\xcc\x32\x12\x6e\x10\x96\x7c\xad\x76\x44\x20\x7c\xe6\x39\x8b\x88\x [...]
+			compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x3d\x5d\x73\xe3\x38\x72\xef\xfa\x15\x5d\xe3\x87\xd9\xa9\x32\xa9\xfd\xba\x64\xe3\x54\x2a\xa5\x93\x67\x2a\xca\xcc\xd8\x2e\xcb\xbb\x97\x7b\x3b\x88\x6c\x51\x38\x91\x00\x03\x80\x96\x75\xa9\xfc\xf7\x14\x3e\x48\x91\x16\x3f\x40\x59\xce\xce\xd5\x19\x2f\x33\x26\x81\x46\x7f\x77\xa3\x01\x42\x17\x10\x9c\xaf\x4d\x2e\xe0\x0b\x8d\x90\x49\x8c\x41\x71\x50\x1b\x84\x59\x4e\xa2\x0d\xc2\x92\xaf\xd5\x8e\x08\x84\x4f\xbc\x60\x31\x51\x94\x [...]
 		},
 		"/crd/bases/camel.apache.org_camelcatalogs.yaml": &vfsgen۰CompressedFileInfo{
 			name:             "camel.apache.org_camelcatalogs.yaml",
@@ -138,9 +138,9 @@ var assets = func() http.FileSystem {
 		"/crd/bases/camel.apache.org_integrationplatforms.yaml": &vfsgen۰CompressedFileInfo{
 			name:             "camel.apache.org_integrationplatforms.yaml",
 			modTime:          time.Time{},
-			uncompressedSize: 22714,
+			uncompressedSize: 23568,
 
-			compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x3c\x4b\x8f\xe3\xb8\xd1\x77\xff\x8a\xc2\xf8\x30\xbb\x40\x5b\xde\xfd\xbe\x04\x49\x9c\x43\xe0\xf5\xcc\x20\x4e\xcf\x74\x37\xda\x9e\xdd\xec\x91\x96\xca\x36\xd7\x12\xa9\x90\x54\x7b\xbc\x41\xfe\x7b\x50\x45\xc9\x96\xdb\x7a\xf5\x63\x91\x64\x20\x5e\xba\x2d\x91\xc5\x7a\x57\xb1\x58\xd0\x10\x46\xaf\x37\x06\x43\xf8\x28\x43\x54\x16\x23\x70\x1a\xdc\x16\x61\x9a\x8a\x70\x8b\xb0\xd0\x6b\xb7\x17\x06\xe1\x83\xce\x54\x24\x9c\xd4\x0a\x [...]
+			compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x1c\x5d\x8f\xe3\xb6\xf1\xdd\xbf\x62\x70\x7e\xb8\x04\xb0\xe4\xa4\x49\xd1\xd4\x45\x51\x6c\x7c\x77\xa8\x7b\x77\xbb\x8b\xb5\xef\xd2\xbc\x85\x96\xc6\x32\x63\x8a\x54\x49\x6a\x7d\x4e\xd1\xff\x5e\x0c\x29\xd9\xf2\x5a\x5f\xbb\x7b\x41\x9b\x40\x7c\xd9\xb5\x44\x0e\xe7\xfb\x83\x1c\x68\x0c\xc1\xe7\x1b\xa3\x31\xbc\xe3\x11\x4a\x83\x31\x58\x05\x76\x8b\x70\x95\xb1\x68\x8b\xb0\x54\x1b\xbb\x67\x1a\xe1\x8d\xca\x65\xcc\x2c\x57\x12\xbe\x [...]
 		},
 		"/crd/bases/camel.apache.org_integrations.yaml": &vfsgen۰CompressedFileInfo{
 			name:             "camel.apache.org_integrations.yaml",
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index 22d2eb5..c831065 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -253,6 +253,7 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Dat
 
 	mc := maven.NewContext(tmpDir)
 	mc.LocalRepository = e.Platform.Status.Build.Maven.LocalRepository
+	mc.AdditionalArguments = e.Platform.Status.Build.Maven.CLIOptions
 	mc.AddArgument("-Dopenapi.spec=" + in)
 	mc.AddArgument("-Ddsl.out=" + out)
 
diff --git a/pkg/util/camel/catalog.go b/pkg/util/camel/catalog.go
index 5fff813..20cdea5 100644
--- a/pkg/util/camel/catalog.go
+++ b/pkg/util/camel/catalog.go
@@ -120,6 +120,7 @@ func GenerateCatalogCommon(
 
 		mc := maven.NewContext(tmpDir)
 		mc.LocalRepository = mvn.LocalRepository
+		mc.AdditionalArguments = mvn.CLIOptions
 		mc.AddSystemProperty("catalog.path", tmpDir)
 		mc.AddSystemProperty("catalog.file", "catalog.yaml")
 		mc.AddSystemProperty("catalog.runtime", string(runtime.Provider))
diff --git a/pkg/util/maven/maven_command.go b/pkg/util/maven/maven_command.go
index 908d819..c6ca436 100644
--- a/pkg/util/maven/maven_command.go
+++ b/pkg/util/maven/maven_command.go
@@ -52,7 +52,7 @@ func (c *Command) Do(ctx context.Context) error {
 	}
 
 	args := make([]string, 0)
-	args = append(args, "--no-transfer-progress", "-Dstyle.color=never")
+	args = append(args, c.context.AdditionalArguments...)
 
 	if c.context.LocalRepository != "" {
 		if _, err := os.Stat(c.context.LocalRepository); err == nil {
@@ -74,8 +74,6 @@ func (c *Command) Do(ctx context.Context) error {
 		args = append(args, "--settings", settingsPath)
 	}
 
-	args = append(args, c.context.AdditionalArguments...)
-
 	cmd := exec.CommandContext(ctx, mvnCmd, args...)
 	cmd.Dir = c.context.Path