diff --git a/spring-boot-cli/samples/app.groovy b/spring-boot-cli/samples/app.groovy index a9b02bc70b..f273c49434 100644 --- a/spring-boot-cli/samples/app.groovy +++ b/spring-boot-cli/samples/app.groovy @@ -7,7 +7,7 @@ class Example implements CommandLineRunner { private MyService myService void run(String... args) { - print "Hello " + this.myService.sayWorld() + println "Hello ${this.myService.sayWorld()} From ${getClass().getClassLoader().getResource('samples/app.groovy')}" } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ScriptCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ScriptCommand.java index 4fe7e8ca83..c342a98769 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ScriptCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ScriptCommand.java @@ -276,7 +276,7 @@ public class ScriptCommand implements Command { @Override public String[] getClasspath() { - return NO_CLASSPATH; + return DEFAULT_CLASSPATH; } @Override diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfiguration.java index 2a8873f182..3b49d5e75f 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompilerConfiguration.java @@ -31,7 +31,7 @@ public interface GroovyCompilerConfiguration { /** * Constant to be used when there is no {@link #getClasspath() classpath}. */ - public static final String[] NO_CLASSPATH = {}; + public static final String[] DEFAULT_CLASSPATH = { "." }; /** * Returns the scope in which the compiler operates. 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/compiler/GroovyCompilerConfigurationAdapter.java index 9f8a5636a8..ae038e1fad 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/compiler/GroovyCompilerConfigurationAdapter.java @@ -82,7 +82,7 @@ public class GroovyCompilerConfigurationAdapter implements GroovyCompilerConfigu if (this.options.has(classpathOption)) { return this.options.valueOf(classpathOption).split(":"); } - return NO_CLASSPATH; + return DEFAULT_CLASSPATH; } @Override diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java index 7c68f70505..96e51ad7a4 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java @@ -17,6 +17,7 @@ package org.springframework.boot.cli; import java.io.File; +import java.net.URI; import org.codehaus.plexus.util.FileUtils; import org.junit.BeforeClass; @@ -48,7 +49,9 @@ public class SampleIntegrationTests { @Test public void appSample() throws Exception { String output = this.cli.run("app.groovy"); - assertTrue("Wrong output: " + output, output.contains("Hello World")); + URI scriptUri = new File("samples/app.groovy").toURI(); + assertTrue("Wrong output: " + output, + output.contains("Hello World! From " + scriptUri)); } @Test