Package restructure
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<includes>
|
||||
<include>org.springframework.zero:spring-zero-cli:jar:*</include>
|
||||
<include>org.springframework.zero:spring-cli:jar:*</include>
|
||||
</includes>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
</dependencySet>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
/**
|
||||
* A single command that can be run from the CLI.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ServiceLoader;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
/**
|
||||
* Simple logger used by the CLI.
|
||||
@@ -14,20 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
/**
|
||||
* Exception thrown when an unknown command is specified.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class NoSuchCommandException extends SpringZeroCliException {
|
||||
class NoSuchCommandException extends SpringCliException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NoSuchCommandException(String name) {
|
||||
super(String.format("%1$s: '%2$s' is not a valid command. See '%1$s --help'.",
|
||||
SpringZeroCli.CLI_APP, name));
|
||||
SpringCli.CLI_APP, name));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -24,9 +24,9 @@ import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Spring Zero Command Line Interface. This is the main entry-point for the Spring Zero
|
||||
* command line application. This class will parse input arguments and delegate to a
|
||||
* suitable {@link Command} implementation based on the first argument.
|
||||
* Spring Command Line Interface. This is the main entry-point for the Spring command line
|
||||
* application. This class will parse input arguments and delegate to a suitable
|
||||
* {@link Command} implementation based on the first argument.
|
||||
*
|
||||
* <p>
|
||||
* The '-d' and '--debug' switches are handled by this class, however, most argument
|
||||
@@ -34,22 +34,22 @@ import java.util.Set;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @see #main(String...)
|
||||
* @see SpringZeroCliException
|
||||
* @see SpringCliException
|
||||
* @see Command
|
||||
*/
|
||||
public class SpringZeroCli {
|
||||
public class SpringCli {
|
||||
|
||||
public static final String CLI_APP = "spring";
|
||||
|
||||
private static final Set<SpringZeroCliException.Option> NO_EXCEPTION_OPTIONS = EnumSet
|
||||
.noneOf(SpringZeroCliException.Option.class);
|
||||
private static final Set<SpringCliException.Option> NO_EXCEPTION_OPTIONS = EnumSet
|
||||
.noneOf(SpringCliException.Option.class);
|
||||
|
||||
private List<Command> commands;
|
||||
|
||||
/**
|
||||
* Create a new {@link SpringZeroCli} implementation with the default set of commands.
|
||||
* Create a new {@link SpringCli} implementation with the default set of commands.
|
||||
*/
|
||||
public SpringZeroCli() {
|
||||
public SpringCli() {
|
||||
setCommands(ServiceLoader.load(CommandFactory.class, getClass().getClassLoader()));
|
||||
}
|
||||
|
||||
@@ -97,17 +97,17 @@ public class SpringZeroCli {
|
||||
}
|
||||
|
||||
private int handleError(boolean debug, Exception ex) {
|
||||
Set<SpringZeroCliException.Option> options = NO_EXCEPTION_OPTIONS;
|
||||
if (ex instanceof SpringZeroCliException) {
|
||||
options = ((SpringZeroCliException) ex).getOptions();
|
||||
Set<SpringCliException.Option> options = NO_EXCEPTION_OPTIONS;
|
||||
if (ex instanceof SpringCliException) {
|
||||
options = ((SpringCliException) ex).getOptions();
|
||||
}
|
||||
if (!(ex instanceof NoHelpCommandArgumentsException)) {
|
||||
errorMessage(ex.getMessage());
|
||||
}
|
||||
if (options.contains(SpringZeroCliException.Option.SHOW_USAGE)) {
|
||||
if (options.contains(SpringCliException.Option.SHOW_USAGE)) {
|
||||
showUsage();
|
||||
}
|
||||
if (debug || options.contains(SpringZeroCliException.Option.STACK_TRACE)) {
|
||||
if (debug || options.contains(SpringCliException.Option.STACK_TRACE)) {
|
||||
printStackTrace(ex);
|
||||
}
|
||||
return 1;
|
||||
@@ -189,7 +189,7 @@ public class SpringZeroCli {
|
||||
throw new NoHelpCommandArgumentsException();
|
||||
}
|
||||
String commandName = args[0];
|
||||
for (Command command : SpringZeroCli.this.commands) {
|
||||
for (Command command : SpringCli.this.commands) {
|
||||
if (command.getName().equals(commandName)) {
|
||||
Log.info(CLI_APP + " " + command.getName() + " - "
|
||||
+ command.getDescription());
|
||||
@@ -230,7 +230,7 @@ public class SpringZeroCli {
|
||||
|
||||
}
|
||||
|
||||
static class NoHelpCommandArgumentsException extends SpringZeroCliException {
|
||||
static class NoHelpCommandArgumentsException extends SpringCliException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -240,7 +240,7 @@ public class SpringZeroCli {
|
||||
|
||||
}
|
||||
|
||||
static class NoArgumentsException extends SpringZeroCliException {
|
||||
static class NoArgumentsException extends SpringCliException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -251,7 +251,7 @@ public class SpringZeroCli {
|
||||
* @param args CLI arguments
|
||||
*/
|
||||
public static void main(String... args) {
|
||||
int exitCode = new SpringZeroCli().runAndHandleErrors(args);
|
||||
int exitCode = new SpringCli().runAndHandleErrors(args);
|
||||
if (exitCode != 0) {
|
||||
System.exit(exitCode);
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -23,41 +23,41 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Runtime exception wrapper that defines additional {@link Option}s that are understood
|
||||
* by the {@link SpringZeroCli}.
|
||||
* by the {@link SpringCli}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class SpringZeroCliException extends RuntimeException {
|
||||
public class SpringCliException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
private final EnumSet<Option> options;
|
||||
|
||||
/**
|
||||
* Create a new {@link SpringZeroCliException} with the specified options.
|
||||
* Create a new {@link SpringCliException} with the specified options.
|
||||
* @param options the exception options
|
||||
*/
|
||||
public SpringZeroCliException(Option... options) {
|
||||
public SpringCliException(Option... options) {
|
||||
this.options = asEnumSet(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link SpringZeroCliException} with the specified options.
|
||||
* Create a new {@link SpringCliException} with the specified options.
|
||||
* @param message the exception message to display to the user
|
||||
* @param options the exception options
|
||||
*/
|
||||
public SpringZeroCliException(String message, Option... options) {
|
||||
public SpringCliException(String message, Option... options) {
|
||||
super(message);
|
||||
this.options = asEnumSet(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link SpringZeroCliException} with the specified options.
|
||||
* Create a new {@link SpringCliException} with the specified options.
|
||||
* @param message the exception message to display to the user
|
||||
* @param cause the underlying cause
|
||||
* @param options the exception options
|
||||
*/
|
||||
public SpringZeroCliException(String message, Throwable cause, Option... options) {
|
||||
public SpringCliException(String message, Throwable cause, Option... options) {
|
||||
super(message, cause);
|
||||
this.options = asEnumSet(options);
|
||||
}
|
||||
@@ -70,14 +70,14 @@ public class SpringZeroCliException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns options a set of options that are understood by the {@link SpringZeroCli}.
|
||||
* Returns options a set of options that are understood by the {@link SpringCli}.
|
||||
*/
|
||||
public Set<Option> getOptions() {
|
||||
return Collections.unmodifiableSet(this.options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specific options understood by the {@link SpringZeroCli}.
|
||||
* Specific options understood by the {@link SpringCli}.
|
||||
*/
|
||||
public static enum Option {
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.cli.Command;
|
||||
|
||||
/**
|
||||
* Abstract {@link Command} implementation.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -24,8 +24,8 @@ import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import org.apache.ivy.util.FileUtil;
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.zero.cli.Log;
|
||||
import org.springframework.cli.Command;
|
||||
import org.springframework.cli.Log;
|
||||
|
||||
/**
|
||||
* {@link Command} to 'clean' up grapes, removing cached dependencies and forcing a
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.cli.Command;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.zero.cli.CommandFactory;
|
||||
import org.springframework.cli.Command;
|
||||
import org.springframework.cli.CommandFactory;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link CommandFactory}.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.cli.Command;
|
||||
|
||||
/**
|
||||
* Base class for a {@link Command} that pare options using an {@link OptionHandler}.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
@@ -25,9 +25,9 @@ import java.util.logging.Level;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.zero.cli.runner.SpringZeroRunner;
|
||||
import org.springframework.zero.cli.runner.SpringZeroRunnerConfiguration;
|
||||
import org.springframework.cli.Command;
|
||||
import org.springframework.cli.runner.SpringApplicationRunner;
|
||||
import org.springframework.cli.runner.SpringApplicationRunnerConfiguration;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
@@ -36,7 +36,7 @@ import static java.util.Arrays.asList;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @see SpringZeroRunner
|
||||
* @see SpringApplicationRunner
|
||||
*/
|
||||
public class RunCommand extends OptionParsingCommand {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class RunCommand extends OptionParsingCommand {
|
||||
|
||||
private OptionSpec<Void> localOption;
|
||||
|
||||
private SpringZeroRunner runner;
|
||||
private SpringApplicationRunner runner;
|
||||
|
||||
@Override
|
||||
protected void options() {
|
||||
@@ -99,12 +99,12 @@ public class RunCommand extends OptionParsingCommand {
|
||||
Desktop.getDesktop().edit(files[0]);
|
||||
}
|
||||
|
||||
SpringZeroRunnerConfiguration configuration = new SpringZeroRunnerConfigurationAdapter(
|
||||
SpringApplicationRunnerConfiguration configuration = new SpringApplicationRunnerConfigurationAdapter(
|
||||
options);
|
||||
if (configuration.isLocal() && System.getProperty("grape.root") == null) {
|
||||
System.setProperty("grape.root", ".");
|
||||
}
|
||||
this.runner = new SpringZeroRunner(configuration, files,
|
||||
this.runner = new SpringApplicationRunner(configuration, files,
|
||||
args.toArray(new String[args.size()]));
|
||||
this.runner.compileAndRun();
|
||||
}
|
||||
@@ -132,14 +132,14 @@ public class RunCommand extends OptionParsingCommand {
|
||||
|
||||
/**
|
||||
* Simple adapter class to present the {@link OptionSet} as a
|
||||
* {@link SpringZeroRunnerConfiguration}.
|
||||
* {@link SpringApplicationRunnerConfiguration}.
|
||||
*/
|
||||
private class SpringZeroRunnerConfigurationAdapter implements
|
||||
SpringZeroRunnerConfiguration {
|
||||
private class SpringApplicationRunnerConfigurationAdapter implements
|
||||
SpringApplicationRunnerConfiguration {
|
||||
|
||||
private OptionSet options;
|
||||
|
||||
public SpringZeroRunnerConfigurationAdapter(OptionSet options) {
|
||||
public SpringApplicationRunnerConfigurationAdapter(OptionSet options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
import groovy.lang.GroovyObjectSupport;
|
||||
@@ -30,9 +30,9 @@ import joptsimple.OptionParser;
|
||||
|
||||
import org.apache.ivy.util.FileUtil;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.zero.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.zero.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.cli.Command;
|
||||
import org.springframework.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.cli.compiler.GroovyCompilerConfiguration;
|
||||
|
||||
/**
|
||||
* {@link Command} to run a Groovy script.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import groovy.lang.Mixin;
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.codehaus.groovy.control.SourceUnit;
|
||||
import org.codehaus.groovy.control.customizers.CompilationCustomizer;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.cli.Command;
|
||||
|
||||
/**
|
||||
* Customizer for the compilation of CLI commands.
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.cli.Command;
|
||||
|
||||
/**
|
||||
* {@link Command} to display the 'version' number.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler;
|
||||
package org.springframework.cli.compiler;
|
||||
|
||||
import org.codehaus.groovy.ast.AnnotatedNode;
|
||||
import org.codehaus.groovy.ast.AnnotationNode;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler;
|
||||
package org.springframework.cli.compiler;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler;
|
||||
package org.springframework.cli.compiler;
|
||||
|
||||
import groovy.grape.Grape;
|
||||
import groovy.lang.Grapes;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler;
|
||||
package org.springframework.cli.compiler;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler;
|
||||
package org.springframework.cli.compiler;
|
||||
|
||||
import groovy.grape.Grape;
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
@@ -45,7 +45,7 @@ import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
* {@link GroovyClassLoader#parseClass(File)} with the following additional features:
|
||||
* <ul>
|
||||
* <li>{@link CompilerAutoConfiguration} strategies will be read from
|
||||
* <code>META-INF/services/org.springframework.zero.cli.compiler.CompilerAutoConfiguration</code>
|
||||
* <code>META-INF/services/org.springframework.cli.compiler.CompilerAutoConfiguration</code>
|
||||
* (per the standard java {@link ServiceLoader} contract) and applied during compilation</li>
|
||||
*
|
||||
* <li>Multiple classes can be returned if the Groovy source defines more than one Class</li>
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler;
|
||||
package org.springframework.cli.compiler;
|
||||
|
||||
/**
|
||||
* Configuration for the {@link GroovyCompiler}.
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler.autoconfigure;
|
||||
package org.springframework.cli.compiler.autoconfigure;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
import org.springframework.zero.cli.compiler.AstUtils;
|
||||
import org.springframework.zero.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.zero.cli.compiler.DependencyCustomizer;
|
||||
import org.springframework.cli.compiler.AstUtils;
|
||||
import org.springframework.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Batch.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler.autoconfigure;
|
||||
package org.springframework.cli.compiler.autoconfigure;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
|
||||
@@ -24,23 +24,24 @@ import org.codehaus.groovy.classgen.GeneratorContext;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.codehaus.groovy.control.SourceUnit;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
import org.springframework.zero.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.zero.cli.compiler.DependencyCustomizer;
|
||||
import org.springframework.zero.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.cli.compiler.DependencyCustomizer;
|
||||
import org.springframework.cli.compiler.GroovyCompilerConfiguration;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Zero.
|
||||
* {@link CompilerAutoConfiguration} for Spring.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class SpringZeroCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
public class SpringCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.zero.SpringApplication")
|
||||
.add("org.springframework.zero", "spring-zero-autoconfigure",
|
||||
"0.5.0.BUILD-SNAPSHOT");
|
||||
dependencies.ifAnyMissingClasses(
|
||||
"org.springframework.bootstrap.SpringApplication").add(
|
||||
"org.springframework.zero", "spring-autoconfigure",
|
||||
"0.5.0.BUILD-SNAPSHOT");
|
||||
dependencies.ifAnyResourcesPresent("logback.xml").add("ch.qos.logback",
|
||||
"logback-classic", "1.0.7");
|
||||
dependencies.ifNotAdded("cg.qos.logback", "logback-classic")
|
||||
@@ -75,8 +76,8 @@ public class SpringZeroCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
"org.springframework.context.MessageSource",
|
||||
"org.springframework.core.annotation.Order",
|
||||
"org.springframework.core.io.ResourceLoader",
|
||||
"org.springframework.zero.CommandLineRunner",
|
||||
"org.springframework.zero.context.annotation.EnableAutoConfiguration");
|
||||
"org.springframework.bootstrap.CommandLineRunner",
|
||||
"org.springframework.autoconfigure.EnableAutoConfiguration");
|
||||
imports.addStarImports("org.springframework.stereotype");
|
||||
}
|
||||
|
||||
@@ -92,10 +93,8 @@ public class SpringZeroCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
ClassNode classNode) {
|
||||
if (!hasEnableAutoConfigureAnnotation(classNode)) {
|
||||
try {
|
||||
Class<?> annotationClass = source
|
||||
.getClassLoader()
|
||||
.loadClass(
|
||||
"org.springframework.zero.context.annotation.EnableAutoConfiguration");
|
||||
Class<?> annotationClass = source.getClassLoader().loadClass(
|
||||
"org.springframework.autoconfigure.EnableAutoConfiguration");
|
||||
AnnotationNode annotationNode = new AnnotationNode(new ClassNode(
|
||||
annotationClass));
|
||||
classNode.addAnnotation(annotationNode);
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler.autoconfigure;
|
||||
package org.springframework.cli.compiler.autoconfigure;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
@@ -24,9 +24,9 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
import org.springframework.zero.cli.compiler.AstUtils;
|
||||
import org.springframework.zero.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.zero.cli.compiler.DependencyCustomizer;
|
||||
import org.springframework.cli.compiler.AstUtils;
|
||||
import org.springframework.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Integration.
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.compiler.autoconfigure;
|
||||
package org.springframework.cli.compiler.autoconfigure;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
import org.springframework.zero.cli.compiler.AstUtils;
|
||||
import org.springframework.zero.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.zero.cli.compiler.DependencyCustomizer;
|
||||
import org.springframework.cli.compiler.AstUtils;
|
||||
import org.springframework.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring MVC.
|
||||
@@ -58,7 +58,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
|
||||
imports.addStarImports("org.springframework.web.bind.annotation",
|
||||
"org.springframework.web.servlet.config.annotation",
|
||||
"org.springframework.http");
|
||||
imports.addStaticImport("org.springframework.zero.cli.template.GroovyTemplate",
|
||||
imports.addStaticImport("org.springframework.cli.template.GroovyTemplate",
|
||||
"template");
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.runner;
|
||||
package org.springframework.cli.runner;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.springframework.zero.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.cli.compiler.GroovyCompiler;
|
||||
|
||||
/**
|
||||
* Compiles Groovy code running the resulting classes using a {@code SpringApplication}.
|
||||
@@ -31,11 +31,11 @@ import org.springframework.zero.cli.compiler.GroovyCompiler;
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SpringZeroRunner {
|
||||
public class SpringApplicationRunner {
|
||||
|
||||
// FIXME logging
|
||||
|
||||
private SpringZeroRunnerConfiguration configuration;
|
||||
private SpringApplicationRunnerConfiguration configuration;
|
||||
|
||||
private final File[] files;
|
||||
|
||||
@@ -48,13 +48,14 @@ public class SpringZeroRunner {
|
||||
private FileWatchThread fileWatchThread;
|
||||
|
||||
/**
|
||||
* Create a new {@link SpringZeroRunner} instance.
|
||||
* Create a new {@link SpringApplicationRunner} instance.
|
||||
* @param configuration the configuration
|
||||
* @param files the files to compile/watch
|
||||
* @param args input arguments
|
||||
*/
|
||||
public SpringZeroRunner(final SpringZeroRunnerConfiguration configuration,
|
||||
File[] files, String... args) {
|
||||
public SpringApplicationRunner(
|
||||
final SpringApplicationRunnerConfiguration configuration, File[] files,
|
||||
String... args) {
|
||||
this.configuration = configuration;
|
||||
this.files = files.clone();
|
||||
this.args = args.clone();
|
||||
@@ -129,11 +130,11 @@ public class SpringZeroRunner {
|
||||
try {
|
||||
// User reflection to load and call Spring
|
||||
Class<?> application = getContextClassLoader().loadClass(
|
||||
"org.springframework.zero.SpringApplication");
|
||||
"org.springframework.bootstrap.SpringApplication");
|
||||
Method method = application.getMethod("run", Object[].class,
|
||||
String[].class);
|
||||
this.applicationContext = method.invoke(null, this.sources,
|
||||
SpringZeroRunner.this.args);
|
||||
SpringApplicationRunner.this.args);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -171,7 +172,7 @@ public class SpringZeroRunner {
|
||||
|
||||
public FileWatchThread() {
|
||||
this.previous = 0;
|
||||
for (File file : SpringZeroRunner.this.files) {
|
||||
for (File file : SpringApplicationRunner.this.files) {
|
||||
long current = file.lastModified();
|
||||
if (current > this.previous) {
|
||||
this.previous = current;
|
||||
@@ -185,7 +186,7 @@ public class SpringZeroRunner {
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
|
||||
for (File file : SpringZeroRunner.this.files) {
|
||||
for (File file : SpringApplicationRunner.this.files) {
|
||||
long current = file.lastModified();
|
||||
if (this.previous < current) {
|
||||
this.previous = current;
|
||||
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.runner;
|
||||
package org.springframework.cli.runner;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.springframework.zero.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.cli.compiler.GroovyCompilerConfiguration;
|
||||
|
||||
/**
|
||||
* Configuration for the {@link SpringZeroRunner}.
|
||||
* Configuration for the {@link SpringApplicationRunner}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public interface SpringZeroRunnerConfiguration extends GroovyCompilerConfiguration {
|
||||
public interface SpringApplicationRunnerConfiguration extends GroovyCompilerConfiguration {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the source file should be monitored for changes and
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.template;
|
||||
package org.springframework.cli.template;
|
||||
|
||||
import groovy.text.GStringTemplateEngine;
|
||||
import groovy.text.Template;
|
||||
@@ -0,0 +1 @@
|
||||
org.springframework.cli.command.DefaultCommandFactory
|
||||
@@ -0,0 +1,5 @@
|
||||
org.springframework.cli.compiler.autoconfigure.SpringCompilerAutoConfiguration
|
||||
org.springframework.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfiguration
|
||||
org.springframework.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration
|
||||
org.springframework.cli.compiler.autoconfigure.SpringIntegrationCompilerAutoConfiguration
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
org.springframework.zero.cli.command.DefaultCommandFactory
|
||||
@@ -1,5 +0,0 @@
|
||||
org.springframework.zero.cli.compiler.autoconfigure.SpringZeroCompilerAutoConfiguration
|
||||
org.springframework.zero.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfiguration
|
||||
org.springframework.zero.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration
|
||||
org.springframework.zero.cli.compiler.autoconfigure.SpringIntegrationCompilerAutoConfiguration
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
@@ -30,7 +30,7 @@ import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.zero.cli.command.RunCommand;
|
||||
import org.springframework.cli.command.RunCommand;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -85,7 +85,7 @@ public class SampleIntegrationTests {
|
||||
|
||||
@BeforeClass
|
||||
public static void clean() {
|
||||
// SpringZeroCli.main("clean");
|
||||
// SpringCli.main("clean");
|
||||
// System.setProperty("ivy.message.logger.level", "3");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.zero.cli;
|
||||
package org.springframework.cli;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
@@ -10,11 +10,11 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.zero.cli.Command;
|
||||
import org.springframework.zero.cli.NoSuchCommandException;
|
||||
import org.springframework.zero.cli.SpringZeroCli;
|
||||
import org.springframework.zero.cli.SpringZeroCli.NoArgumentsException;
|
||||
import org.springframework.zero.cli.SpringZeroCli.NoHelpCommandArgumentsException;
|
||||
import org.springframework.cli.Command;
|
||||
import org.springframework.cli.NoSuchCommandException;
|
||||
import org.springframework.cli.SpringCli;
|
||||
import org.springframework.cli.SpringCli.NoArgumentsException;
|
||||
import org.springframework.cli.SpringCli.NoHelpCommandArgumentsException;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -23,17 +23,17 @@ import static org.mockito.BDDMockito.willThrow;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringZeroCli}.
|
||||
* Tests for {@link SpringCli}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SpringZeroCliTests {
|
||||
public class SpringCliTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private SpringZeroCli cli;
|
||||
private SpringCli cli;
|
||||
|
||||
@Mock
|
||||
private Command regularCommand;
|
||||
@@ -43,23 +43,23 @@ public class SpringZeroCliTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.cli = new SpringZeroCli() {
|
||||
this.cli = new SpringCli() {
|
||||
|
||||
@Override
|
||||
protected void showUsage() {
|
||||
SpringZeroCliTests.this.calls.add(Call.SHOW_USAGE);
|
||||
SpringCliTests.this.calls.add(Call.SHOW_USAGE);
|
||||
super.showUsage();
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void errorMessage(String message) {
|
||||
SpringZeroCliTests.this.calls.add(Call.ERROR_MESSAGE);
|
||||
SpringCliTests.this.calls.add(Call.ERROR_MESSAGE);
|
||||
super.errorMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void printStackTrace(Exception ex) {
|
||||
SpringZeroCliTests.this.calls.add(Call.PRINT_STACK_TRACE);
|
||||
SpringCliTests.this.calls.add(Call.PRINT_STACK_TRACE);
|
||||
super.printStackTrace(ex);
|
||||
}
|
||||
};
|
||||
@@ -14,12 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.zero.cli.command;
|
||||
package org.springframework.cli.command;
|
||||
|
||||
import groovy.lang.GroovyObjectSupport;
|
||||
import groovy.lang.Script;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cli.command.OptionHandler;
|
||||
import org.springframework.cli.command.ScriptCommand;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
@@ -1,5 +1,5 @@
|
||||
def run = { msg ->
|
||||
org.springframework.zero.cli.command.ScriptCommandTests.executed = true
|
||||
org.springframework.cli.command.ScriptCommandTests.executed = true
|
||||
println "Hello ${msg}"
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestCommand implements Command {
|
||||
String usageHelp = "Not very useful"
|
||||
|
||||
void run(String... args) {
|
||||
org.springframework.zero.cli.command.ScriptCommandTests.executed = true
|
||||
org.springframework.cli.command.ScriptCommandTests.executed = true
|
||||
println "Hello ${args[0]}"
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class TestCommand extends OptionHandler {
|
||||
void run(OptionSet options) {
|
||||
// Demonstrate use of Grape.grab to load dependencies before running
|
||||
println "Clean : " + Git.open(".." as File).status().call().isClean()
|
||||
org.springframework.zero.cli.command.ScriptCommandTests.executed = true
|
||||
org.springframework.cli.command.ScriptCommandTests.executed = true
|
||||
println "Hello ${options.nonOptionArguments()}: ${options.has('foo')}"
|
||||
}
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@ void options() {
|
||||
option "foo", "Foo set"
|
||||
}
|
||||
|
||||
org.springframework.zero.cli.command.ScriptCommandTests.executed = true
|
||||
org.springframework.cli.command.ScriptCommandTests.executed = true
|
||||
println "Hello ${options.nonOptionArguments()}: ${options.has('foo')}"
|
||||
|
||||
@@ -4,7 +4,7 @@ class TestCommand implements Runnable {
|
||||
this.msg = msg
|
||||
}
|
||||
void run() {
|
||||
org.springframework.zero.cli.command.ScriptCommandTests.executed = true
|
||||
org.springframework.cli.command.ScriptCommandTests.executed = true
|
||||
println "Hello ${msg}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ options {
|
||||
option "bar", "Bar has an argument of type int" withOptionalArg() ofType Integer
|
||||
}
|
||||
|
||||
org.springframework.zero.cli.command.ScriptCommandTests.executed = true
|
||||
org.springframework.cli.command.ScriptCommandTests.executed = true
|
||||
println "Hello ${options.nonOptionArguments()}: ${options.has('foo')} ${options.valueOf('bar')}"
|
||||
|
||||
@@ -4,6 +4,7 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
|
||||
|
||||
log4j.category.org.springframework.zero=DEBUG
|
||||
log4j.category.org.springframework.autoconfigure=DEBUG
|
||||
log4j.category.org.springframework.bootstrap=DEBUG
|
||||
#log4j.category.org.springframework.integration.dsl=DEBUG
|
||||
#log4j.category.org.springframework.amqp=DEBUG
|
||||
|
||||
Reference in New Issue
Block a user