diff --git a/deploy/platform-cr.yaml b/deploy/platform-cr.yaml index e92676b165..8f9b3e6ef6 100644 --- a/deploy/platform-cr.yaml +++ b/deploy/platform-cr.yaml @@ -8,3 +8,4 @@ spec: build: camelVersion: "2.23.1" baseImage: "fabric8/s2i-java:3.0-java8" + localRepository: "/tmp/artifacts/m2" diff --git a/deploy/resources.go b/deploy/resources.go index 68cfc91428..2a0028eaa6 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -3342,6 +3342,7 @@ spec: build: camelVersion: "2.23.1" baseImage: "fabric8/s2i-java:3.0-java8" + localRepository: "/tmp/artifacts/m2" ` Resources["platform-integration-context-groovy.yaml"] = diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types.go b/pkg/apis/camel/v1alpha1/integrationplatform_types.go index c70281d087..e2c94f0fa3 100644 --- a/pkg/apis/camel/v1alpha1/integrationplatform_types.go +++ b/pkg/apis/camel/v1alpha1/integrationplatform_types.go @@ -78,6 +78,7 @@ type IntegrationPlatformBuildSpec struct { CamelVersion string `json:"camelVersion,omitempty"` BaseImage string `json:"baseImage,omitempty"` Properties map[string]string `json:"properties,omitempty"` + LocalRepository string `json:"localRepository,omitempty"` Repositories []string `json:"repositories,omitempty"` } diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go index 876647fba1..555befc46f 100644 --- a/pkg/builder/builder_steps.go +++ b/pkg/builder/builder_steps.go @@ -111,9 +111,11 @@ func ComputeDependencies(ctx *Context) error { return err } - goal := fmt.Sprintf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", version.Version) + opts := make([]string, 0, 2) + opts = append(opts, maven.ExtraOptions(ctx.Request.Platform.Build)...) + opts = append(opts, fmt.Sprintf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", version.Version)) - err = maven.Run(p, goal) + err = maven.Run(p, opts...) if err != nil { return errors.Wrap(err, "failure while determining classpath") } diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 48792f9bb4..2b54d8c34c 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -52,6 +52,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command { cmd.Flags().StringVar(&impl.organization, "organization", "", "A organization on the Docker registry that can be used to publish images") cmd.Flags().StringVar(&impl.pushSecret, "push-secret", "", "A secret used to push images to the Docker registry") cmd.Flags().StringSliceVar(&impl.repositories, "repository", nil, "Add a maven repository") + cmd.Flags().StringVar(&impl.localRepository, "local-repository", "", "Location of the local maven repository") cmd.Flags().StringSliceVarP(&impl.properties, "property", "p", nil, "Add a camel property") cmd.Flags().StringVar(&impl.camelVersion, "camel-version", "", "Set the camel version") cmd.Flags().StringVar(&impl.baseImage, "base-image", "", "Set the base image used to run integrations") @@ -81,6 +82,7 @@ type installCmdOptions struct { pushSecret string camelVersion string baseImage string + localRepository string repositories []string properties []string contexts []string @@ -140,6 +142,9 @@ func (o *installCmdOptions) install(cmd *cobra.Command, args []string) error { } } } + if o.localRepository != "" { + platform.Spec.Build.LocalRepository = o.localRepository + } if len(o.repositories) > 0 { platform.Spec.Build.Repositories = o.repositories } diff --git a/pkg/trait/rest.go b/pkg/trait/rest.go index 8001373b2c..a8596f7486 100644 --- a/pkg/trait/rest.go +++ b/pkg/trait/rest.go @@ -99,11 +99,13 @@ func (t *restTrait) Apply(e *Environment) error { return err } - goal := fmt.Sprintf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-rest-xml", version.Version) - iArg := "-Dopenapi.spec=" + in - oArg := "-Ddsl.out=" + out + opts := make([]string, 0, 4) + opts = append(opts, maven.ExtraOptions(e.Platform.Spec.Build)...) + opts = append(opts, fmt.Sprintf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-rest-xml", version.Version)) + opts = append(opts, "-Dopenapi.spec="+in) + opts = append(opts, "-Ddsl.out="+out) - if err := maven.Run(tmpDir, goal, iArg, oArg); err != nil { + if err := maven.Run(tmpDir, opts...); err != nil { return err } diff --git a/pkg/util/maven/maven.go b/pkg/util/maven/maven.go index c2a90d13bf..782cb83d56 100644 --- a/pkg/util/maven/maven.go +++ b/pkg/util/maven/maven.go @@ -80,11 +80,7 @@ func Run(buildDir string, args ...string) error { "logger": "maven", }) - cmdArgs := make([]string, 0, 1+len(args)) - cmdArgs = append(cmdArgs, extraOptions()) - cmdArgs = append(cmdArgs, args...) - - cmd := exec.Command(mvnCmd, cmdArgs...) + cmd := exec.Command(mvnCmd, args...) cmd.Dir = buildDir cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -126,9 +122,10 @@ func ParseGAV(gav string) (Dependency, error) { return dep, nil } -func extraOptions() string { - if _, err := os.Stat("/tmp/artifacts/m2"); err == nil { - return "-Dmaven.repo.local=/tmp/artifacts/m2" +// ExtraOptions -- +func ExtraOptions(spec v1alpha1.IntegrationPlatformBuildSpec) []string { + if _, err := os.Stat(spec.LocalRepository); err == nil { + return []string{"-Dmaven.repo.local=" + spec.LocalRepository} } - return "-Dcamel.noop=true" + return []string{"-Dcamel.noop=true"} }