[bs-136] Add 'spring run --local ...'
Use this to download and cache the dependencies to ./grapes. Good for running on virgin system (like PaaS). [Fixes #50511883] Add --local to RunCommand
This commit is contained in:
parent
35a376b403
commit
a112717fd3
|
|
@ -53,6 +53,8 @@ public class RunCommand extends OptionParsingCommand {
|
||||||
|
|
||||||
private OptionSpec<Void> quietOption;
|
private OptionSpec<Void> quietOption;
|
||||||
|
|
||||||
|
private OptionSpec<Void> localOption;
|
||||||
|
|
||||||
private BootstrapRunner runner;
|
private BootstrapRunner runner;
|
||||||
|
|
||||||
public RunCommand() {
|
public RunCommand() {
|
||||||
|
|
@ -75,6 +77,8 @@ public class RunCommand extends OptionParsingCommand {
|
||||||
OptionParser parser = new OptionParser();
|
OptionParser parser = new OptionParser();
|
||||||
this.watchOption = parser
|
this.watchOption = parser
|
||||||
.accepts("watch", "Watch the specified file for changes");
|
.accepts("watch", "Watch the specified file for changes");
|
||||||
|
this.localOption = parser.accepts("local",
|
||||||
|
"Accumulate the dependencies in a local folder (./grapes)");
|
||||||
this.editOption = parser.acceptsAll(asList("edit", "e"),
|
this.editOption = parser.acceptsAll(asList("edit", "e"),
|
||||||
"Open the file with the default system editor");
|
"Open the file with the default system editor");
|
||||||
this.noGuessImportsOption = parser.accepts("no-guess-imports",
|
this.noGuessImportsOption = parser.accepts("no-guess-imports",
|
||||||
|
|
@ -99,6 +103,9 @@ public class RunCommand extends OptionParsingCommand {
|
||||||
|
|
||||||
BootstrapRunnerConfiguration configuration = new BootstrapRunnerConfigurationAdapter(
|
BootstrapRunnerConfiguration configuration = new BootstrapRunnerConfigurationAdapter(
|
||||||
options);
|
options);
|
||||||
|
if (configuration.isLocal() && System.getProperty("grape.root") == null) {
|
||||||
|
System.setProperty("grape.root", ".");
|
||||||
|
}
|
||||||
this.runner = new BootstrapRunner(configuration, files,
|
this.runner = new BootstrapRunner(configuration, files,
|
||||||
args.toArray(new String[args.size()]));
|
args.toArray(new String[args.size()]));
|
||||||
this.runner.compileAndRun();
|
this.runner.compileAndRun();
|
||||||
|
|
@ -153,6 +160,11 @@ public class RunCommand extends OptionParsingCommand {
|
||||||
return !this.options.has(RunCommand.this.noGuessDependenciesOption);
|
return !this.options.has(RunCommand.this.noGuessDependenciesOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLocal() {
|
||||||
|
return this.options.has(RunCommand.this.localOption);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Level getLogLevel() {
|
public Level getLogLevel() {
|
||||||
if (this.options.has(RunCommand.this.verboseOption)) {
|
if (this.options.has(RunCommand.this.verboseOption)) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
|
||||||
@Override
|
@Override
|
||||||
public void applyImports(ImportCustomizer imports) {
|
public void applyImports(ImportCustomizer imports) {
|
||||||
imports.addStarImports("org.springframework.web.bind.annotation",
|
imports.addStarImports("org.springframework.web.bind.annotation",
|
||||||
"org.springframework.web.servlet.config.annotation");
|
"org.springframework.web.servlet.config.annotation",
|
||||||
|
"org.springframework.http");
|
||||||
imports.addStaticImport(
|
imports.addStaticImport(
|
||||||
"org.springframework.bootstrap.cli.template.GroovyTemplate", "template");
|
"org.springframework.bootstrap.cli.template.GroovyTemplate", "template");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,9 @@ public interface BootstrapRunnerConfiguration extends GroovyCompilerConfiguratio
|
||||||
*/
|
*/
|
||||||
Level getLogLevel();
|
Level getLogLevel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the dependencies should be cached locally
|
||||||
|
*/
|
||||||
|
boolean isLocal();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ mkdir -p "${TARGETDIR%/}"
|
||||||
|
|
||||||
CLASSPATH="${CLASSPATH}":"${SPRING_BIN}":"${TARGETDIR}"
|
CLASSPATH="${CLASSPATH}":"${SPRING_BIN}":"${TARGETDIR}"
|
||||||
|
|
||||||
for f in "${SPRING_HOME}"/*.jar "${SPRING_HOME}"/lib/*.jar "${SPRING_HOME}"/classes; do
|
for f in "${SPRING_HOME}"/classes "${SPRING_HOME}"/*.jar "${SPRING_HOME}"/lib/*.jar; do
|
||||||
[ -f $f ] && CLASSPATH="${CLASSPATH}":$f
|
[ -f $f ] && CLASSPATH="${CLASSPATH}":$f
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue