From 70cb8cfed6022bc1446d1e6ff7f384cbcb783385 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 3 Feb 2014 20:17:00 -0800 Subject: [PATCH] Fix CLI package and class tangles --- .../{command => }/DefaultCommandFactory.java | 4 +++- .../springframework/boot/cli/SpringCli.java | 6 ++++-- .../boot/cli/command/AbstractCommand.java | 2 ++ .../boot/cli/command/Command.java | 2 ++ .../cli/{ => command}/CommandException.java | 2 +- .../boot/cli/{ => command}/CommandRunner.java | 20 ++----------------- .../{ => command}/NoArgumentsException.java | 3 ++- .../NoHelpCommandArgumentsException.java | 2 +- .../{ => command}/NoSuchCommandException.java | 2 +- .../cli/command/OptionParsingCommand.java | 3 +++ .../boot/cli/command/core/HelpCommand.java | 10 +++++----- .../boot/cli/command/core/HintCommand.java | 6 +++--- .../boot/cli/command/core/VersionCommand.java | 2 +- .../boot/cli/command/grab/GrabCommand.java | 8 ++++---- .../boot/cli/command/jar/JarCommand.java | 8 ++++---- .../{ => options}/CompilerOptionHandler.java | 2 +- .../command/{ => options}/OptionHandler.java | 4 +++- .../cli/command/{ => options}/OptionHelp.java | 2 +- ...OptionSetGroovyCompilerConfiguration.java} | 12 ++++++----- .../command/{ => options}/SourceOptions.java | 2 +- .../boot/cli/command/run/RunCommand.java | 8 ++++---- .../cli/command/shell/CommandCompleter.java | 4 ++-- .../cli/command/shell/ForkProcessCommand.java | 2 +- .../boot/cli/command/shell/Shell.java | 5 +++-- .../cli/command/shell/ShellExitException.java | 2 +- .../boot/cli/command/test/TestCommand.java | 8 ++++---- ...ndencyAutoConfigurationTransformation.java | 0 .../GroovyBeansTransformation.java | 0 ...veDependencyCoordinatesTransformation.java | 0 .../boot/cli/{ => util}/Log.java | 2 +- ...gframework.boot.cli.command.CommandFactory | 2 +- .../CommandRunnerIntegrationTests.java | 3 ++- .../cli/{ => command}/CommandRunnerTests.java | 9 +++++---- .../command/OptionParsingCommandTests.java | 1 + ...endencyCoordinatesTransformationTests.java | 0 35 files changed, 76 insertions(+), 72 deletions(-) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{command => }/DefaultCommandFactory.java (90%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{ => command}/CommandException.java (98%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{ => command}/CommandRunner.java (94%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{ => command}/NoArgumentsException.java (94%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{ => command}/NoHelpCommandArgumentsException.java (95%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{ => command}/NoSuchCommandException.java (95%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/command/{ => options}/CompilerOptionHandler.java (97%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/command/{ => options}/OptionHandler.java (97%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/command/{ => options}/OptionHelp.java (94%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{compiler/GroovyCompilerConfigurationAdapter.java => command/options/OptionSetGroovyCompilerConfiguration.java} (82%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/command/{ => options}/SourceOptions.java (98%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/{transformation => }/DependencyAutoConfigurationTransformation.java (100%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/{transformation => }/GroovyBeansTransformation.java (100%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/{transformation => }/ResolveDependencyCoordinatesTransformation.java (100%) rename spring-boot-cli/src/main/java/org/springframework/boot/cli/{ => util}/Log.java (96%) rename spring-boot-cli/src/test/java/org/springframework/boot/cli/{ => command}/CommandRunnerIntegrationTests.java (94%) rename spring-boot-cli/src/test/java/org/springframework/boot/cli/{ => command}/CommandRunnerTests.java (95%) rename spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/{transformation => }/ResolveDependencyCoordinatesTransformationTests.java (100%) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/DefaultCommandFactory.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java similarity index 90% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/command/DefaultCommandFactory.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java index 26d549ded5..589388e765 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/DefaultCommandFactory.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/DefaultCommandFactory.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.cli.command; +package org.springframework.boot.cli; import java.util.Arrays; import java.util.Collection; import java.util.List; +import org.springframework.boot.cli.command.Command; +import org.springframework.boot.cli.command.CommandFactory; import org.springframework.boot.cli.command.core.VersionCommand; import org.springframework.boot.cli.command.grab.GrabCommand; import org.springframework.boot.cli.command.jar.JarCommand; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/SpringCli.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/SpringCli.java index d9e28281a8..9afce6a68e 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/SpringCli.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/SpringCli.java @@ -19,7 +19,9 @@ package org.springframework.boot.cli; import java.util.ServiceLoader; import org.springframework.boot.cli.command.CommandFactory; +import org.springframework.boot.cli.command.CommandRunner; import org.springframework.boot.cli.command.core.HelpCommand; +import org.springframework.boot.cli.command.core.HintCommand; import org.springframework.boot.cli.command.core.VersionCommand; import org.springframework.boot.cli.command.shell.ShellCommand; @@ -37,10 +39,10 @@ public class SpringCli { System.setProperty("java.awt.headless", Boolean.toString(true)); CommandRunner runner = new CommandRunner("spring"); - runner.addHelpCommand(); + runner.addCommand(new HelpCommand(runner)); addServiceLoaderCommands(runner); runner.addCommand(new ShellCommand()); - runner.addHintCommand(); + runner.addCommand(new HintCommand(runner)); runner.setOptionCommands(HelpCommand.class, VersionCommand.class); int exitCode = runner.runAndHandleErrors(args); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/AbstractCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/AbstractCommand.java index 850b21face..a70b46addc 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/AbstractCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/AbstractCommand.java @@ -19,6 +19,8 @@ package org.springframework.boot.cli.command; import java.util.Collection; import java.util.Collections; +import org.springframework.boot.cli.command.options.OptionHelp; + /** * Abstract {@link Command} implementation. * diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/Command.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/Command.java index 29dce3902c..3fb24b4b4c 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/Command.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/Command.java @@ -18,6 +18,8 @@ package org.springframework.boot.cli.command; import java.util.Collection; +import org.springframework.boot.cli.command.options.OptionHelp; + /** * A single command that can be run from the CLI. * diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/CommandException.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandException.java similarity index 98% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/CommandException.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandException.java index bc350f0635..0732a502be 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/CommandException.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; import java.util.Arrays; import java.util.Collections; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/CommandRunner.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java similarity index 94% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/CommandRunner.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java index 2175d639fc..2863f33baa 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/CommandRunner.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; import java.util.ArrayList; import java.util.Arrays; @@ -24,9 +24,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.core.HelpCommand; -import org.springframework.boot.cli.command.core.HintCommand; +import org.springframework.boot.cli.util.Log; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -64,20 +62,6 @@ public class CommandRunner implements Iterable { return this.name; } - /** - * Add 'help' support. - */ - public void addHelpCommand() { - this.commands.add(new HelpCommand(this)); - } - - /** - * Add 'hint' support for command line completion. - */ - public void addHintCommand() { - this.commands.add(new HintCommand(this)); - } - /** * Add the specified commands. * @param commands the commands to add diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/NoArgumentsException.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoArgumentsException.java similarity index 94% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/NoArgumentsException.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoArgumentsException.java index 116b7463f6..09a15f0087 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/NoArgumentsException.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoArgumentsException.java @@ -14,7 +14,8 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; + /** * Exception used to indicate that no arguemnts were specified. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/NoHelpCommandArgumentsException.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoHelpCommandArgumentsException.java similarity index 95% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/NoHelpCommandArgumentsException.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoHelpCommandArgumentsException.java index 5bbdd043bf..a30731b830 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/NoHelpCommandArgumentsException.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoHelpCommandArgumentsException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; /** * Exception used to when the help command is called without arguments. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/NoSuchCommandException.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoSuchCommandException.java similarity index 95% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/NoSuchCommandException.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoSuchCommandException.java index 5e473ab2a1..de3fbee3d4 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/NoSuchCommandException.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/NoSuchCommandException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; /** * Exception used when a command is not found. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionParsingCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionParsingCommand.java index 8261eebfaa..fae15a26a5 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionParsingCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionParsingCommand.java @@ -18,6 +18,9 @@ package org.springframework.boot.cli.command; import java.util.Collection; +import org.springframework.boot.cli.command.options.OptionHandler; +import org.springframework.boot.cli.command.options.OptionHelp; + /** * Base class for a {@link Command} that parse options using an {@link OptionHandler}. * diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java index 2987a8449f..8da6dc2662 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java @@ -22,13 +22,13 @@ import java.util.Collections; import java.util.List; import java.util.Set; -import org.springframework.boot.cli.CommandRunner; -import org.springframework.boot.cli.Log; -import org.springframework.boot.cli.NoHelpCommandArgumentsException; -import org.springframework.boot.cli.NoSuchCommandException; import org.springframework.boot.cli.command.AbstractCommand; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.OptionHelp; +import org.springframework.boot.cli.command.CommandRunner; +import org.springframework.boot.cli.command.NoHelpCommandArgumentsException; +import org.springframework.boot.cli.command.NoSuchCommandException; +import org.springframework.boot.cli.command.options.OptionHelp; +import org.springframework.boot.cli.util.Log; /** * Internal {@link Command} used for 'help' requests. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java index 1a46e54098..1ee18232ef 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java @@ -20,11 +20,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.springframework.boot.cli.CommandRunner; -import org.springframework.boot.cli.Log; import org.springframework.boot.cli.command.AbstractCommand; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.OptionHelp; +import org.springframework.boot.cli.command.CommandRunner; +import org.springframework.boot.cli.command.options.OptionHelp; +import org.springframework.boot.cli.util.Log; /** * Internal {@link Command} to provide hints for shell auto-completion. Expects to be diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/VersionCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/VersionCommand.java index c58d1ac424..6efa3ac251 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/VersionCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/VersionCommand.java @@ -16,9 +16,9 @@ package org.springframework.boot.cli.command.core; -import org.springframework.boot.cli.Log; import org.springframework.boot.cli.command.AbstractCommand; import org.springframework.boot.cli.command.Command; +import org.springframework.boot.cli.util.Log; /** * {@link Command} to display the 'version' number. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/grab/GrabCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/grab/GrabCommand.java index 881d74eb73..df593b725a 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/grab/GrabCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/grab/GrabCommand.java @@ -21,12 +21,12 @@ import java.util.List; import joptsimple.OptionSet; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.CompilerOptionHandler; import org.springframework.boot.cli.command.OptionParsingCommand; -import org.springframework.boot.cli.command.SourceOptions; +import org.springframework.boot.cli.command.options.CompilerOptionHandler; +import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration; +import org.springframework.boot.cli.command.options.SourceOptions; import org.springframework.boot.cli.compiler.GroovyCompiler; import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration; -import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter; import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory; import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration; @@ -51,7 +51,7 @@ public class GrabCommand extends OptionParsingCommand { List repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); - GroovyCompilerConfiguration configuration = new GroovyCompilerConfigurationAdapter( + GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration( options, this, repositoryConfiguration); if (System.getProperty("grape.root") == null) { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/jar/JarCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/jar/JarCommand.java index ad0f8aecb7..a2e895e1dd 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/jar/JarCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/jar/JarCommand.java @@ -42,13 +42,13 @@ import org.codehaus.groovy.ast.expr.ConstantExpression; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.transform.ASTTransformation; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.CompilerOptionHandler; import org.springframework.boot.cli.command.OptionParsingCommand; -import org.springframework.boot.cli.command.SourceOptions; import org.springframework.boot.cli.command.jar.ResourceMatcher.MatchedResource; +import org.springframework.boot.cli.command.options.CompilerOptionHandler; +import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration; +import org.springframework.boot.cli.command.options.SourceOptions; import org.springframework.boot.cli.compiler.GroovyCompiler; import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration; -import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter; import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory; import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration; import org.springframework.boot.cli.jar.PackagedSpringApplicationLauncher; @@ -137,7 +137,7 @@ public class JarCommand extends OptionParsingCommand { private GroovyCompiler createCompiler(OptionSet options) { List repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); - GroovyCompilerConfiguration configuration = new GroovyCompilerConfigurationAdapter( + GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration( options, this, repositoryConfiguration); GroovyCompiler groovyCompiler = new GroovyCompiler(configuration); groovyCompiler.getAstTransformations().add(0, new GrabAnnotationTransform()); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CompilerOptionHandler.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/CompilerOptionHandler.java similarity index 97% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CompilerOptionHandler.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/CompilerOptionHandler.java index 159d43baac..d10786e57b 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CompilerOptionHandler.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/CompilerOptionHandler.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli.command; +package org.springframework.boot.cli.command.options; import joptsimple.OptionSpec; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java similarity index 97% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java index 45d18cecaf..b334c41561 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli.command; +package org.springframework.boot.cli.command.options; import groovy.lang.Closure; @@ -31,6 +31,8 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.springframework.boot.cli.command.OptionParsingCommand; + import joptsimple.BuiltinHelpFormatter; import joptsimple.HelpFormatter; import joptsimple.OptionDescriptor; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHelp.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHelp.java similarity index 94% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHelp.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHelp.java index fb62221870..ef4dec540d 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHelp.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHelp.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli.command; +package org.springframework.boot.cli.command.options; import java.util.Set; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfigurationAdapter.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionSetGroovyCompilerConfiguration.java similarity index 82% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfigurationAdapter.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionSetGroovyCompilerConfiguration.java index ae038e1fad..59a949c94e 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfigurationAdapter.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionSetGroovyCompilerConfiguration.java @@ -14,14 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.cli.compiler; +package org.springframework.boot.cli.command.options; import java.util.List; import joptsimple.OptionSet; import joptsimple.OptionSpec; -import org.springframework.boot.cli.command.CompilerOptionHandler; +import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration; +import org.springframework.boot.cli.compiler.GroovyCompilerScope; +import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory; import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration; /** @@ -30,7 +32,7 @@ import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration; * * @author Andy Wilkinson */ -public class GroovyCompilerConfigurationAdapter implements GroovyCompilerConfiguration { +public class OptionSetGroovyCompilerConfiguration implements GroovyCompilerConfiguration { private final OptionSet options; @@ -38,13 +40,13 @@ public class GroovyCompilerConfigurationAdapter implements GroovyCompilerConfigu private final List repositoryConfiguration; - protected GroovyCompilerConfigurationAdapter(OptionSet optionSet, + protected OptionSetGroovyCompilerConfiguration(OptionSet optionSet, CompilerOptionHandler compilerOptionHandler) { this(optionSet, compilerOptionHandler, RepositoryConfigurationFactory .createDefaultRepositoryConfiguration()); } - public GroovyCompilerConfigurationAdapter(OptionSet optionSet, + public OptionSetGroovyCompilerConfiguration(OptionSet optionSet, CompilerOptionHandler compilerOptionHandler, List repositoryConfiguration) { this.options = optionSet; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/SourceOptions.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java similarity index 98% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/command/SourceOptions.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java index c953af2dc7..553f34e113 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/SourceOptions.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli.command; +package org.springframework.boot.cli.command.options; import java.util.ArrayList; import java.util.Collections; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/RunCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/RunCommand.java index bb48672a87..859f26bd78 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/RunCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/RunCommand.java @@ -25,10 +25,10 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.CompilerOptionHandler; import org.springframework.boot.cli.command.OptionParsingCommand; -import org.springframework.boot.cli.command.SourceOptions; -import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter; +import org.springframework.boot.cli.command.options.CompilerOptionHandler; +import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration; +import org.springframework.boot.cli.command.options.SourceOptions; import org.springframework.boot.cli.compiler.GroovyCompilerScope; import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory; import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration; @@ -121,7 +121,7 @@ public class RunCommand extends OptionParsingCommand { * {@link SpringApplicationRunnerConfiguration}. */ private class SpringApplicationRunnerConfigurationAdapter extends - GroovyCompilerConfigurationAdapter implements + OptionSetGroovyCompilerConfiguration implements SpringApplicationRunnerConfiguration { public SpringApplicationRunnerConfigurationAdapter(OptionSet options, diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java index e169da6cc5..1e313f0455 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java @@ -30,9 +30,9 @@ import jline.console.completer.Completer; import jline.console.completer.FileNameCompleter; import jline.console.completer.StringsCompleter; -import org.springframework.boot.cli.Log; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.OptionHelp; +import org.springframework.boot.cli.command.options.OptionHelp; +import org.springframework.boot.cli.util.Log; /** * JLine {@link Completer} for Spring Boot {@link Command}s. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ForkProcessCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ForkProcessCommand.java index d50ccd59fe..6d655d058e 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ForkProcessCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ForkProcessCommand.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.List; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.OptionHelp; +import org.springframework.boot.cli.command.options.OptionHelp; import org.springframework.boot.cli.util.JavaExecutable; /** diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java index f30cc944ca..90a74a9104 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java @@ -31,9 +31,10 @@ import jline.console.ConsoleReader; import jline.console.completer.CandidateListCompletionHandler; import org.fusesource.jansi.AnsiRenderer.Code; -import org.springframework.boot.cli.CommandRunner; import org.springframework.boot.cli.command.Command; import org.springframework.boot.cli.command.CommandFactory; +import org.springframework.boot.cli.command.CommandRunner; +import org.springframework.boot.cli.command.core.HelpCommand; import org.springframework.boot.cli.command.core.VersionCommand; import org.springframework.util.StringUtils; @@ -83,7 +84,7 @@ public class Shell { private ShellCommandRunner createCommandRunner() { ShellCommandRunner runner = new ShellCommandRunner(); - runner.addHelpCommand(); + runner.addCommand(new HelpCommand(runner)); runner.addCommands(getCommands()); runner.addAliases("exit", "quit"); runner.addAliases("help", "?"); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellExitException.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellExitException.java index 983d5f1cf8..5d8f541e23 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellExitException.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellExitException.java @@ -16,7 +16,7 @@ package org.springframework.boot.cli.command.shell; -import org.springframework.boot.cli.CommandException; +import org.springframework.boot.cli.command.CommandException; /** * Exception used to stop the {@link Shell}. diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/test/TestCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/test/TestCommand.java index 28eacdf522..e333649984 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/test/TestCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/test/TestCommand.java @@ -19,10 +19,10 @@ package org.springframework.boot.cli.command.test; import joptsimple.OptionSet; import org.springframework.boot.cli.command.Command; -import org.springframework.boot.cli.command.CompilerOptionHandler; import org.springframework.boot.cli.command.OptionParsingCommand; -import org.springframework.boot.cli.command.SourceOptions; -import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter; +import org.springframework.boot.cli.command.options.CompilerOptionHandler; +import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration; +import org.springframework.boot.cli.command.options.SourceOptions; /** * {@link Command} to run a groovy test script or scripts. @@ -60,7 +60,7 @@ public class TestCommand extends OptionParsingCommand { * {@link TestRunnerConfiguration}. */ private class TestRunnerConfigurationAdapter extends - GroovyCompilerConfigurationAdapter implements TestRunnerConfiguration { + OptionSetGroovyCompilerConfiguration implements TestRunnerConfiguration { public TestRunnerConfigurationAdapter(OptionSet options, CompilerOptionHandler optionHandler) { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/DependencyAutoConfigurationTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyAutoConfigurationTransformation.java similarity index 100% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/DependencyAutoConfigurationTransformation.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyAutoConfigurationTransformation.java diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/GroovyBeansTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyBeansTransformation.java similarity index 100% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/GroovyBeansTransformation.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyBeansTransformation.java diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/ResolveDependencyCoordinatesTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java similarity index 100% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/ResolveDependencyCoordinatesTransformation.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/Log.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/Log.java similarity index 96% rename from spring-boot-cli/src/main/java/org/springframework/boot/cli/Log.java rename to spring-boot-cli/src/main/java/org/springframework/boot/cli/util/Log.java index 182a019fec..30b35d1050 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/Log.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/Log.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.util; /** * Simple logger used by the CLI. diff --git a/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.command.CommandFactory b/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.command.CommandFactory index 3a57546dd1..c03475a0c3 100644 --- a/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.command.CommandFactory +++ b/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.command.CommandFactory @@ -1 +1 @@ -org.springframework.boot.cli.command.DefaultCommandFactory +org.springframework.boot.cli.DefaultCommandFactory diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/CommandRunnerIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerIntegrationTests.java similarity index 94% rename from spring-boot-cli/src/test/java/org/springframework/boot/cli/CommandRunnerIntegrationTests.java rename to spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerIntegrationTests.java index cc64ecee63..0706bb1c51 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/CommandRunnerIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerIntegrationTests.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; import org.junit.Rule; import org.junit.Test; +import org.springframework.boot.cli.command.CommandRunner; import org.springframework.boot.cli.command.run.RunCommand; import org.springframework.boot.cli.util.OutputCapture; diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/CommandRunnerTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java similarity index 95% rename from spring-boot-cli/src/test/java/org/springframework/boot/cli/CommandRunnerTests.java rename to spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java index 31da06759c..684e2dac93 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/CommandRunnerTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.cli; +package org.springframework.boot.cli.command; import java.util.EnumSet; import java.util.Set; @@ -26,7 +26,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.springframework.boot.cli.command.Command; +import org.springframework.boot.cli.command.core.HelpCommand; +import org.springframework.boot.cli.command.core.HintCommand; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; @@ -95,8 +96,8 @@ public class CommandRunnerTests { given(this.regularCommand.getName()).willReturn("command"); given(this.regularCommand.getDescription()).willReturn("A regular command"); this.commandRunner.addCommand(this.regularCommand); - this.commandRunner.addHelpCommand(); - this.commandRunner.addHintCommand(); + this.commandRunner.addCommand(new HelpCommand(this.commandRunner)); + this.commandRunner.addCommand(new HintCommand(this.commandRunner)); } @Test diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/OptionParsingCommandTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/OptionParsingCommandTests.java index dc07ed4e3b..1cc2ef406b 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/OptionParsingCommandTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/OptionParsingCommandTests.java @@ -17,6 +17,7 @@ package org.springframework.boot.cli.command; import org.junit.Test; +import org.springframework.boot.cli.command.options.OptionHandler; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertThat; diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/transformation/ResolveDependencyCoordinatesTransformationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java similarity index 100% rename from spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/transformation/ResolveDependencyCoordinatesTransformationTests.java rename to spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformationTests.java