Remove dead code

Remove what appears to be unused CLI code.
This commit is contained in:
Phillip Webb 2014-01-27 16:25:41 -08:00
parent bcd74bb72d
commit a624245b78
4 changed files with 5 additions and 33 deletions

View File

@ -23,6 +23,7 @@ import java.util.List;
import joptsimple.OptionSet; import joptsimple.OptionSet;
import org.springframework.boot.cli.util.ResourceUtils; import org.springframework.boot.cli.util.ResourceUtils;
import org.springframework.util.Assert;
/** /**
* Extract source file options (anything following '--' in an {@link OptionSet}). * Extract source file options (anything following '--' in an {@link OptionSet}).
@ -54,11 +55,8 @@ public class SourceOptions {
* @param optionSet the source option set * @param optionSet the source option set
* @param classLoader an optional classloader used to try and load files that are not * @param classLoader an optional classloader used to try and load files that are not
* found in the local filesystem * found in the local filesystem
* @param defaultPaths the default paths to use if no files are provided in the option
* set
*/ */
public SourceOptions(OptionSet optionSet, ClassLoader classLoader, public SourceOptions(OptionSet optionSet, ClassLoader classLoader) {
String... defaultPaths) {
List<?> nonOptionArguments = optionSet.nonOptionArguments(); List<?> nonOptionArguments = optionSet.nonOptionArguments();
List<String> sources = new ArrayList<String>(); List<String> sources = new ArrayList<String>();
int sourceArgCount = 0; int sourceArgCount = 0;
@ -86,15 +84,7 @@ public class SourceOptions {
} }
this.args = Collections.unmodifiableList(nonOptionArguments.subList( this.args = Collections.unmodifiableList(nonOptionArguments.subList(
sourceArgCount, nonOptionArguments.size())); sourceArgCount, nonOptionArguments.size()));
if (sources.size() == 0) { Assert.isTrue(sources.size() > 0, "Please specify at least one file to run");
if (defaultPaths.length == 0) {
throw new IllegalArgumentException(
"Please specify at least one file to run");
}
for (String path : defaultPaths) {
sources.addAll(ResourceUtils.getUrls(path, classLoader));
}
}
this.sources = Collections.unmodifiableList(sources); this.sources = Collections.unmodifiableList(sources);
} }

View File

@ -78,7 +78,7 @@ public class SpringApplicationRunner {
stop(); stop();
// Compile // Compile
Object[] compiledSources = this.compiler.sources(this.sources); Object[] compiledSources = this.compiler.compile(this.sources);
if (compiledSources.length == 0) { if (compiledSources.length == 0) {
throw new RuntimeException("No classes found in '" + this.sources + "'"); throw new RuntimeException("No classes found in '" + this.sources + "'");
} }

View File

@ -50,7 +50,7 @@ public class TestRunner {
} }
public void compileAndRunTests() throws Exception { public void compileAndRunTests() throws Exception {
Object[] sources = this.compiler.sources(this.sources); Object[] sources = this.compiler.compile(this.sources);
if (sources.length == 0) { if (sources.length == 0) {
throw new RuntimeException("No classes found in '" + this.sources + "'"); throw new RuntimeException("No classes found in '" + this.sources + "'");
} }

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -153,23 +152,6 @@ public class GroovyCompiler {
this.loader.getConfiguration().addCompilationCustomizers(customizers); this.loader.getConfiguration().addCompilationCustomizers(customizers);
} }
public Object[] sources(String... sources) throws CompilationFailedException,
IOException {
List<String> compilables = new ArrayList<String>();
List<Object> others = new ArrayList<Object>();
for (String source : sources) {
if (source.endsWith(".groovy") || source.endsWith(".java")) {
compilables.add(source);
}
else {
others.add(source);
}
}
Class<?>[] compiled = compile(compilables.toArray(new String[compilables.size()]));
others.addAll(0, Arrays.asList(compiled));
return others.toArray(new Object[others.size()]);
}
/** /**
* Compile the specified Groovy sources, applying any * Compile the specified Groovy sources, applying any
* {@link CompilerAutoConfiguration}s. All classes defined in the sources will be * {@link CompilerAutoConfiguration}s. All classes defined in the sources will be