diff --git a/spring-boot-cli/pom.xml b/spring-boot-cli/pom.xml
index 43c2f6a890..b4b31c0e51 100644
--- a/spring-boot-cli/pom.xml
+++ b/spring-boot-cli/pom.xml
@@ -103,12 +103,6 @@
aether-util
-
- ${project.groupId}
- spring-boot-loader
- ${project.version}
- provided
-
org.codehaus.groovy
groovy-templates
diff --git a/spring-boot-cli/src/it/java/org/springframework/boot/cli/JarCommandIT.java b/spring-boot-cli/src/it/java/org/springframework/boot/cli/JarCommandIT.java
index 75b794ca96..96b3095882 100644
--- a/spring-boot-cli/src/it/java/org/springframework/boot/cli/JarCommandIT.java
+++ b/spring-boot-cli/src/it/java/org/springframework/boot/cli/JarCommandIT.java
@@ -19,13 +19,20 @@ package org.springframework.boot.cli;
import java.io.File;
import org.junit.Test;
+import org.springframework.boot.cli.command.jar.JarCommand;
import org.springframework.boot.cli.infrastructure.CommandLineInvoker;
import org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation;
+import org.springframework.boot.cli.util.JavaExecutable;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
+ * Integration test for {@link JarCommand}.
+ *
* @author Andy Wilkinson
*/
public class JarCommandIT {
@@ -37,20 +44,18 @@ public class JarCommandIT {
public void noArguments() throws Exception {
Invocation invocation = this.cli.invoke("jar");
invocation.await();
- assertEquals(0, invocation.getStandardOutput().length());
- assertEquals(
- "The name of the resulting jar and at least one source file must be specified",
- invocation.getErrorOutput().trim());
+ assertThat(invocation.getStandardOutput(), equalTo(""));
+ assertThat(invocation.getErrorOutput(), containsString("The name of the "
+ + "resulting jar and at least one source file must be specified"));
}
@Test
public void noSources() throws Exception {
Invocation invocation = this.cli.invoke("jar", "test-app.jar");
invocation.await();
- assertEquals(0, invocation.getStandardOutput().length());
- assertEquals(
- "The name of the resulting jar and at least one source file must be specified",
- invocation.getErrorOutput().trim());
+ assertThat(invocation.getStandardOutput(), equalTo(""));
+ assertThat(invocation.getErrorOutput(), containsString("The name of the "
+ + "resulting jar and at least one source file must be specified"));
}
@Test
@@ -62,14 +67,13 @@ public class JarCommandIT {
assertEquals(0, invocation.getErrorOutput().length());
assertTrue(jar.exists());
- ProcessBuilder builder = new ProcessBuilder(System.getProperty("java.home")
- + "/bin/java", "-jar", jar.getAbsolutePath());
- Process process = builder.start();
- Invocation appInvocation = new Invocation(process);
- appInvocation.await();
+ Process process = new JavaExecutable().processBuilder("-jar",
+ jar.getAbsolutePath()).start();
+ invocation = new Invocation(process);
+ invocation.await();
- assertEquals(0, appInvocation.getErrorOutput().length());
- assertTrue(appInvocation.getStandardOutput().contains("Hello World!"));
- assertTrue(appInvocation.getStandardOutput().contains("/static/test.txt"));
+ assertThat(invocation.getErrorOutput(), equalTo(""));
+ assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
+ assertThat(invocation.getStandardOutput(), containsString("/static/test.txt"));
}
}
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 7a34aa88ea..ad0f8aecb7 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
@@ -18,20 +18,17 @@ package org.springframework.boot.cli.command.jar;
import groovy.lang.Grab;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.jar.Manifest;
import joptsimple.OptionSet;
@@ -50,7 +47,6 @@ 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.compiler.GroovyCompiler;
-import org.springframework.boot.cli.compiler.GroovyCompiler.CompilationCallback;
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter;
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
@@ -59,12 +55,13 @@ import org.springframework.boot.cli.jar.PackagedSpringApplicationLauncher;
import org.springframework.boot.loader.tools.JarWriter;
import org.springframework.boot.loader.tools.Layout;
import org.springframework.boot.loader.tools.Layouts;
-import org.springframework.util.StringUtils;
+import org.springframework.util.Assert;
/**
* {@link Command} to create a self-contained executable jar file from a CLI application
*
* @author Andy Wilkinson
+ * @author Phillip Webb
*/
public class JarCommand extends OptionParsingCommand {
@@ -77,9 +74,8 @@ public class JarCommand extends OptionParsingCommand {
private static final Layout LAYOUT = new Layouts.Jar();
public JarCommand() {
- super(
- "jar",
- "Create a self-contained executable jar file from a Spring Groovy script",
+ super("jar", "Create a self-contained "
+ + "executable jar file from a Spring Groovy script",
new JarOptionHandler());
}
@@ -110,156 +106,163 @@ public class JarCommand extends OptionParsingCommand {
protected void run(OptionSet options) throws Exception {
List> nonOptionArguments = new ArrayList