Add spring war command
Add a `war` command to the CLI to generate WAR archives. Fixes gh-925 Closes gh-4168
This commit is contained in:
committed by
Phillip Webb
parent
b1aebe6075
commit
9a63e574b6
@@ -36,8 +36,8 @@ import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
import org.springframework.boot.cli.command.archive.JarCommand;
|
||||
import org.springframework.boot.cli.command.grab.GrabCommand;
|
||||
import org.springframework.boot.cli.command.jar.JarCommand;
|
||||
import org.springframework.boot.cli.command.run.RunCommand;
|
||||
import org.springframework.boot.cli.command.test.TestCommand;
|
||||
import org.springframework.boot.cli.util.OutputCapture;
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.boot.cli.app;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
@@ -90,27 +90,34 @@ public class SpringApplicationLauncherTests {
|
||||
equalTo("false"));
|
||||
}
|
||||
|
||||
private List<String> launch() {
|
||||
private Set<String> launch() {
|
||||
TestClassLoader classLoader = new TestClassLoader(getClass().getClassLoader());
|
||||
try {
|
||||
new TestSpringApplicationLauncher(classLoader).launch(new Object[0],
|
||||
new String[0]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// SpringApplication isn't on the classpath, but we can still check that
|
||||
// the launcher tried to use the right class
|
||||
catch (Exception ex) {
|
||||
// Launch will fail, but we can still check that the launcher tried to use
|
||||
// the right class
|
||||
}
|
||||
return classLoader.classes;
|
||||
}
|
||||
|
||||
private static class TestClassLoader extends ClassLoader {
|
||||
|
||||
private List<String> classes = new ArrayList<String>();
|
||||
private Set<String> classes = new HashSet<String>();
|
||||
|
||||
TestClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException {
|
||||
this.classes.add(name);
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||
this.classes.add(name);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command.jar;
|
||||
package org.springframework.boot.cli.command.archive;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.cli.command.jar.ResourceMatcher.MatchedResource;
|
||||
import org.springframework.boot.cli.command.archive.ResourceMatcher.MatchedResource;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
Reference in New Issue
Block a user