From 1d812fa6b7f08e822f8585c051f2bb11a273e579 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Wed, 18 Oct 2023 17:19:24 +0200 Subject: [PATCH] Re-work CLI to use Picocli + a bunch of UX fixes --- README.md | 12 +- .../glow/plugin/arquillian/ScanMojo.java | 2 +- cli/pom.xml | 4 + .../org/wildfly/glow/cli/CLIArguments.java | 50 +++-- .../glow/cli/ExecutionExceptionHandler.java | 44 ++++ .../java/org/wildfly/glow/cli/GlowCLI.java | 30 ++- .../glow/cli/commands/AbstractCommand.java | 38 ++++ .../glow/cli/commands/CompletionCommand.java | 46 ++++ .../wildfly/glow/cli/commands/Constants.java | 72 +++++++ .../glow/cli/commands/GoOfflineCommand.java | 75 +++++++ .../glow/cli/commands/MainCommand.java | 63 ++++++ .../glow/cli/commands/ScanCommand.java | 203 ++++++++++++++++++ .../glow/cli/commands/ShowAddOnsCommand.java | 89 ++++++++ .../commands/ShowConfigurationCommand.java | 89 ++++++++ .../commands/ShowServerVersionsCommand.java | 34 +++ .../main/resources/UsageMessages.properties | 48 +++++ .../main/java/org/wildfly/glow/Arguments.java | 2 +- .../java/org/wildfly/glow/DockerSupport.java | 18 +- .../java/org/wildfly/glow/FeaturePacks.java | 28 +-- .../java/org/wildfly/glow/GlowSession.java | 139 ++++++------ .../glow/HiddenPropertiesAccessor.java | 4 +- .../java/org/wildfly/glow/OutputFormat.java | 3 +- .../java/org/wildfly/glow/ScanResults.java | 4 +- .../org/wildfly/glow/ScanResultsPrinter.java | 22 +- pom.xml | 6 + tests/run-cli-tests.sh | 20 +- tests/run-internal.sh | 27 ++- wildfly-glow | 17 ++ 28 files changed, 1037 insertions(+), 152 deletions(-) create mode 100644 cli/src/main/java/org/wildfly/glow/cli/ExecutionExceptionHandler.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/AbstractCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/CompletionCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/GoOfflineCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/MainCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/ShowAddOnsCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/ShowConfigurationCommand.java create mode 100644 cli/src/main/java/org/wildfly/glow/cli/commands/ShowServerVersionsCommand.java create mode 100644 cli/src/main/resources/UsageMessages.properties create mode 100755 wildfly-glow diff --git a/README.md b/README.md index faf067f7..c9deb239 100644 --- a/README.md +++ b/README.md @@ -48,28 +48,28 @@ to adjust the provisioned WildFly server (execution context, profile, add-ons, W * To display the required Galleon layers and feature-packs required to run kitchensink: -`java -jar cli/target/wildfly-glow.jar examples/war/kitchensink.war` +`./wildfly-glow scan examples/war/kitchensink.war` * To display the required Galleon layers and feature-packs required to run kitchensink on the cloud: -`java -jar cli/target/wildfly-glow.jar examples/war/kitchensink.war --context=cloud` +`./wildfly-glow scan examples/war/kitchensink.war --cloud` * To provision a WildFly server to run kitchensink: -`java -jar cli/target/wildfly-glow.jar examples/war/kitchensink.war --output=server` +`./wildfly-glow scan examples/war/kitchensink.war --provision=server` * To provision a WildFly Bootable JAR to run kitchensink: -`java -jar cli/target/wildfly-glow.jar examples/war/kitchensink.war --output=bootable-jar` +`./wildfly-glow scan examples/war/kitchensink.war --provision=bootable-jar` * To provision a WildFly server for the cloud and produce a Docker image to run kitchensink: -`java -jar cli/target/wildfly-glow.jar examples/war/kitchensink.war --output=server --context=cloud` +`./wildfly-glow scan examples/war/kitchensink.war --provision=server --cloud` # Accessing the WildFly Glow command line help -`java -jar cli/target/wildfly-glow.jar --help` +`./wildfly-glow --help` # WildFly Glow documentation diff --git a/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java b/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java index 14f47bff..00cdd672 100644 --- a/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java +++ b/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java @@ -321,7 +321,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { ProvisioningXmlWriter.getInstance().write(builder.build(), fileWriter); } } else { - results.outputConfig(outputFolder, false); + results.outputConfig(outputFolder, null); } } catch (Exception ex) { if (ex instanceof MojoExecutionException) { diff --git a/cli/pom.xml b/cli/pom.xml index ca32531a..8f725105 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -25,6 +25,10 @@ ${project.groupId} wildfly-glow-core + + info.picocli + picocli + org.jboss.slf4j diff --git a/cli/src/main/java/org/wildfly/glow/cli/CLIArguments.java b/cli/src/main/java/org/wildfly/glow/cli/CLIArguments.java index 35c3f54a..efa0ef72 100644 --- a/cli/src/main/java/org/wildfly/glow/cli/CLIArguments.java +++ b/cli/src/main/java/org/wildfly/glow/cli/CLIArguments.java @@ -22,13 +22,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import org.jboss.galleon.config.FeaturePackConfig; import org.jboss.galleon.config.ProvisioningConfig; -import org.wildfly.glow.AddOn; +import org.jboss.galleon.universe.FeaturePackLocation; import org.wildfly.glow.Arguments; import org.wildfly.glow.FeaturePacks; import static org.wildfly.glow.GlowSession.STANDALONE_PROFILE; @@ -62,7 +63,7 @@ public class CLIArguments extends Arguments { private final boolean help; private final boolean version; private final boolean displayConfigurationInfo; - private CLIArguments( + public CLIArguments( boolean version, boolean help, String executionContext, @@ -303,30 +304,41 @@ public static void dumpInfos(Set profiles) throws Exception { System.out.println(builder); } - public static void dumpConfiguration(String context, String serverVersion, Map allLayers, + public static String dumpConfiguration(Map> fpDependencies, String context, String serverVersion, Map allLayers, LayerMapping mapping, ProvisioningConfig fps, boolean isLatest, boolean techPreview) throws Exception { StringBuilder builder = new StringBuilder(); - builder.append("\n Execution context: ").append(context).append("\n"); - builder.append("\n Server version: ").append(serverVersion).append(isLatest ? " (latest)" : "").append("\n"); - builder.append("\n Tech Preview: ").append(techPreview).append("\n"); - builder.append("\n Known Galleon feature-packs:\n"); + builder.append("Execution context: ").append(context).append("\n"); + builder.append("Server version: ").append(serverVersion).append(isLatest ? " (latest)" : "").append("\n"); + builder.append("Tech Preview: ").append(techPreview).append("\n"); + Set topLevel = new LinkedHashSet<>(); for(FeaturePackConfig fp : fps.getFeaturePackDeps()) { - builder.append(" * ").append(fp.getLocation().getFPID()).append("\n"); + topLevel.add(fp.getLocation().getProducer()); } - builder.append("\n Possible add-ons:\n"); - for (Map.Entry> entry : mapping.getAddOnFamilyMembers().entrySet()) { - builder.append(" * ").append(entry.getKey()).append(" add-ons:\n"); - for (AddOn member : mapping.getAddOnFamilyMembers().get(entry.getKey())) { - if (!member.getName().endsWith(":default")) { - builder.append(" - ").append(member.getName()).append(member.getDescription() == null ? "" : ": " + member.getDescription()).append("\n"); + for(FeaturePackConfig fp : fps.getFeaturePackDeps()) { + builder.append("\nFeature-pack: ").append("@|bold ").append(fp.getLocation().getFPID()).append("|@\n"); + builder.append("Contained layers: "); + Set layers = new TreeSet<>(); + Set deps = fpDependencies.get(fp.getLocation().getFPID()); + for(Layer l : allLayers.values()) { + if(l.getFeaturePacks().contains(fp.getLocation().getFPID())) { + layers.add(l.getName()); + } + if(deps != null) { + for (FeaturePackLocation.ProducerSpec dep : deps) { + if (!topLevel.contains(dep)) { + for (FeaturePackLocation.FPID fpid : l.getFeaturePacks()) { + if (fpid.getProducer().equals(dep)) { + layers.add(l.getName()); + } + } + } + } } } + topLevel.addAll(deps); + builder.append(layers).append("\n"); } - builder.append("\n Known Galleon layers:\n"); - Set sortedSet = new TreeSet<>(); - sortedSet.addAll(allLayers.keySet()); - builder.append(sortedSet).append("\n"); - System.out.println(builder.toString()); + return builder.toString(); } public boolean isGoOffline() { diff --git a/cli/src/main/java/org/wildfly/glow/cli/ExecutionExceptionHandler.java b/cli/src/main/java/org/wildfly/glow/cli/ExecutionExceptionHandler.java new file mode 100644 index 00000000..a25344dc --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/ExecutionExceptionHandler.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wildfly.glow.cli; + +import picocli.CommandLine; + + +/** + * Handles exceptions that happen during command executions. + */ +public class ExecutionExceptionHandler implements CommandLine.IExecutionExceptionHandler { + + private final boolean isVerbose; + + public ExecutionExceptionHandler(boolean isVerbose) { + this.isVerbose = isVerbose; + } + + @Override + public int handleExecutionException(Exception ex, CommandLine commandLine, CommandLine.ParseResult parseResult) + throws Exception { + System.err.println(CommandLine.Help.Ansi.AUTO.string("@|fg(red) ERROR: " + ex.getLocalizedMessage() + "|@")); + if(isVerbose) { + ex.printStackTrace(); + } + return 1; + } + +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/GlowCLI.java b/cli/src/main/java/org/wildfly/glow/cli/GlowCLI.java index 1bdf1e8d..d6b280d5 100644 --- a/cli/src/main/java/org/wildfly/glow/cli/GlowCLI.java +++ b/cli/src/main/java/org/wildfly/glow/cli/GlowCLI.java @@ -19,6 +19,7 @@ import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import org.jboss.galleon.layout.FeaturePackLayout; import org.jboss.galleon.layout.ProvisioningLayout; import org.jboss.galleon.universe.UniverseResolver; @@ -42,6 +43,14 @@ import org.wildfly.glow.Version; import static org.wildfly.glow.GlowSession.OFFLINE_CONTENT; +import org.wildfly.glow.cli.commands.CompletionCommand; +import org.wildfly.glow.cli.commands.GoOfflineCommand; +import org.wildfly.glow.cli.commands.ShowConfigurationCommand; +import org.wildfly.glow.cli.commands.MainCommand; +import org.wildfly.glow.cli.commands.ScanCommand; +import org.wildfly.glow.cli.commands.ShowAddOnsCommand; +import org.wildfly.glow.cli.commands.ShowServerVersionsCommand; +import picocli.CommandLine; /** * @@ -50,6 +59,23 @@ public class GlowCLI { public static void main(String[] args) throws Exception { + try { + CommandLine commandLine = new CommandLine(new MainCommand()); + commandLine.addSubcommand(new ScanCommand()); + commandLine.addSubcommand(new ShowAddOnsCommand()); + commandLine.addSubcommand(new ShowServerVersionsCommand()); + commandLine.addSubcommand(new ShowConfigurationCommand()); + commandLine.addSubcommand(new GoOfflineCommand()); + commandLine.addSubcommand(new CompletionCommand()); + commandLine.setUsageHelpAutoWidth(true); + final boolean isVerbose = Arrays.stream(args).anyMatch(s -> s.equals("-vv") || s.equals("--verbose")); + commandLine.setExecutionExceptionHandler(new ExecutionExceptionHandler(isVerbose)); + int exitCode = commandLine.execute(args); + System.exit(exitCode); + } catch (Exception ex) { + System.err.println(ex.getMessage()); + System.exit(1); + } CLIArguments arguments = CLIArguments.fromMainArguments(args); if (arguments.isVersion()) { System.out.println(Version.getVersion()); @@ -76,7 +102,7 @@ public static void main(String[] args) throws Exception { String serverVersion = isLatest ? FeaturePacks.getLatestVersion() : arguments.getVersion(); Path fps = FeaturePacks.getFeaturePacks(serverVersion, arguments.getExecutionContext(), arguments.isTechPreview()); ProvisioningConfig config = ProvisioningXmlParser.parse(fps); - CLIArguments.dumpConfiguration(arguments.getExecutionContext(), serverVersion, all, mapping, config, isLatest, arguments.isTechPreview()); + CLIArguments.dumpConfiguration(null, arguments.getExecutionContext(), serverVersion, all, mapping, config, isLatest, arguments.isTechPreview()); } } finally { IoUtils.recursiveDelete(OFFLINE_CONTENT); @@ -92,7 +118,7 @@ public static void main(String[] args) throws Exception { if (arguments.getOutput() == null) { scanResults.outputInformation(); } else { - scanResults.outputConfig(Paths.get("server"), true); + scanResults.outputConfig(Paths.get("server"), null); } } } diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/AbstractCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/AbstractCommand.java new file mode 100644 index 00000000..fe3a03e3 --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/AbstractCommand.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import java.util.Optional; +import java.util.concurrent.Callable; + +import picocli.CommandLine; + +public abstract class AbstractCommand implements Callable { + + @SuppressWarnings("unused") + @CommandLine.Option( + names = {Constants.HELP_OPTION_SHORT, Constants.HELP_OPTION}, + usageHelp = true + ) + boolean help; + + @SuppressWarnings("unused") + @CommandLine.Option( + names = {Constants.VERBOSE_OPTION_SHORT, Constants.VERBOSE_OPTION} + ) + Optional verbose; +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/CompletionCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/CompletionCommand.java new file mode 100644 index 00000000..410b4a5f --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/CompletionCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import picocli.AutoComplete; +import picocli.CommandLine; + +/** + * By invoking this command, user can obtain a shell completion script. + * + * User can apply the completion script by running `source <(wildfly-glow completion)` (in bash), or can redirect the + * output of this command to a file. + * + * The completion script can be used for bash and zsh. + */ +@CommandLine.Command( + name = Constants.COMPLETION_COMMAND, + mixinStandardHelpOptions = true, + helpCommand = true) +public class CompletionCommand implements Runnable { + + @CommandLine.Spec + CommandLine.Model.CommandSpec spec; + + @Override + public void run() { + String script = AutoComplete.bash(Constants.WILDFLY_GLOW, spec.root().commandLine()); + spec.commandLine().getOut().print(script); + spec.commandLine().getOut().print('\n'); + spec.commandLine().getOut().flush(); + } +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java b/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java new file mode 100644 index 00000000..ddeff5f2 --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java @@ -0,0 +1,72 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +/** + * + * @author jdenise + */ +public interface Constants { + + String HA = "ha"; + + String COMPLETION_COMMAND = "completion"; + String GO_OFFLINE_COMMAND = "go-offline"; + String SCAN_COMMAND = "scan"; + String SHOW_ADD_ONS_COMMAND = "show-add-ons"; + String SHOW_CONFIGURATION_COMMAND = "show-configuration"; + String SHOW_SERVER_VERSIONS_COMMAND = "show-server-versions"; + String ADD_LAYERS_FOR_JNDI_OPTION = "--add-layers-for-jndi"; + String ADD_LAYERS_FOR_JNDI_OPTION_LABEL = ""; + String ADD_ONS_OPTION = "--add-ons"; + String ADD_ONS_OPTION_LABEL = ""; + String ADD_ONS_OPTION_SHORT = "-ao"; + + String CLOUD_OPTION = "--cloud"; + String CLOUD_OPTION_SHORT = "-c"; + String DOCKER_IMAGE_NAME_OPTION = "--docker-image-name"; + String DOCKER_IMAGE_NAME_OPTION_LABEL = ""; + String DOCKER_IMAGE_NAME_OPTION_SHORT = "-di"; + String HA_OPTION = "--ha"; + + String HELP_OPTION = "--help"; + String HELP_OPTION_SHORT = "-h"; + String INPUT_FEATURE_PACKS_FILE_OPTION = "--input-feature-packs-file"; + String INPUT_FEATURE_PACKS_FILE_OPTION_LABEL = ""; + String NO_DOCKER_IMAGE_OPTION = "--no-docker-image"; + String NO_DOCKER_IMAGE_OPTION_SHORT = "-nd"; + String PROVISION_OPTION = "--provision"; + String PROVISION_OPTION_LABEL = ""; + String PROVISION_OPTION_SHORT = "-p"; + String SERVER_VERSION_OPTION = "--server-version"; + String SERVER_VERSION_OPTION_SHORT = "-sv"; + String SERVER_VERSION_OPTION_LABEL = ""; + String SUGGEST_OPTION = "--suggest"; + String SUGGEST_OPTION_SHORT = "-s"; + + String VERBOSE_OPTION = "--verbose"; + String VERBOSE_OPTION_SHORT = "-vv"; + + String VERSION_OPTION = "--version"; + String VERSION_OPTION_SHORT = "-v"; + + String WILDFLY_PREVIEW_OPTION = "--wildfly-preview"; + String WILDFLY_PREVIEW_OPTION_SHORT = "-wp"; + + String WILDFLY_GLOW = "wildfly-glow"; + +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/GoOfflineCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/GoOfflineCommand.java new file mode 100644 index 00000000..c2694313 --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/GoOfflineCommand.java @@ -0,0 +1,75 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import java.nio.file.Path; +import java.util.Optional; +import org.wildfly.glow.Arguments; +import static org.wildfly.glow.Arguments.CLOUD_EXECUTION_CONTEXT; +import org.wildfly.glow.GlowMessageWriter; +import org.wildfly.glow.GlowSession; +import static org.wildfly.glow.GlowSession.OFFLINE_ZIP; +import org.wildfly.glow.ScanArguments.Builder; +import org.wildfly.glow.maven.MavenResolver; + +import picocli.CommandLine; + +@CommandLine.Command( + name = Constants.GO_OFFLINE_COMMAND, + sortOptions = true +) +public class GoOfflineCommand extends AbstractCommand { + + @CommandLine.Spec + protected CommandLine.Model.CommandSpec spec; + + @CommandLine.Option(names = {Constants.CLOUD_OPTION_SHORT, Constants.CLOUD_OPTION}) + Optional cloud; + + @CommandLine.Option(names = {Constants.WILDFLY_PREVIEW_OPTION_SHORT, Constants.WILDFLY_PREVIEW_OPTION}) + Optional wildflyPreview; + + @CommandLine.Option(names = {Constants.SERVER_VERSION_OPTION_SHORT, Constants.SERVER_VERSION_OPTION}, paramLabel = "") + Optional wildflyServerVersion; + + @CommandLine.Option(names = Constants.INPUT_FEATURE_PACKS_FILE_OPTION, paramLabel = "") + Optional provisioningXml; + + @Override + public Integer call() throws Exception { + System.out.println("Wildfly Glow is assembling offline content..."); + Builder builder = Arguments.scanBuilder(); + if (cloud.orElse(false)) { + builder.setExecutionContext(CLOUD_EXECUTION_CONTEXT); + } + if (wildflyPreview.orElse(false)) { + builder.setTechPreview(true); + } + if (wildflyServerVersion.isPresent()) { + builder.setVersion(wildflyServerVersion.get()); + } + if (verbose.isPresent()) { + builder.setVerbose(verbose.get()); + } + if (provisioningXml.isPresent()) { + builder.setProvisoningXML(provisioningXml.get()); + } + GlowSession.goOffline(MavenResolver.newMavenResolver(), builder.build(), GlowMessageWriter.DEFAULT); + System.out.println("Offline zip file "+ OFFLINE_ZIP + " generated"); + return 0; + } +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/MainCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/MainCommand.java new file mode 100644 index 00000000..24746d19 --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/MainCommand.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import java.io.IOException; +import java.util.ResourceBundle; +import java.util.concurrent.Callable; +import org.wildfly.glow.Version; + +import picocli.CommandLine; + +@CommandLine.Command(name = Constants.WILDFLY_GLOW, resourceBundle = "UsageMessages", + versionProvider = MainCommand.VersionProvider.class) +public class MainCommand implements Callable { + + @CommandLine.Spec + protected CommandLine.Model.CommandSpec spec; + + + @SuppressWarnings("unused") + @CommandLine.Option(names = {Constants.HELP_OPTION_SHORT, Constants.HELP_OPTION}, usageHelp = true) + boolean help; + + @SuppressWarnings("unused") + @CommandLine.Option(names = {Constants.VERSION_OPTION_SHORT, Constants.VERSION_OPTION}, versionHelp = true) + boolean version; + + @SuppressWarnings("unused") + @CommandLine.Option(names = {Constants.VERBOSE_OPTION_SHORT, Constants.VERBOSE_OPTION}) + boolean verbose; + + @Override + public Integer call() throws IOException { + // print welcome message - this is not printed when -h option is set + ResourceBundle usageBundle = ResourceBundle.getBundle("UsageMessages"); + + System.out.println(CommandLine.Help.Ansi.AUTO.string(usageBundle.getString("glow.welcomeMessage"))); + // print main command usage + spec.commandLine().usage(System.out); + return 0; + } + + static class VersionProvider implements CommandLine.IVersionProvider { + @Override + public String[] getVersion() throws Exception { + return new String[] {Version.getVersion()}; + } + } +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java new file mode 100644 index 00000000..d487a622 --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java @@ -0,0 +1,203 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import org.wildfly.glow.Arguments; +import static org.wildfly.glow.Arguments.CLOUD_EXECUTION_CONTEXT; +import static org.wildfly.glow.Arguments.COMPACT_PROPERTY; +import org.wildfly.glow.DockerSupport; +import org.wildfly.glow.FeaturePacks; +import org.wildfly.glow.GlowMessageWriter; +import org.wildfly.glow.GlowSession; +import org.wildfly.glow.HiddenPropertiesAccessor; +import org.wildfly.glow.OutputFormat; +import static org.wildfly.glow.OutputFormat.BOOTABLE_JAR; +import static org.wildfly.glow.OutputFormat.DOCKER_IMAGE; +import static org.wildfly.glow.OutputFormat.PROVISIONING_XML; +import static org.wildfly.glow.OutputFormat.SERVER; +import org.wildfly.glow.ScanArguments.Builder; +import org.wildfly.glow.ScanResults; +import org.wildfly.glow.maven.MavenResolver; + +import picocli.CommandLine; +import picocli.CommandLine.Parameters; + +@CommandLine.Command( + name = Constants.SCAN_COMMAND, + sortOptions = true +) +public class ScanCommand extends AbstractCommand { + + @CommandLine.Spec + protected CommandLine.Model.CommandSpec spec; + + @CommandLine.Option(names = {Constants.CLOUD_OPTION_SHORT, Constants.CLOUD_OPTION}) + Optional cloud; + + @CommandLine.Option(names = {Constants.WILDFLY_PREVIEW_OPTION_SHORT, Constants.WILDFLY_PREVIEW_OPTION}) + Optional wildflyPreview; + + @CommandLine.Option(names = {Constants.SUGGEST_OPTION_SHORT, Constants.SUGGEST_OPTION}) + Optional suggest; + + @CommandLine.Option(names = Constants.HA_OPTION) + Optional haProfile; + + @CommandLine.Option(names = {Constants.SERVER_VERSION_OPTION_SHORT, Constants.SERVER_VERSION_OPTION}, paramLabel = Constants.SERVER_VERSION_OPTION_LABEL) + Optional wildflyServerVersion; + + @CommandLine.Option(names = {Constants.DOCKER_IMAGE_NAME_OPTION_SHORT, Constants.DOCKER_IMAGE_NAME_OPTION}, paramLabel = Constants.DOCKER_IMAGE_NAME_OPTION_LABEL) + Optional dockerImageName; + + @CommandLine.Option(names = Constants.ADD_LAYERS_FOR_JNDI_OPTION, split = ",", paramLabel = Constants.ADD_LAYERS_FOR_JNDI_OPTION_LABEL) + Set layersForJndi = new LinkedHashSet<>(); + + @CommandLine.Option(names = {Constants.ADD_ONS_OPTION_SHORT, Constants.ADD_ONS_OPTION}, split = ",", paramLabel = Constants.ADD_ONS_OPTION_LABEL) + Set addOns = new LinkedHashSet<>(); + + @Parameters(descriptionKey = "deployments") + List deployments; + + @CommandLine.Option(names = Constants.INPUT_FEATURE_PACKS_FILE_OPTION, paramLabel = Constants.INPUT_FEATURE_PACKS_FILE_OPTION_LABEL) + Optional provisioningXml; + + @CommandLine.Option(names = {Constants.PROVISION_OPTION_SHORT, Constants.PROVISION_OPTION}, paramLabel = Constants.PROVISION_OPTION_LABEL) + Optional provision; + + @Override + public Integer call() throws Exception { + HiddenPropertiesAccessor hiddenPropertiesAccessor = new HiddenPropertiesAccessor(); + boolean compact = Boolean.parseBoolean(hiddenPropertiesAccessor.getProperty(COMPACT_PROPERTY)); + if (!compact) { + System.out.println("Wildfly Glow is scanning..."); + } + Builder builder = Arguments.scanBuilder(); + if (cloud.orElse(false)) { + builder.setExecutionContext(CLOUD_EXECUTION_CONTEXT); + } + if (haProfile.orElse(false)) { + Set profiles = new HashSet<>(); + profiles.add(Constants.HA); + builder.setExecutionProfiles(profiles); + } + if (!layersForJndi.isEmpty()) { + builder.setJndiLayers(layersForJndi); + } + if (suggest.orElse(false)) { + builder.setSuggest(true); + } + if (wildflyPreview.orElse(false)) { + builder.setTechPreview(true); + } + if (wildflyServerVersion.isPresent()) { + builder.setVersion(wildflyServerVersion.get()); + } + if (verbose.isPresent()) { + builder.setVerbose(verbose.get()); + } + if (!addOns.isEmpty()) { + builder.setUserEnabledAddOns(addOns); + } + if (deployments != null && !deployments.isEmpty()) { + builder.setBinaries(deployments); + } + if (provisioningXml.isPresent()) { + builder.setProvisoningXML(provisioningXml.get()); + } + if (provision.isPresent()) { + if (BOOTABLE_JAR.equals(provision.get()) && cloud.orElse(false)) { + throw new Exception("Can't produce a Bootable JAR for cloud. Use the " + Constants.PROVISION_OPTION + "=SERVER option for cloud."); + } + if (DOCKER_IMAGE.equals(provision.get()) && !cloud.orElse(false)) { + throw new Exception("Can't produce a Docker image if cloud is not enabled. Use the " + Constants.CLOUD_OPTION + " option."); + } + builder.setOutput(provision.get()); + } + if (dockerImageName.isPresent()) { + if (provision.isPresent() && !DOCKER_IMAGE.equals(provision.get())) { + throw new Exception("Can only set a docker image name when provisioning a docker image. Remove the " + Constants.DOCKER_IMAGE_NAME_OPTION + " option"); + } + } + ScanResults scanResults = GlowSession.scan(MavenResolver.newMavenResolver(), builder.build(), GlowMessageWriter.DEFAULT); + scanResults.outputInformation(); + if (provision.isEmpty()) { + if (!compact) { + if (suggest.orElse(false)) { + if (!scanResults.getSuggestions().getPossibleAddOns().isEmpty() && addOns.isEmpty()) { + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold To enable add-ons add the|@ @|fg(yellow) " + Constants.ADD_ONS_OPTION + "=|@ @|bold option to the|@ @|fg(yellow) " + Constants.SCAN_COMMAND + "|@ @|bold command|@")); + } + if (!scanResults.getSuggestions().getPossibleProfiles().isEmpty()) { + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold To enable the HA profile add the|@ @|fg(yellow) " + Constants.HA_OPTION + "|@ @|bold option to the|@ @|fg(yellow) " + Constants.SCAN_COMMAND + "|@ @|bold command|@")); + } + } + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold To provision the WildFly server for your deployment add the|@ @|fg(yellow) " + Constants.PROVISION_OPTION + "=SERVER|@ @|bold option to the|@ @|fg(yellow) " + Constants.SCAN_COMMAND + "|@ @|bold command|@")); + } + } else { + System.out.print("\n"); + Path target = null; + String vers = wildflyServerVersion.orElse(null) == null ? FeaturePacks.getLatestVersion() : wildflyServerVersion.get(); + String doneMessage = null; + switch (provision.get()) { + case BOOTABLE_JAR: { + target = Paths.get(""); + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold Building WildFly Bootable JAR file|@")); + break; + } + case PROVISIONING_XML: { + target = Paths.get("server-" + vers); + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold Generating provisioning configuration in " + target + "/provisioning.xml file|@")); + doneMessage = CommandLine.Help.Ansi.AUTO.string("@|bold Generation DONE. Provisioning configuration is located in " + target + "/provisioning.xml file|@"); + break; + } + case SERVER: { + target = Paths.get("server-" + vers); + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold Provisioning server in " + target + " directory|@")); + if (cloud.orElse(false)) { + doneMessage = CommandLine.Help.Ansi.AUTO.string("@|bold Provisioning DONE. To run the server: 'JBOSS_HOME=" + target + " sh " + target + "/bin/openshift-launch.sh'|@"); + } else { + doneMessage = CommandLine.Help.Ansi.AUTO.string("@|bold Provisioning DONE. To run the server: 'sh " + target + "/bin/standalone.sh'|@"); + } + break; + } + case DOCKER_IMAGE: { + target = Paths.get("server-" + vers); + String imageName = dockerImageName.isPresent()? dockerImageName.get() : DockerSupport.getImageName(target.toString()); + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold Generating docker image '" + imageName + "'|@")); + doneMessage = CommandLine.Help.Ansi.AUTO.string("@|bold To run the image call: 'docker run " + imageName + "'|@"); + break; + } + } + Path actualTarget = scanResults.outputConfig(target, dockerImageName.orElse(null)); + if (BOOTABLE_JAR.equals(provision.get())) { + doneMessage = CommandLine.Help.Ansi.AUTO.string("@|bold Bootable JAR build DONE. To run the jar: 'java -jar " + actualTarget + "'|@"); + } else { + if (DOCKER_IMAGE.equals(provision.get())) { + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold Image generation DONE. Docker file generated in " + actualTarget.toAbsolutePath() + "|@.")); + } + } + System.out.println(doneMessage); + } + return 0; + } +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/ShowAddOnsCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/ShowAddOnsCommand.java new file mode 100644 index 00000000..7132c7ea --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/ShowAddOnsCommand.java @@ -0,0 +1,89 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import org.jboss.galleon.layout.FeaturePackLayout; +import org.jboss.galleon.layout.ProvisioningLayout; +import org.jboss.galleon.universe.UniverseResolver; +import org.jboss.galleon.universe.maven.repo.MavenRepoManager; +import org.wildfly.glow.AddOn; +import org.wildfly.glow.Arguments; +import org.wildfly.glow.GlowMessageWriter; +import org.wildfly.glow.Layer; +import org.wildfly.glow.LayerMapping; +import org.wildfly.glow.Utils; +import org.wildfly.glow.maven.MavenResolver; + +import picocli.CommandLine; + +@CommandLine.Command( + name = Constants.SHOW_ADD_ONS_COMMAND, + sortOptions = true +) +public class ShowAddOnsCommand extends AbstractCommand { + + @CommandLine.Option(names = {Constants.CLOUD_OPTION_SHORT, Constants.CLOUD_OPTION}) + Optional cloud; + + @CommandLine.Option(names = {Constants.WILDFLY_PREVIEW_OPTION_SHORT, Constants.WILDFLY_PREVIEW_OPTION}) + Optional wildflyPreview; + + @CommandLine.Option(names = {Constants.SERVER_VERSION_OPTION_SHORT, Constants.SERVER_VERSION_OPTION}, paramLabel = Constants.SERVER_VERSION_OPTION_LABEL) + Optional wildflyServerVersion; + + @CommandLine.Option(names = Constants.INPUT_FEATURE_PACKS_FILE_OPTION, paramLabel = Constants.INPUT_FEATURE_PACKS_FILE_OPTION_LABEL) + Optional provisioningXml; + + @Override + public Integer call() throws Exception { + System.out.println("Wildfly Glow is retrieving add-ons..."); + MavenRepoManager resolver = MavenResolver.newMavenResolver(); + UniverseResolver universeResolver = UniverseResolver.builder().addArtifactResolver(resolver).build(); + String context = Arguments.BARE_METAL_EXECUTION_CONTEXT; + if (cloud.orElse(false)) { + context = Arguments.CLOUD_EXECUTION_CONTEXT; + } + try (ProvisioningLayout layout = Utils.buildLayout(context, + provisioningXml.orElse(null), wildflyServerVersion.orElse(null), GlowMessageWriter.DEFAULT, wildflyPreview.orElse(false))) { + Map all; + try { + all = Utils.getAllLayers(universeResolver, layout, new HashMap<>()); + } finally { + layout.close(); + } + LayerMapping mapping = Utils.buildMapping(all, Collections.emptySet()); + StringBuilder builder = new StringBuilder(); + for (Map.Entry> entry : mapping.getAddOnFamilyMembers().entrySet()) { + builder.append("* @|bold ").append(entry.getKey()).append("|@ add-ons:\n"); + for (AddOn member : mapping.getAddOnFamilyMembers().get(entry.getKey())) { + if (!member.getName().endsWith(":default")) { + builder.append(" - ").append(member.getName()).append(member.getDescription() == null ? "" : ": " + member.getDescription()).append("\n"); + } + } + } + System.out.println(CommandLine.Help.Ansi.AUTO.string(builder.toString())); + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold Add-ons can be set using the|@ @|fg(yellow) " + Constants.ADD_ONS_OPTION + "=|@ @|bold option of the|@ @|fg(yellow) " + Constants.SCAN_COMMAND + "|@ @|bold command|@")); + } + return 0; + } +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/ShowConfigurationCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/ShowConfigurationCommand.java new file mode 100644 index 00000000..a8300b8e --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/ShowConfigurationCommand.java @@ -0,0 +1,89 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import org.jboss.galleon.config.ProvisioningConfig; +import org.jboss.galleon.layout.FeaturePackLayout; +import org.jboss.galleon.layout.ProvisioningLayout; +import org.jboss.galleon.universe.FeaturePackLocation; +import org.jboss.galleon.universe.UniverseResolver; +import org.jboss.galleon.universe.maven.repo.MavenRepoManager; +import org.jboss.galleon.xml.ProvisioningXmlParser; +import org.wildfly.glow.Arguments; +import org.wildfly.glow.FeaturePacks; +import org.wildfly.glow.GlowMessageWriter; +import org.wildfly.glow.Layer; +import org.wildfly.glow.LayerMapping; +import org.wildfly.glow.Utils; +import org.wildfly.glow.cli.CLIArguments; +import org.wildfly.glow.maven.MavenResolver; + +import picocli.CommandLine; + +@CommandLine.Command( + name = Constants.SHOW_CONFIGURATION_COMMAND, + sortOptions = true +) +public class ShowConfigurationCommand extends AbstractCommand { + + @CommandLine.Option(names = {Constants.CLOUD_OPTION_SHORT, Constants.CLOUD_OPTION}) + Optional cloud; + + @CommandLine.Option(names = {Constants.WILDFLY_PREVIEW_OPTION_SHORT, Constants.WILDFLY_PREVIEW_OPTION}) + Optional wildflyPreview; + + @CommandLine.Option(names = {Constants.SERVER_VERSION_OPTION_SHORT, Constants.SERVER_VERSION_OPTION}, paramLabel = Constants.SERVER_VERSION_OPTION_LABEL) + Optional wildflyServerVersion; + + @CommandLine.Option(names = Constants.INPUT_FEATURE_PACKS_FILE_OPTION, paramLabel = Constants.INPUT_FEATURE_PACKS_FILE_OPTION_LABEL) + Optional provisioningXml; + + @Override + public Integer call() throws Exception { + System.out.println("Wildfly Glow is retrieving know provisioning configuration..."); + MavenRepoManager resolver = MavenResolver.newMavenResolver(); + UniverseResolver universeResolver = UniverseResolver.builder().addArtifactResolver(resolver).build(); + String context = Arguments.BARE_METAL_EXECUTION_CONTEXT; + if (cloud.orElse(false)) { + context = Arguments.CLOUD_EXECUTION_CONTEXT; + } + try (ProvisioningLayout layout = Utils.buildLayout(context, + provisioningXml.orElse(null), wildflyServerVersion.orElse(null), GlowMessageWriter.DEFAULT, wildflyPreview.orElse(false))) { + Map all; + Map> fpDependencies = new HashMap<>(); + try { + all = Utils.getAllLayers(universeResolver, layout, fpDependencies); + } finally { + layout.close(); + } + LayerMapping mapping = Utils.buildMapping(all, Collections.emptySet()); + boolean isLatest = wildflyServerVersion.isEmpty(); + String vers = wildflyServerVersion.isPresent() ? wildflyServerVersion.get() : FeaturePacks.getLatestVersion(); + Path fps = FeaturePacks.getFeaturePacks(vers, context, wildflyPreview.orElse(false)); + ProvisioningConfig config = ProvisioningXmlParser.parse(fps); + String configStr = CLIArguments.dumpConfiguration(fpDependencies, context, vers, all, mapping, config, isLatest, wildflyPreview.orElse(false)); + System.out.println(CommandLine.Help.Ansi.AUTO.string(configStr)); + } + return 0; + } +} diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/ShowServerVersionsCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/ShowServerVersionsCommand.java new file mode 100644 index 00000000..ffac7425 --- /dev/null +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/ShowServerVersionsCommand.java @@ -0,0 +1,34 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wildfly.glow.cli.commands; + +import org.wildfly.glow.FeaturePacks; +import picocli.CommandLine; + +@CommandLine.Command( + name = Constants.SHOW_SERVER_VERSIONS_COMMAND, + sortOptions = true +) +public class ShowServerVersionsCommand extends AbstractCommand { + + @Override + public Integer call() throws Exception { + System.out.println(FeaturePacks.getAllVersions()); + System.out.println(CommandLine.Help.Ansi.AUTO.string("@|bold WildFly server version can be set using the|@ @|fg(yellow) "+Constants.SERVER_VERSION_OPTION+"=|@ @|bold option of the|@ @|fg(yellow) "+Constants.SCAN_COMMAND+"|@ @|bold command|@")); + return 0; + } +} diff --git a/cli/src/main/resources/UsageMessages.properties b/cli/src/main/resources/UsageMessages.properties new file mode 100644 index 00000000..987ea644 --- /dev/null +++ b/cli/src/main/resources/UsageMessages.properties @@ -0,0 +1,48 @@ +# +# WildFly Glow CLI messages +# +# +# Main Command Welcome Message +# +# This is only printed when running prospero without any parameters. +glow.welcomeMessage = @|bold \nWelcome to WildFly Glow CLI!|@\n\ + \n\ + WildFly Glow helps you create a WildFly server based on the content of your WAR/JAR/EAR deployment(s).\n\ + Call @|fg(yellow) wildfly-glow scan |@ to get started.\n + +# +# Footer +# +# This only appears in the main command usage. + +wildfly-glow.usage.footer = %nUse @|fg(yellow) wildfly-glow --help|@ to show help information for the command. + + +cloud = When deploying your application to the cloud. It will fine tune the WildFly server for the cloud. N.B.: Building a Bootable JAR is not supported for the cloud. +docker-image-name = Name of the docker image when --provision=DOCKER is specified. By default an image name is computed based on the WildFly server version. +version = Prints the version of wildfly-glow and exits. +verbose = Prints additional information if the command fails. +server-version = The WildFly server version to deploy the deployment to. By default the latest WildFly version is used. +wildfly-preview = To deploy the deployment into a WildFly preview server (by default normal WildFly server is used). +ha = High Availability profile. Set this option when deploying an application into an HA WildFly Server. +add-layers-for-jndi = List of layers. In the case some layers are missing, consider adding them manually with this option. +suggest = WildFly Glow will suggest additional add-ons and environment variables that are usable with your deployment. +add-ons = List of add-ons to enable. To get the list of possible add-ons, use the @|fg(yellow) show-add-ons|@ command. +deployments = List of path to war|jar|ear files to scan. +input-feature-packs-file = Galleon feature-packs used by wildfly-glow are retrieved from an online registry. To override the set of feature-packs you can specify a path to a Galleon provisioning XML file containing the set of Galleon feature-packs to be used by wildfly-glow. +provision = The kind of provisioning to produce based on what has been discovered. Can be @|fg(yellow) SERVER|@: a provisioned WildFly server, @|fg(yellow) BOOTABLE_JAR|@: a WildFly Bootable JAR, @|fg(yellow) DOCKER_IMAGE|@: a Docker image or @|fg(yellow) PROVISIONING_XML|@: a Galleon provisioning.xml file. +wildfly-preview = Use only WildFly preview feature-packs as input. +usage.synopsisHeading = %nUsage:\u0020 +# for the main command do not prepend with new line character: +wildfly-glow.usage.synopsisHeading = Usage:\u0020 +usage.commandListHeading = %nCommands:%n +usage.optionListHeading = %nOptions:%n +wildfly-glow.help = Displays the help information for the command. + + +wildfly-glow.show-configuration.usage.header = Shows the Galleon feature-packs and Galleon layers known by WildFly Glow. +wildfly-glow.show-server-versions.usage.header = Shows all WildFly server versions one can set with the @|fg(yellow) --server-version|@ option. +wildfly-glow.show-add-ons.usage.header = Shows all the WildFly server add-ons one can set with the @|fg(yellow) --add-ons|@ option to the @|fg(yellow) scan|@ command. +wildfly-glow.scan.usage.header = Scan your deployment(s) to produce a WildFly server. +wildfly-glow.go-offline.usage.header = Generate a zip file containing all that is required to run the tool in offline mode. Put the generated zip in the working directory of WildFly Glow to work offline. +wildfly-glow.completion.usage.header = Generates a bash completion script. To enable auto-completion use the command `source <(./wildfly-glow completion)`. \ No newline at end of file diff --git a/core/src/main/java/org/wildfly/glow/Arguments.java b/core/src/main/java/org/wildfly/glow/Arguments.java index 309f8f9d..ce32e399 100644 --- a/core/src/main/java/org/wildfly/glow/Arguments.java +++ b/core/src/main/java/org/wildfly/glow/Arguments.java @@ -9,7 +9,7 @@ public class Arguments implements GoOfflineArguments, ScanArguments { - private static final String COMPACT_PROPERTY = "compact"; + public static final String COMPACT_PROPERTY = "compact"; private static final String MANUAL_LAYERS_PROPERTY = "org.wildfly.glow.manual.layers"; private final Set executionProfiles; diff --git a/core/src/main/java/org/wildfly/glow/DockerSupport.java b/core/src/main/java/org/wildfly/glow/DockerSupport.java index b3374582..e820b9fe 100644 --- a/core/src/main/java/org/wildfly/glow/DockerSupport.java +++ b/core/src/main/java/org/wildfly/glow/DockerSupport.java @@ -31,20 +31,25 @@ */ public class DockerSupport { - public static boolean buildApplicationImage(String image, Path jbossHome, Arguments arguments, GlowMessageWriter writer) throws IOException { + public static Path buildApplicationImage(String image, Path jbossHome, Arguments arguments, GlowMessageWriter writer) throws IOException { jbossHome = jbossHome.toAbsolutePath(); String binary = ExecUtil.resolveImageBinary(writer); - generateDockerfile( "quay.io/wildfly/wildfly-runtime:latest", jbossHome.getParent(), jbossHome); + Path file = generateDockerfile("quay.io/wildfly/wildfly-runtime:latest", jbossHome.getParent(), jbossHome); writer.info(format("Building application image %s using %s.", image, binary)); String[] dockerArgs = new String[]{"build", "-t", image, "."}; writer.info(format("Executing the following command to build application image: '%s %s'", binary, join(" ", dockerArgs))); - return ExecUtil.exec(jbossHome.getParent().toFile(), binary, writer, + ExecUtil.exec(jbossHome.getParent().toFile(), binary, writer, dockerArgs); + return file; } - private static void generateDockerfile(String runtimeImage, Path targetDir, Path jbossHome) + public static String getImageName(String target) { + return ("wildfly-glow-image-" + target.replaceAll("\\.", "_") + ":latest").toLowerCase(); + } + + private static Path generateDockerfile(String runtimeImage, Path targetDir, Path jbossHome) throws IOException { // Docker requires the source file be relative to the context. From the documentation: @@ -53,11 +58,12 @@ private static void generateDockerfile(String runtimeImage, Path targetDir, Path if (jbossHome.isAbsolute()) { jbossHome = targetDir.relativize(jbossHome); } - - Files.writeString(targetDir.resolve("Dockerfile"), + Path file = targetDir.resolve("Dockerfile"); + Files.writeString(file, "FROM " + runtimeImage + "\n" + "COPY --chown=jboss:root " + jbossHome + " $JBOSS_HOME\n" + "RUN chmod -R ug+rwX $JBOSS_HOME\n", StandardCharsets.UTF_8); + return file; } } diff --git a/core/src/main/java/org/wildfly/glow/FeaturePacks.java b/core/src/main/java/org/wildfly/glow/FeaturePacks.java index cf7c4252..92e96276 100644 --- a/core/src/main/java/org/wildfly/glow/FeaturePacks.java +++ b/core/src/main/java/org/wildfly/glow/FeaturePacks.java @@ -41,19 +41,23 @@ public class FeaturePacks { private static final String TECH_PREVIEW = "/tech-preview/"; public static Path getFeaturePacks(String version, String context, boolean techPreview) throws Exception { - String rootURL = getFeaturePacksURL(); - Yaml yaml = new Yaml(); - if (version == null) { - Map map = yaml.load(new URI(rootURL + VERSIONS).toURL().openStream()); - version = map.get("latest"); - } - Path p = Files.createTempFile("glow-provisioning-", context); - try (InputStream in = new URL(rootURL + version + (techPreview ? TECH_PREVIEW : "") + PROVISIONING_FILE_RADICAL + context + ".xml").openStream()) { - Files.copy(in, p, - StandardCopyOption.REPLACE_EXISTING); + try { + String rootURL = getFeaturePacksURL(); + Yaml yaml = new Yaml(); + if (version == null) { + Map map = yaml.load(new URI(rootURL + VERSIONS).toURL().openStream()); + version = map.get("latest"); + } + Path p = Files.createTempFile("glow-provisioning-", context); + try (InputStream in = new URL(rootURL + version + (techPreview ? TECH_PREVIEW : "") + PROVISIONING_FILE_RADICAL + context + ".xml").openStream()) { + Files.copy(in, p, + StandardCopyOption.REPLACE_EXISTING); + } + p.toFile().deleteOnExit(); + return p; + } catch (Exception ex) { + throw new Exception("Exception occured while retrieving known Galleon feature-packs for version " + version + ". Cause: " + ex.getLocalizedMessage()); } - p.toFile().deleteOnExit(); - return p; } public static String getFeaturePacksURL() throws Exception { diff --git a/core/src/main/java/org/wildfly/glow/GlowSession.java b/core/src/main/java/org/wildfly/glow/GlowSession.java index a9116591..7b24e9d7 100644 --- a/core/src/main/java/org/wildfly/glow/GlowSession.java +++ b/core/src/main/java/org/wildfly/glow/GlowSession.java @@ -96,7 +96,7 @@ private void goOffline() throws Exception { } UniverseResolver universeResolver = UniverseResolver.builder().addArtifactResolver(resolver).build(); - try (ProvisioningLayout layout = Utils.buildLayout(Arguments.CLOUD_EXECUTION_CONTEXT, + try (ProvisioningLayout layout = Utils.buildLayout(arguments.getExecutionContext(), arguments.getProvisioningXML(), arguments.getVersion(), writer, arguments.isTechPreview())) { Utils.exportOffline(universeResolver, layout); } @@ -161,7 +161,7 @@ public ScanResults scan() throws Exception { // END VALIDATE USER INPUTS // DISCOVERY - if (!arguments.getBinaries().isEmpty()) { + if (arguments.getBinaries() != null && !arguments.getBinaries().isEmpty()) { Path windup = WindupSupport.getWindupMapping(); if (windup == null) { for (Path d : arguments.getBinaries()) { @@ -451,29 +451,30 @@ public ScanResults scan() throws Exception { } } - void outputConfig(ScanResults scanResults, Path target, boolean generateImage) throws Exception { + Path outputConfig(ScanResults scanResults, Path target, String dockerImageName) throws Exception { if (arguments.getOutput() == null) { throw new IllegalStateException("No output format set"); } - if (OutputFormat.SERVER.equals(arguments.getOutput()) || OutputFormat.BOOTABLE_JAR.equals(arguments.getOutput())) { + Path ret = null; + if (OutputFormat.DOCKER_IMAGE.equals(arguments.getOutput()) || OutputFormat.SERVER.equals(arguments.getOutput()) || OutputFormat.BOOTABLE_JAR.equals(arguments.getOutput())) { if (scanResults.getErrorSession().hasErrors()) { writer.warn("You are provisioning a server although some errors still exist. You should first fix them."); } Path generatedArtifact = provisionServer(arguments.getBinaries(), scanResults.getProvisioningConfig(), resolver, arguments.getOutput(), arguments.isCloud(), target); - if (arguments.isCloud()) { + if (OutputFormat.DOCKER_IMAGE.equals(arguments.getOutput())) { // generate docker image - if (generateImage) { - String image = "image-" + generatedArtifact.getFileName().toString().toLowerCase(); - DockerSupport.buildApplicationImage(image, generatedArtifact, arguments, writer); - writer.info("Image generation DONE. To run the image: " + ExecUtil.resolveImageBinary(writer) + " run " + image); - } + String imageName = dockerImageName == null ? DockerSupport.getImageName(generatedArtifact.getFileName().toString()) : dockerImageName; + ret = DockerSupport.buildApplicationImage(imageName, generatedArtifact, arguments, writer); } + IoUtils.recursiveDelete(generatedArtifact); } else { if (OutputFormat.PROVISIONING_XML.equals(arguments.getOutput())) { - writer.info("Generating provisioning.xml in " + target.toAbsolutePath()); - try (FileWriter fileWriter = new FileWriter(target.resolve("provisioning.xml").toFile())) { + IoUtils.recursiveDelete(target); + Files.createDirectories(target); + ret = target.resolve("provisioning.xml"); + try (FileWriter fileWriter = new FileWriter(ret.toFile())) { ProvisioningXmlWriter.getInstance().write(scanResults.getProvisioningConfig(), fileWriter); } } @@ -497,6 +498,7 @@ void outputConfig(ScanResults scanResults, Path target, boolean generateImage) t writer.info("The file " + p + " contains the environment variables to set in a " + arguments.getExecutionContext() + " context"); Files.write(p, envFileContent.toString().getBytes()); } + return ret; } private String buildEnvs(Map> map, boolean isRequired) { @@ -526,7 +528,15 @@ String getCompactInformation(ScanResultsPrinter scanResultsPrinter, ScanResults private Path provisionServer(List binaries, ProvisioningConfig activeConfig, MavenRepoManager resolver, OutputFormat format, boolean isCloud, Path target) throws Exception { - IoUtils.recursiveDelete(target); + Path tmpDir = null; + Path originalTarget = target; + if (!isCloud && OutputFormat.BOOTABLE_JAR.equals(format)) { + // We create a tmp directory in which the server is provisioned + tmpDir = Files.createTempDirectory("wildfly-glow-bootable"); + target = tmpDir; + } else { + IoUtils.recursiveDelete(target); + } Utils.provisionServer(activeConfig, target.toAbsolutePath(), resolver, writer); if (!binaries.isEmpty()) { @@ -539,66 +549,65 @@ private Path provisionServer(List binaries, ProvisioningConfig activeConfi } Path ret = target; if (!isCloud && OutputFormat.BOOTABLE_JAR.equals(format)) { - String bootableJarName = ""; - if (!binaries.isEmpty()) { - for (Path binary : binaries) { - int i = binary.getFileName().toString().lastIndexOf("."); - bootableJarName = bootableJarName + binary.getFileName().toString().substring(0, i); - } - } else { - bootableJarName = "hollow"; - } - Path targetJarFile = target.toAbsolutePath().getParent().resolve(bootableJarName + "-" + BootableJarSupport.BOOTABLE_SUFFIX + ".jar"); - ret = targetJarFile; - Files.deleteIfExists(targetJarFile); - BootableJarSupport.packageBootableJar(targetJarFile,target.toAbsolutePath().getParent(), - activeConfig, target.toAbsolutePath(), - resolver, - new MessageWriter() { - @Override - public void verbose(Throwable cause, CharSequence message) { - if (writer.isVerbose()) { - writer.trace(message); + try { + String bootableJarName = ""; + if (!binaries.isEmpty()) { + for (Path binary : binaries) { + int i = binary.getFileName().toString().lastIndexOf("."); + bootableJarName = bootableJarName + binary.getFileName().toString().substring(0, i); + } + } else { + bootableJarName = "hollow"; + } + String vers = arguments.getVersion() == null ? FeaturePacks.getLatestVersion() : arguments.getVersion(); + Path targetJarFile = originalTarget.toAbsolutePath().resolve(bootableJarName + "-" + vers + "-" + BootableJarSupport.BOOTABLE_SUFFIX + ".jar"); + ret = targetJarFile; + Files.deleteIfExists(targetJarFile); + BootableJarSupport.packageBootableJar(targetJarFile, originalTarget.toAbsolutePath(), + activeConfig, tmpDir.toAbsolutePath(), + resolver, + new MessageWriter() { + @Override + public void verbose(Throwable cause, CharSequence message) { + if (writer.isVerbose()) { + writer.trace(message); + } } - } - @Override - public void print(Throwable cause, CharSequence message) { - writer.info(message); - } + @Override + public void print(Throwable cause, CharSequence message) { + writer.info(message); + } - @Override - public void error(Throwable cause, CharSequence message) { - writer.error(message); - } + @Override + public void error(Throwable cause, CharSequence message) { + writer.error(message); + } - @Override - public boolean isVerboseEnabled() { - return writer.isVerbose(); - } + @Override + public boolean isVerboseEnabled() { + return writer.isVerbose(); + } - @Override - public void close() throws Exception { - } + @Override + public void close() throws Exception { + } - }, new ArtifactLog() { - @Override - public void info(FeaturePackLocation.FPID fpid, MavenArtifact a) { - writer.info("Found artifact " + a); - } + }, new ArtifactLog() { + @Override + public void info(FeaturePackLocation.FPID fpid, MavenArtifact a) { + writer.info("Found artifact " + a); + } - @Override - public void debug(FeaturePackLocation.FPID fpid, MavenArtifact a) { - if (writer.isVerbose()) { - writer.trace("Found artifact " + a); + @Override + public void debug(FeaturePackLocation.FPID fpid, MavenArtifact a) { + if (writer.isVerbose()) { + writer.trace("Found artifact " + a); + } } - } - }, null); - IoUtils.recursiveDelete(target); - writer.info("DONE. To run the server: java -jar " + targetJarFile); - } else { - if (!isCloud) { - writer.info("DONE. To run the server: sh " + target + "/bin/" + (isCloud ? "openshift-launch.sh" : "standalone.sh")); + }, null); + } finally { + IoUtils.recursiveDelete(target); } } return ret; diff --git a/core/src/main/java/org/wildfly/glow/HiddenPropertiesAccessor.java b/core/src/main/java/org/wildfly/glow/HiddenPropertiesAccessor.java index e5f22464..afc2bcea 100644 --- a/core/src/main/java/org/wildfly/glow/HiddenPropertiesAccessor.java +++ b/core/src/main/java/org/wildfly/glow/HiddenPropertiesAccessor.java @@ -22,10 +22,10 @@ public class HiddenPropertiesAccessor { private static Map overrides; - HiddenPropertiesAccessor() { + public HiddenPropertiesAccessor() { } - String getProperty(String name) { + public String getProperty(String name) { if (overrides != null) { String value = overrides.get(name); if (value != null) { diff --git a/core/src/main/java/org/wildfly/glow/OutputFormat.java b/core/src/main/java/org/wildfly/glow/OutputFormat.java index db1b2b3f..f2d9f8d2 100644 --- a/core/src/main/java/org/wildfly/glow/OutputFormat.java +++ b/core/src/main/java/org/wildfly/glow/OutputFormat.java @@ -24,7 +24,8 @@ public enum OutputFormat { PROVISIONING_XML("provisioning.xml", "Galleon provisioning file usable with Galleon tooling."), SERVER("server", "Provision a WildFly server."), - BOOTABLE_JAR("bootable-jar", "Provision a WildFly bootable jar."); + BOOTABLE_JAR("bootable-jar", "Provision a WildFly bootable jar."), + DOCKER_IMAGE("docker-image", "Produce a docker image."); public final String name; public final String description; diff --git a/core/src/main/java/org/wildfly/glow/ScanResults.java b/core/src/main/java/org/wildfly/glow/ScanResults.java index 022ece6c..276a326f 100644 --- a/core/src/main/java/org/wildfly/glow/ScanResults.java +++ b/core/src/main/java/org/wildfly/glow/ScanResults.java @@ -94,8 +94,8 @@ public Set getEnabledAddOns() { return enabledAddOns; } - public void outputConfig(Path target, boolean image) throws Exception { - glowSession.outputConfig(this, target, image); + public Path outputConfig(Path target, String dockerImageName) throws Exception { + return glowSession.outputConfig(this, target, dockerImageName); } public void outputInformation() throws Exception { diff --git a/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java b/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java index 79810908..30d527a1 100644 --- a/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java +++ b/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java @@ -79,8 +79,7 @@ private void detailed(ScanArguments arguments, ScanResults scanResults) throws E profileBuilder.append("none"); } writer.info(profileBuilder); - writer.info("\ngalleon discovery"); - writer.info("- raw basic layers: " + scanResults.getDiscoveredLayers()); + writer.info("galleon discovery"); StringBuilder builder = new StringBuilder(); builder.append("- feature-packs").append("\n"); for (FeaturePackConfig fp : scanResults.getProvisioningConfig().getFeaturePackDeps()) { @@ -107,10 +106,8 @@ private void detailed(ScanArguments arguments, ScanResults scanResults) throws E } writer.info(addOnsBuilder); } - writer.info("disabled add-ons"); - if (scanResults.getDisabledAddOns().isEmpty()) { - writer.info("none\n"); - } else { + if (!scanResults.getDisabledAddOns().isEmpty()) { + writer.info("disabled add-ons"); StringBuilder disabledBuilder = new StringBuilder(); for (Map.Entry l : scanResults.getDisabledAddOns().entrySet()) { disabledBuilder.append("- ").append(l.getKey().getName()).append(": ").append(l.getValue()).append("\n"); @@ -144,18 +141,15 @@ private void detailed(ScanArguments arguments, ScanResults scanResults) throws E } } - writer.info("identified errors"); - if (errorBuilders.isEmpty()) { - writer.info("none\n"); - } else { + if (!errorBuilders.isEmpty()) { + writer.info("identified errors"); for (StringBuilder errorBuilder : errorBuilders) { writer.error(errorBuilder); } } - writer.info("possible issues"); - if (warnBuilders.isEmpty()) { - writer.info("none\n"); - } else { + + if (!warnBuilders.isEmpty()) { + writer.info("possible issues"); for (StringBuilder warnBuilder : warnBuilders) { writer.warn(warnBuilder); } diff --git a/pom.xml b/pom.xml index 062bce44..61d26737 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ https://raw.githubusercontent.com/wildfly/wildfly-galleon-feature-packs/release/ + 4.7.5 9.5 6.4.0 10.0.0.Final @@ -209,6 +210,11 @@ wildfly-glow-arquillian-plugin-scanner ${project.version} + + info.picocli + picocli + ${version.info.picocli} + org.apache.commons commons-lang3 diff --git a/tests/run-cli-tests.sh b/tests/run-cli-tests.sh index f31add98..13e72164 100644 --- a/tests/run-cli-tests.sh +++ b/tests/run-cli-tests.sh @@ -21,33 +21,33 @@ function test { if [ ! -z "$provisioningFile" ]; then if [ ! "default" == "$provisioningFile" ]; then - provisioningFile="--feature-packs-file=$provisioningFile"; + provisioningFile="--input-feature-packs-file=$provisioningFile"; else unset provisioningFile fi fi if [ ! -z "$profile" ]; then - profile="--profiles=$profile"; + profile="--$profile"; fi if [ ! -z "$addOns" ]; then addOns="--add-ons=$addOns"; fi if [ ! -z "$context" ]; then - context="--context=$context"; + context="--$context"; fi if [ ! -z "$preview" ]; then - preview="--preview"; + preview="--wildfly-preview"; fi if [ ! -z $GENERATE_CONFIG ]; then - echo "java -jar -Dverbose=true $jar $warFile ${provisioningFile} $profile $addOns $preview" - java -jar -Dverbose=true $jar $warFile ${provisioningFile} $profile $addOns $preview + echo "java -jar -Dverbose=true $jar scan $warFile ${provisioningFile} $profile $addOns $preview" + java -jar -Dverbose=true $jar scan $warFile ${provisioningFile} $profile $addOns $preview else if [ "$DEBUG" = 1 ]; then - echo "java $compact -jar $jar $warFile ${provisioningFile} $profile $addOns $context $preview" + echo "java $compact -jar $jar scan $warFile ${provisioningFile} $profile $addOns $context $preview" fi - found_layers=$(java $compact -jar $jar \ + found_layers=$(java $compact -jar $jar scan \ $warFile \ ${provisioningFile} \ $profile \ @@ -71,9 +71,9 @@ if [ $? -ne 0 ]; then exit 1 fi -echo "* Display configuration" +echo "* Show configuration" -java -jar $jar --display-configuration +java -jar $jar show-configuration if [ $? -ne 0 ]; then echo "Error, check log" diff --git a/tests/run-internal.sh b/tests/run-internal.sh index ab48fd3e..83967654 100755 --- a/tests/run-internal.sh +++ b/tests/run-internal.sh @@ -45,34 +45,39 @@ function test() { if [ ! -z "$provisioningFile" ]; then if [ ! "default" == "$provisioningFile" ]; then - provisioningFile="--feature-packs-file=$provisioningFile"; + provisioningFile="--input-feature-packs-file=$provisioningFile"; else unset provisioningFile fi fi if [ ! -z "$profile" ]; then - profile="--profiles=$profile"; + profile="--$profile"; fi if [ ! -z "$addOns" ]; then addOns="--add-ons=$addOns"; fi if [ ! -z "$context" ]; then - context="--context=$context"; + context="--$context"; fi if [ ! -z "$preview" ]; then - preview="--preview"; + preview="--wildfly-preview"; fi +saved_IFS="$IFS" +IFS=, +read warFile1 warFile2 <<<$warFile +IFS="$saved_IFS" if [ ! -z $GENERATE_CONFIG ]; then - echo "java -jar -Dverbose=true $fpdb $jar $warFile ${provisioningFile} $profile $addOns $preview" - java -jar -Dverbose=true $fpdb $jar $warFile ${provisioningFile} $profile $addOns $preview + echo "java -jar -Dverbose=true $fpdb $jar scan $warFile1 $warFile2 ${provisioningFile} $profile $addOns $preview" + java -jar -Dverbose=true $fpdb $jar scan $warFile1 $warFile2 ${provisioningFile} $profile $addOns $preview else if [ "$DEBUG" = 1 ]; then - echo "java $compact $fpdb -jar $jar $warFile ${provisioningFile} $profile $addOns $context $preview" + echo "java $compact $fpdb -jar $jar scan $warFile1 $warFile2 ${provisioningFile} $profile $addOns $context $preview" fi - found_layers=$(java $fpdb $compact -jar $jar \ - $warFile \ + found_layers=$(java $fpdb $compact -jar $jar scan \ + $warFile1 \ + $warFile2 \ ${provisioningFile} \ $profile \ $addOns \ @@ -111,7 +116,7 @@ java -jar $jar echo "* Display configuration" -java -jar $jar --display-configuration +java -jar $jar show-configuration #preview fp @@ -658,7 +663,7 @@ echo todo-backend [Execution TESTED] test \ "[cdi, datasources, ejb-lite, jaxrs, jpa, postgresql-datasource, postgresql-driver, transactions]==>ee-core-profile-server,ejb-lite,jaxrs,jpa,postgresql-datasource" \ "$GLOW_QS_HOME"todo-backend/target/todo-backend.war \ -standalone \ +"" \ default \ postgresql diff --git a/wildfly-glow b/wildfly-glow new file mode 100755 index 00000000..59ef96c8 --- /dev/null +++ b/wildfly-glow @@ -0,0 +1,17 @@ +#!/bin/bash +if [ -n "${DEBUG}" ]; +then + JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8787" +else + JAVA_OPTS="$JAVA_OPTS" +fi + +if [ -z "${WILDFLY_GLOW_HOME}" ]; +then + full_path=$(realpath $0) + WILDFLY_GLOW_HOME=$(dirname $full_path) +fi +CLASSPATH=( "${WILDFLY_GLOW_HOME}/cli/target/"wildfly-glow.jar ) + +java ${JAVA_OPTS} -jar "${CLASSPATH}" "$@" +