diff --git a/spring-boot-cli-grape/src/main/java/org/springframework/boot/cli/compiler/AetherGrapeEngine.java b/spring-boot-cli-grape/src/main/java/org/springframework/boot/cli/compiler/AetherGrapeEngine.java index f03a956a7a..d608fd3514 100644 --- a/spring-boot-cli-grape/src/main/java/org/springframework/boot/cli/compiler/AetherGrapeEngine.java +++ b/spring-boot-cli-grape/src/main/java/org/springframework/boot/cli/compiler/AetherGrapeEngine.java @@ -141,8 +141,18 @@ public class AetherGrapeEngine implements GrapeEngine { } }); - LocalRepository localRepo = new LocalRepository(new File( - System.getProperty("user.home"), ".m2/repository")); + String grapeRootProperty = System.getProperty("grape.root"); + File root; + if (grapeRootProperty != null && grapeRootProperty.trim().length() > 0) { + root = new File(grapeRootProperty); + + } + else { + root = new File(System.getProperty("user.home"), ".m2"); + } + + LocalRepository localRepo = new LocalRepository(new File(root, "repository")); + repositorySystemSession.setLocalRepositoryManager(this.repositorySystem .newLocalRepositoryManager(repositorySystemSession, localRepo)); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/RunCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/RunCommand.java index 1f5f9b1376..f5653dd607 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/RunCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/RunCommand.java @@ -76,7 +76,7 @@ public class RunCommand extends OptionParsingCommand { protected void options() { this.watchOption = option("watch", "Watch the specified file for changes"); this.localOption = option("local", - "Accumulate the dependencies in a local folder (./grapes)"); + "Accumulate the dependencies in a local folder (./repository)"); this.editOption = option(asList("edit", "e"), "Open the file with the default system editor"); this.noGuessImportsOption = option("no-guess-imports", diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/TestCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/TestCommand.java index 49fa75cef1..e348729de9 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/TestCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/TestCommand.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.logging.Level; import joptsimple.OptionSet; @@ -46,11 +45,8 @@ import org.springframework.boot.cli.util.FileUtils; */ public class TestCommand extends OptionParsingCommand { - private TestOptionHandler testOptionHandler; - public TestCommand() { super("test", "Test a groovy script", new TestOptionHandler()); - this.testOptionHandler = (TestOptionHandler) this.getHandler(); } @Override @@ -59,7 +55,7 @@ public class TestCommand extends OptionParsingCommand { } public TestResults getResults() { - return this.testOptionHandler.results; + return ((TestOptionHandler) this.getHandler()).results; } private static class TestGroovyCompilerConfiguration implements @@ -79,27 +75,17 @@ public class TestCommand extends OptionParsingCommand { public String getClasspath() { return ""; } - - public Level getLogLevel() { - return Level.INFO; - } } private static class TestOptionHandler extends OptionHandler { - private final GroovyCompiler compiler; private TestResults results; - public TestOptionHandler() { - TestGroovyCompilerConfiguration configuration = new TestGroovyCompilerConfiguration(); - this.compiler = new GroovyCompiler(configuration); - if (configuration.getLogLevel().intValue() <= Level.FINE.intValue()) { - System.setProperty("groovy.grape.report.downloads", "true"); - } - } - @Override protected void run(OptionSet options) throws Exception { + TestGroovyCompilerConfiguration configuration = new TestGroovyCompilerConfiguration(); + GroovyCompiler compiler = new GroovyCompiler(configuration); + FileOptions fileOptions = new FileOptions(options, getClass() .getClassLoader()); @@ -114,13 +100,13 @@ public class TestCommand extends OptionParsingCommand { // Compile - Pass 1 - compile source code to see what test libraries were // pulled in - Object[] sources = this.compiler.sources(fileOptions.getFilesArray()); + Object[] sources = compiler.sources(fileOptions.getFilesArray()); List testerFiles = compileAndCollectTesterFiles(sources); // Compile - Pass 2 - add appropriate testers List files = new ArrayList(fileOptions.getFiles()); files.addAll(testerFiles); - sources = this.compiler.sources(files.toArray(new File[files.size()])); + sources = compiler.sources(files.toArray(new File[files.size()])); if (sources.length == 0) { throw new RuntimeException("No classes found in '" + files + "'"); }