From 89547c32aaaae20d6d6a0306b301d912969a81f5 Mon Sep 17 00:00:00 2001 From: Marek Aufart Date: Thu, 11 Jan 2024 12:13:39 +0100 Subject: [PATCH 1/2] Add settings file option to openrewrite Maven settings.xml file can be now specified as parameter for kantra transform openrewrite (that uses maven for its execution). Fixes: https://github.com/konveyor/kantra/issues/19 Signed-off-by: Marek Aufart --- cmd/openrewrite.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/openrewrite.go b/cmd/openrewrite.go index c8d0d06..6152115 100644 --- a/cmd/openrewrite.go +++ b/cmd/openrewrite.go @@ -12,13 +12,14 @@ import ( ) type openRewriteCommand struct { - listTargets bool - input string - target string - goal string - miscOpts string - log logr.Logger - cleanup bool + listTargets bool + input string + target string + goal string + miscOpts string + log logr.Logger + cleanup bool + mavenSettingsFile string } func NewOpenRewriteCommand(log logr.Logger) *cobra.Command { @@ -58,6 +59,7 @@ func NewOpenRewriteCommand(log logr.Logger) *cobra.Command { openRewriteCommand.Flags().StringVarP(&openRewriteCmd.target, "target", "t", "", "target openrewrite recipe to use. Run --list-targets to get a list of packaged recipes.") openRewriteCommand.Flags().StringVarP(&openRewriteCmd.goal, "goal", "g", "dryRun", "target goal") openRewriteCommand.Flags().StringVarP(&openRewriteCmd.input, "input", "i", "", "path to application source code directory") + openRewriteCommand.Flags().StringVarP(&openRewriteCmd.mavenSettingsFile, "maven-settings", "s", "", "path to a custom maven settings file to use") return openRewriteCommand } @@ -143,6 +145,12 @@ func (o *openRewriteCommand) Run(ctx context.Context) error { } o.log.Info("executing openrewrite recipe", "recipe", o.target, "input", o.input, "args", strings.Join(args, " ")) + + if o.mavenSettingsFile != "" { + o.log.Info("using custom maven settings file", "path", o.mavenSettingsFile) + args = append(args, "-s", o.mavenSettingsFile) + } + err := NewContainer(o.log).Run( ctx, WithEntrypointArgs(args...), From fd827774e1633c865f8a1b7d4d0fa2edefa6284a Mon Sep 17 00:00:00 2001 From: Marek Aufart Date: Fri, 12 Jan 2024 10:20:04 +0100 Subject: [PATCH 2/2] Update readme Signed-off-by: Marek Aufart --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1b3be7f..1649e13 100644 --- a/README.md +++ b/README.md @@ -166,11 +166,12 @@ Usage: kantra transform openrewrite [flags] Flags: - -g, --goal string target goal (default "dryRun") - -h, --help help for openrewrite - -i, --input string path to application source code directory - -l, --list-targets list all available OpenRewrite recipes - -t, --target string target openrewrite recipe to use. Run --list-targets to get a list of packaged recipes. + -g, --goal string target goal (default "dryRun") + -h, --help help for openrewrite + -i, --input string path to application source code directory + -l, --list-targets list all available OpenRewrite recipes + -s, --maven-settings string path to a custom maven settings file to use + -t, --target string target openrewrite recipe to use. Run --list-targets to get a list of packaged recipes. Global Flags: --log-level int log level (default 5)