Merge branch '1.2.x'
This commit is contained in:
@@ -38,8 +38,8 @@ public class CommandLineIT {
|
||||
private final CommandLineInvoker cli = new CommandLineInvoker();
|
||||
|
||||
@Test
|
||||
public void hintProducesListOfValidCommands() throws IOException,
|
||||
InterruptedException {
|
||||
public void hintProducesListOfValidCommands()
|
||||
throws IOException, InterruptedException {
|
||||
Invocation cli = this.cli.invoke("hint");
|
||||
assertThat(cli.await(), equalTo(0));
|
||||
assertThat("Unexpected error: \n" + cli.getErrorOutput(), cli.getErrorOutput()
|
||||
@@ -48,8 +48,8 @@ public class CommandLineIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokingWithNoArgumentsDisplaysHelp() throws IOException,
|
||||
InterruptedException {
|
||||
public void invokingWithNoArgumentsDisplaysHelp()
|
||||
throws IOException, InterruptedException {
|
||||
Invocation cli = this.cli.invoke();
|
||||
assertThat(cli.await(), equalTo(1));
|
||||
assertThat(cli.getErrorOutput().length(), equalTo(0));
|
||||
@@ -57,8 +57,8 @@ public class CommandLineIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unrecognizedCommandsAreHandledGracefully() throws IOException,
|
||||
InterruptedException {
|
||||
public void unrecognizedCommandsAreHandledGracefully()
|
||||
throws IOException, InterruptedException {
|
||||
Invocation cli = this.cli.invoke("not-a-real-command");
|
||||
assertThat(cli.await(), equalTo(1));
|
||||
assertThat(cli.getErrorOutput(),
|
||||
|
||||
@@ -38,8 +38,8 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
public class JarCommandIT {
|
||||
|
||||
private final CommandLineInvoker cli = new CommandLineInvoker(new File(
|
||||
"src/it/resources/jar-command"));
|
||||
private final CommandLineInvoker cli = new CommandLineInvoker(
|
||||
new File("src/it/resources/jar-command"));
|
||||
|
||||
@Test
|
||||
public void noArguments() throws Exception {
|
||||
@@ -68,11 +68,12 @@ public class JarCommandIT {
|
||||
assertThat(invocation.getErrorOutput(), equalTo(""));
|
||||
invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "bad.groovy");
|
||||
invocation.await();
|
||||
assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
|
||||
assertEquals(invocation.getErrorOutput(), 0,
|
||||
invocation.getErrorOutput().length());
|
||||
assertTrue(jar.exists());
|
||||
|
||||
Process process = new JavaExecutable().processBuilder("-jar",
|
||||
jar.getAbsolutePath()).start();
|
||||
Process process = new JavaExecutable()
|
||||
.processBuilder("-jar", jar.getAbsolutePath()).start();
|
||||
invocation = new Invocation(process);
|
||||
invocation.await();
|
||||
|
||||
@@ -85,11 +86,12 @@ public class JarCommandIT {
|
||||
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(),
|
||||
"jar.groovy");
|
||||
invocation.await();
|
||||
assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
|
||||
assertEquals(invocation.getErrorOutput(), 0,
|
||||
invocation.getErrorOutput().length());
|
||||
assertTrue(jar.exists());
|
||||
|
||||
Process process = new JavaExecutable().processBuilder("-jar",
|
||||
jar.getAbsolutePath()).start();
|
||||
Process process = new JavaExecutable()
|
||||
.processBuilder("-jar", jar.getAbsolutePath()).start();
|
||||
invocation = new Invocation(process);
|
||||
invocation.await();
|
||||
|
||||
@@ -107,14 +109,15 @@ public class JarCommandIT {
|
||||
@Test
|
||||
public void jarCreationWithIncludes() throws Exception {
|
||||
File jar = new File("target/test-app.jar");
|
||||
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(),
|
||||
"--include", "-public/**,-resources/**", "jar.groovy");
|
||||
Invocation invocation = this.cli.invoke("jar", jar.getAbsolutePath(), "--include",
|
||||
"-public/**,-resources/**", "jar.groovy");
|
||||
invocation.await();
|
||||
assertEquals(invocation.getErrorOutput(), 0, invocation.getErrorOutput().length());
|
||||
assertEquals(invocation.getErrorOutput(), 0,
|
||||
invocation.getErrorOutput().length());
|
||||
assertTrue(jar.exists());
|
||||
|
||||
Process process = new JavaExecutable().processBuilder("-jar",
|
||||
jar.getAbsolutePath()).start();
|
||||
Process process = new JavaExecutable()
|
||||
.processBuilder("-jar", jar.getAbsolutePath()).start();
|
||||
invocation = new Invocation(process);
|
||||
invocation.await();
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ public final class CommandLineInvoker {
|
||||
return pathname.isDirectory() && pathname.getName().contains("-bin");
|
||||
}
|
||||
})[0];
|
||||
dir = new File(dir, dir.getName().replace("-bin", "")
|
||||
.replace("spring-boot-cli", "spring"));
|
||||
dir = new File(dir,
|
||||
dir.getName().replace("-bin", "").replace("spring-boot-cli", "spring"));
|
||||
dir = new File(dir, "bin");
|
||||
File launchScript = new File(dir, isWindows() ? "spring.bat" : "spring");
|
||||
Assert.state(launchScript.exists() && launchScript.isFile(),
|
||||
@@ -99,10 +99,10 @@ public final class CommandLineInvoker {
|
||||
|
||||
public Invocation(Process process) {
|
||||
this.process = process;
|
||||
this.streamReaders.add(new Thread(new StreamReadingRunnable(this.process
|
||||
.getErrorStream(), this.err)));
|
||||
this.streamReaders.add(new Thread(new StreamReadingRunnable(this.process
|
||||
.getInputStream(), this.out)));
|
||||
this.streamReaders.add(new Thread(
|
||||
new StreamReadingRunnable(this.process.getErrorStream(), this.err)));
|
||||
this.streamReaders.add(new Thread(
|
||||
new StreamReadingRunnable(this.process.getInputStream(), this.out)));
|
||||
for (Thread streamReader : this.streamReaders) {
|
||||
streamReader.start();
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public final class SpringCli {
|
||||
}
|
||||
|
||||
private static void addServiceLoaderCommands(CommandRunner runner) {
|
||||
ServiceLoader<CommandFactory> factories = ServiceLoader.load(
|
||||
CommandFactory.class, runner.getClass().getClassLoader());
|
||||
ServiceLoader<CommandFactory> factories = ServiceLoader.load(CommandFactory.class,
|
||||
runner.getClass().getClassLoader());
|
||||
for (CommandFactory factory : factories) {
|
||||
runner.addCommands(factory.getCommands());
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ public class CommandRunner implements Iterable<Command> {
|
||||
public Command findCommand(String name) {
|
||||
for (Command candidate : this.commands) {
|
||||
String candidateName = candidate.getName();
|
||||
if (candidateName.equals(name)
|
||||
|| (isOptionCommand(candidate) && ("--" + candidateName).equals(name))) {
|
||||
if (candidateName.equals(name) || (isOptionCommand(candidate)
|
||||
&& ("--" + candidateName).equals(name))) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
@@ -280,8 +280,8 @@ public class CommandRunner implements Iterable<Command> {
|
||||
String usageHelp = command.getUsageHelp();
|
||||
String description = command.getDescription();
|
||||
Log.info(String.format("\n %1$s %2$-15s\n %3$s", command.getName(),
|
||||
(usageHelp == null ? "" : usageHelp), (description == null ? ""
|
||||
: description)));
|
||||
(usageHelp == null ? "" : usageHelp),
|
||||
(description == null ? "" : description)));
|
||||
}
|
||||
}
|
||||
Log.info("");
|
||||
|
||||
@@ -33,7 +33,8 @@ public abstract class OptionParsingCommand extends AbstractCommand {
|
||||
|
||||
private final OptionHandler handler;
|
||||
|
||||
protected OptionParsingCommand(String name, String description, OptionHandler handler) {
|
||||
protected OptionParsingCommand(String name, String description,
|
||||
OptionHandler handler) {
|
||||
super(name, description);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ public class HintCommand extends AbstractCommand {
|
||||
return false;
|
||||
}
|
||||
return command.getName().startsWith(starting)
|
||||
|| (this.commandRunner.isOptionCommand(command) && ("--" + command
|
||||
.getName()).startsWith(starting));
|
||||
|| (this.commandRunner.isOptionCommand(command)
|
||||
&& ("--" + command.getName()).startsWith(starting));
|
||||
}
|
||||
|
||||
private void showCommandOptionHints(String commandName,
|
||||
|
||||
@@ -104,7 +104,8 @@ class InitializrService {
|
||||
* @throws IOException if the service's metadata cannot be loaded
|
||||
*/
|
||||
public InitializrServiceMetadata loadMetadata(String serviceUrl) throws IOException {
|
||||
CloseableHttpResponse httpResponse = executeInitializrMetadataRetrieval(serviceUrl);
|
||||
CloseableHttpResponse httpResponse = executeInitializrMetadataRetrieval(
|
||||
serviceUrl);
|
||||
validateResponse(httpResponse, serviceUrl);
|
||||
return parseJsonMetadata(httpResponse.getEntity());
|
||||
}
|
||||
@@ -120,8 +121,10 @@ class InitializrService {
|
||||
*/
|
||||
public Object loadServiceCapabilities(String serviceUrl) throws IOException {
|
||||
HttpGet request = new HttpGet(serviceUrl);
|
||||
request.setHeader(new BasicHeader(HttpHeaders.ACCEPT, ACCEPT_SERVICE_CAPABILITIES));
|
||||
CloseableHttpResponse httpResponse = execute(request, serviceUrl, "retrieve help");
|
||||
request.setHeader(
|
||||
new BasicHeader(HttpHeaders.ACCEPT, ACCEPT_SERVICE_CAPABILITIES));
|
||||
CloseableHttpResponse httpResponse = execute(request, serviceUrl,
|
||||
"retrieve help");
|
||||
validateResponse(httpResponse, serviceUrl);
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
ContentType contentType = ContentType.getOrDefault(httpEntity);
|
||||
@@ -137,15 +140,15 @@ class InitializrService {
|
||||
return new InitializrServiceMetadata(getContentAsJson(httpEntity));
|
||||
}
|
||||
catch (JSONException ex) {
|
||||
throw new ReportableException("Invalid content received from server ("
|
||||
+ ex.getMessage() + ")", ex);
|
||||
throw new ReportableException(
|
||||
"Invalid content received from server (" + ex.getMessage() + ")", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateResponse(CloseableHttpResponse httpResponse, String serviceUrl) {
|
||||
if (httpResponse.getEntity() == null) {
|
||||
throw new ReportableException("No content received from server '"
|
||||
+ serviceUrl + "'");
|
||||
throw new ReportableException(
|
||||
"No content received from server '" + serviceUrl + "'");
|
||||
}
|
||||
if (httpResponse.getStatusLine().getStatusCode() != 200) {
|
||||
throw createException(serviceUrl, httpResponse);
|
||||
@@ -157,8 +160,8 @@ class InitializrService {
|
||||
ProjectGenerationResponse response = new ProjectGenerationResponse(
|
||||
ContentType.getOrDefault(httpEntity));
|
||||
response.setContent(FileCopyUtils.copyToByteArray(httpEntity.getContent()));
|
||||
String fileName = extractFileName(httpResponse
|
||||
.getFirstHeader("Content-Disposition"));
|
||||
String fileName = extractFileName(
|
||||
httpResponse.getFirstHeader("Content-Disposition"));
|
||||
if (fileName != null) {
|
||||
response.setFileName(fileName);
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ class InitializrServiceMetadata {
|
||||
InitializrServiceMetadata(ProjectType defaultProjectType) {
|
||||
this.dependencies = new HashMap<String, Dependency>();
|
||||
this.projectTypes = new MetadataHolder<String, ProjectType>();
|
||||
this.projectTypes.getContent()
|
||||
.put(defaultProjectType.getId(), defaultProjectType);
|
||||
this.projectTypes.getContent().put(defaultProjectType.getId(),
|
||||
defaultProjectType);
|
||||
this.projectTypes.setDefaultItem(defaultProjectType);
|
||||
this.defaults = new HashMap<String, String>();
|
||||
}
|
||||
@@ -145,8 +145,8 @@ class InitializrServiceMetadata {
|
||||
}
|
||||
JSONObject type = root.getJSONObject(TYPE_EL);
|
||||
JSONArray array = type.getJSONArray(VALUES_EL);
|
||||
String defaultType = type.has(DEFAULT_ATTRIBUTE) ? type
|
||||
.getString(DEFAULT_ATTRIBUTE) : null;
|
||||
String defaultType = type.has(DEFAULT_ATTRIBUTE)
|
||||
? type.getString(DEFAULT_ATTRIBUTE) : null;
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
JSONObject typeJson = array.getJSONObject(i);
|
||||
ProjectType projectType = parseType(typeJson, defaultType);
|
||||
|
||||
@@ -367,8 +367,8 @@ class ProjectGenerationRequest {
|
||||
if (this.type != null) {
|
||||
ProjectType result = metadata.getProjectTypes().get(this.type);
|
||||
if (result == null) {
|
||||
throw new ReportableException(
|
||||
("No project type with id '" + this.type + "' - check the service capabilities (--list)"));
|
||||
throw new ReportableException(("No project type with id '" + this.type
|
||||
+ "' - check the service capabilities (--list)"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -423,8 +423,8 @@ class ProjectGenerationRequest {
|
||||
|
||||
private static void filter(Map<String, ProjectType> projects, String tag,
|
||||
String tagValue) {
|
||||
for (Iterator<Map.Entry<String, ProjectType>> it = projects.entrySet().iterator(); it
|
||||
.hasNext();) {
|
||||
for (Iterator<Map.Entry<String, ProjectType>> it = projects.entrySet()
|
||||
.iterator(); it.hasNext();) {
|
||||
Map.Entry<String, ProjectType> entry = it.next();
|
||||
String value = entry.getValue().getTags().get(tag);
|
||||
if (!tagValue.equals(value)) {
|
||||
|
||||
@@ -46,8 +46,8 @@ class ProjectGenerator {
|
||||
public void generateProject(ProjectGenerationRequest request, boolean force)
|
||||
throws IOException {
|
||||
ProjectGenerationResponse response = this.initializrService.generate(request);
|
||||
String fileName = (request.getOutput() != null ? request.getOutput() : response
|
||||
.getFileName());
|
||||
String fileName = (request.getOutput() != null ? request.getOutput()
|
||||
: response.getFileName());
|
||||
if (shouldExtract(request, response)) {
|
||||
if (isZipArchive(response)) {
|
||||
extractProject(response, request.getOutput(), force);
|
||||
@@ -101,13 +101,13 @@ class ProjectGenerator {
|
||||
|
||||
private void extractProject(ProjectGenerationResponse entity, String output,
|
||||
boolean overwrite) throws IOException {
|
||||
File outputFolder = (output != null ? new File(output) : new File(
|
||||
System.getProperty("user.dir")));
|
||||
File outputFolder = (output != null ? new File(output)
|
||||
: new File(System.getProperty("user.dir")));
|
||||
if (!outputFolder.exists()) {
|
||||
outputFolder.mkdirs();
|
||||
}
|
||||
ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(
|
||||
entity.getContent()));
|
||||
ZipInputStream zipStream = new ZipInputStream(
|
||||
new ByteArrayInputStream(entity.getContent()));
|
||||
try {
|
||||
extractFromStream(zipStream, overwrite, outputFolder);
|
||||
Log.info("Project extracted to '" + outputFolder.getAbsolutePath() + "'");
|
||||
@@ -150,8 +150,8 @@ class ProjectGenerator {
|
||||
+ "overwrite or specify an alternate location.");
|
||||
}
|
||||
if (!outputFile.delete()) {
|
||||
throw new ReportableException("Failed to delete existing file "
|
||||
+ outputFile.getPath());
|
||||
throw new ReportableException(
|
||||
"Failed to delete existing file " + outputFile.getPath());
|
||||
}
|
||||
}
|
||||
FileCopyUtils.copy(entity.getContent(), outputFile);
|
||||
|
||||
@@ -133,10 +133,12 @@ class ServiceCapabilitiesReportGenerator {
|
||||
report.append("]");
|
||||
}
|
||||
|
||||
private void reportDefaults(StringBuilder report, InitializrServiceMetadata metadata) {
|
||||
private void reportDefaults(StringBuilder report,
|
||||
InitializrServiceMetadata metadata) {
|
||||
report.append("Defaults:" + NEW_LINE);
|
||||
report.append("---------" + NEW_LINE);
|
||||
List<String> defaultsKeys = new ArrayList<String>(metadata.getDefaults().keySet());
|
||||
List<String> defaultsKeys = new ArrayList<String>(
|
||||
metadata.getDefaults().keySet());
|
||||
Collections.sort(defaultsKeys);
|
||||
for (String defaultsKey : defaultsKeys) {
|
||||
String defaultsValue = metadata.getDefaults().get(defaultsKey);
|
||||
|
||||
@@ -48,8 +48,8 @@ class Installer {
|
||||
|
||||
Installer(OptionSet options, CompilerOptionHandler compilerOptionHandler)
|
||||
throws IOException {
|
||||
this(new GroovyGrabDependencyResolver(createCompilerConfiguration(options,
|
||||
compilerOptionHandler)));
|
||||
this(new GroovyGrabDependencyResolver(
|
||||
createCompilerConfiguration(options, compilerOptionHandler)));
|
||||
}
|
||||
|
||||
Installer(DependencyResolver resolver) throws IOException {
|
||||
|
||||
@@ -187,8 +187,8 @@ class ResourceMatcher {
|
||||
}
|
||||
|
||||
private MatchedResource(File rootFolder, File file) {
|
||||
this.name = StringUtils.cleanPath(file.getAbsolutePath().substring(
|
||||
rootFolder.getAbsolutePath().length() + 1));
|
||||
this.name = StringUtils.cleanPath(file.getAbsolutePath()
|
||||
.substring(rootFolder.getAbsolutePath().length() + 1));
|
||||
this.file = file;
|
||||
this.root = false;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ public class OptionSetGroovyCompilerConfiguration implements GroovyCompilerConfi
|
||||
|
||||
protected OptionSetGroovyCompilerConfiguration(OptionSet optionSet,
|
||||
CompilerOptionHandler compilerOptionHandler) {
|
||||
this(optionSet, compilerOptionHandler, RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration());
|
||||
this(optionSet, compilerOptionHandler,
|
||||
RepositoryConfigurationFactory.createDefaultRepositoryConfiguration());
|
||||
}
|
||||
|
||||
public OptionSetGroovyCompilerConfiguration(OptionSet optionSet,
|
||||
|
||||
@@ -94,8 +94,8 @@ public class SourceOptions {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.args = Collections.unmodifiableList(nonOptionArguments.subList(
|
||||
sourceArgCount, nonOptionArguments.size()));
|
||||
this.args = Collections.unmodifiableList(
|
||||
nonOptionArguments.subList(sourceArgCount, nonOptionArguments.size()));
|
||||
Assert.isTrue(sources.size() > 0, "Please specify at least one file");
|
||||
this.sources = Collections.unmodifiableList(sources);
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class RunCommand extends OptionParsingCommand {
|
||||
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
repositoryConfiguration.add(0, new RepositoryConfiguration("local", new File(
|
||||
"repository").toURI(), true));
|
||||
repositoryConfiguration.add(0, new RepositoryConfiguration("local",
|
||||
new File("repository").toURI(), true));
|
||||
|
||||
SpringApplicationRunnerConfiguration configuration = new SpringApplicationRunnerConfigurationAdapter(
|
||||
options, this, repositoryConfiguration);
|
||||
@@ -113,9 +113,9 @@ public class RunCommand extends OptionParsingCommand {
|
||||
* Simple adapter class to present the {@link OptionSet} as a
|
||||
* {@link SpringApplicationRunnerConfiguration}.
|
||||
*/
|
||||
private class SpringApplicationRunnerConfigurationAdapter extends
|
||||
OptionSetGroovyCompilerConfiguration implements
|
||||
SpringApplicationRunnerConfiguration {
|
||||
private class SpringApplicationRunnerConfigurationAdapter
|
||||
extends OptionSetGroovyCompilerConfiguration
|
||||
implements SpringApplicationRunnerConfiguration {
|
||||
|
||||
SpringApplicationRunnerConfigurationAdapter(OptionSet options,
|
||||
CompilerOptionHandler optionHandler,
|
||||
|
||||
@@ -156,7 +156,7 @@ public class SpringApplicationRunner {
|
||||
try {
|
||||
this.applicationContext = new SpringApplicationLauncher(
|
||||
getContextClassLoader()).launch(this.compiledSources,
|
||||
SpringApplicationRunner.this.args);
|
||||
SpringApplicationRunner.this.args);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
@@ -25,7 +25,8 @@ import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public interface SpringApplicationRunnerConfiguration extends GroovyCompilerConfiguration {
|
||||
public interface SpringApplicationRunnerConfiguration
|
||||
extends GroovyCompilerConfiguration {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the source file should be monitored for changes and
|
||||
|
||||
@@ -61,8 +61,8 @@ public class CommandCompleter extends StringsCompleter {
|
||||
}
|
||||
AggregateCompleter arguementCompleters = new AggregateCompleter(
|
||||
new StringsCompleter(options), new FileNameCompleter());
|
||||
ArgumentCompleter argumentCompleter = new ArgumentCompleter(
|
||||
argumentDelimiter, arguementCompleters);
|
||||
ArgumentCompleter argumentCompleter = new ArgumentCompleter(argumentDelimiter,
|
||||
arguementCompleters);
|
||||
argumentCompleter.setStrict(false);
|
||||
this.commandCompleters.put(command.getName(), argumentCompleter);
|
||||
}
|
||||
@@ -99,8 +99,8 @@ public class CommandCompleter extends StringsCompleter {
|
||||
for (OptionHelp optionHelp : command.getOptionsHelp()) {
|
||||
OptionHelpLine optionHelpLine = new OptionHelpLine(optionHelp);
|
||||
optionHelpLines.add(optionHelpLine);
|
||||
maxOptionsLength = Math.max(maxOptionsLength, optionHelpLine.getOptions()
|
||||
.length());
|
||||
maxOptionsLength = Math.max(maxOptionsLength,
|
||||
optionHelpLine.getOptions().length());
|
||||
}
|
||||
|
||||
this.console.println();
|
||||
|
||||
@@ -49,6 +49,7 @@ import jline.console.completer.CandidateListCompletionHandler;
|
||||
public class Shell {
|
||||
|
||||
private static final Set<Class<?>> NON_FORKED_COMMANDS;
|
||||
|
||||
static {
|
||||
Set<Class<?>> nonForked = new HashSet<Class<?>>();
|
||||
nonForked.add(VersionCommand.class);
|
||||
@@ -86,8 +87,8 @@ public class Shell {
|
||||
|
||||
private Iterable<Command> getCommands() {
|
||||
List<Command> commands = new ArrayList<Command>();
|
||||
ServiceLoader<CommandFactory> factories = ServiceLoader.load(
|
||||
CommandFactory.class, getClass().getClassLoader());
|
||||
ServiceLoader<CommandFactory> factories = ServiceLoader.load(CommandFactory.class,
|
||||
getClass().getClassLoader());
|
||||
for (CommandFactory factory : factories) {
|
||||
for (Command command : factory.getCommands()) {
|
||||
commands.add(convertToForkCommand(command));
|
||||
|
||||
@@ -95,7 +95,8 @@ public class TestRunner {
|
||||
if (sources.length != 0 && sources[0] instanceof Class) {
|
||||
setContextClassLoader(((Class<?>) sources[0]).getClassLoader());
|
||||
}
|
||||
this.spockSpecificationClass = loadSpockSpecificationClass(getContextClassLoader());
|
||||
this.spockSpecificationClass = loadSpockSpecificationClass(
|
||||
getContextClassLoader());
|
||||
this.testClasses = getTestClasses(sources);
|
||||
}
|
||||
|
||||
@@ -135,8 +136,8 @@ public class TestRunner {
|
||||
}
|
||||
|
||||
private boolean isSpockTest(Class<?> sourceClass) {
|
||||
return (this.spockSpecificationClass != null && this.spockSpecificationClass
|
||||
.isAssignableFrom(sourceClass));
|
||||
return (this.spockSpecificationClass != null
|
||||
&& this.spockSpecificationClass.isAssignableFrom(sourceClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,8 +157,8 @@ public class TestRunner {
|
||||
resultClass);
|
||||
Object result = resultClass.newInstance();
|
||||
runMethod.invoke(null, this.testClasses, result);
|
||||
boolean wasSuccessful = (Boolean) resultClass.getMethod(
|
||||
"wasSuccessful").invoke(result);
|
||||
boolean wasSuccessful = (Boolean) resultClass
|
||||
.getMethod("wasSuccessful").invoke(result);
|
||||
if (!wasSuccessful) {
|
||||
throw new RuntimeException("Tests Failed.");
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ public abstract class AstUtils {
|
||||
String... annotations) {
|
||||
for (AnnotationNode annotationNode : node.getAnnotations()) {
|
||||
for (String annotation : annotations) {
|
||||
if (PatternMatchUtils.simpleMatch(annotation, annotationNode
|
||||
.getClassNode().getName())) {
|
||||
if (PatternMatchUtils.simpleMatch(annotation,
|
||||
annotationNode.getClassNode().getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ public abstract class CompilerAutoConfiguration {
|
||||
* @param classNode the class
|
||||
* @throws CompilationFailedException if the configuration cannot be applied
|
||||
*/
|
||||
public void apply(GroovyClassLoader loader,
|
||||
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
|
||||
SourceUnit source, ClassNode classNode) throws CompilationFailedException {
|
||||
public void apply(GroovyClassLoader loader, GroovyCompilerConfiguration configuration,
|
||||
GeneratorContext generatorContext, SourceUnit source, ClassNode classNode)
|
||||
throws CompilationFailedException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class DependencyCustomizer {
|
||||
}
|
||||
|
||||
public String getVersion(String artifactId, String defaultVersion) {
|
||||
String version = this.dependencyResolutionContext
|
||||
.getArtifactCoordinatesResolver().getVersion(artifactId);
|
||||
String version = this.dependencyResolutionContext.getArtifactCoordinatesResolver()
|
||||
.getVersion(artifactId);
|
||||
if (version == null) {
|
||||
version = defaultVersion;
|
||||
}
|
||||
@@ -224,11 +224,11 @@ public class DependencyCustomizer {
|
||||
if (canAdd()) {
|
||||
ArtifactCoordinatesResolver artifactCoordinatesResolver = this.dependencyResolutionContext
|
||||
.getArtifactCoordinatesResolver();
|
||||
this.classNode.addAnnotation(createGrabAnnotation(
|
||||
artifactCoordinatesResolver.getGroupId(module),
|
||||
artifactCoordinatesResolver.getArtifactId(module),
|
||||
artifactCoordinatesResolver.getVersion(module), classifier, type,
|
||||
transitive));
|
||||
this.classNode.addAnnotation(
|
||||
createGrabAnnotation(artifactCoordinatesResolver.getGroupId(module),
|
||||
artifactCoordinatesResolver.getArtifactId(module),
|
||||
artifactCoordinatesResolver.getVersion(module), classifier,
|
||||
type, transitive));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -160,8 +160,8 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
|
||||
@Override
|
||||
protected Class<?> createClass(byte[] code, ClassNode classNode) {
|
||||
Class<?> createdClass = super.createClass(code, classNode);
|
||||
ExtendedGroovyClassLoader.this.classResources.put(classNode.getName()
|
||||
.replace(".", "/") + ".class", code);
|
||||
ExtendedGroovyClassLoader.this.classResources
|
||||
.put(classNode.getName().replace(".", "/") + ".class", code);
|
||||
return createdClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ public class GroovyBeansTransformation implements ASTTransformation {
|
||||
for (ASTNode node : nodes) {
|
||||
if (node instanceof ModuleNode) {
|
||||
ModuleNode module = (ModuleNode) node;
|
||||
for (ClassNode classNode : new ArrayList<ClassNode>(module.getClasses())) {
|
||||
for (ClassNode classNode : new ArrayList<ClassNode>(
|
||||
module.getClasses())) {
|
||||
if (classNode.isScript()) {
|
||||
classNode.visitContents(new ClassVisitor(source, classNode));
|
||||
}
|
||||
@@ -95,9 +96,10 @@ public class GroovyBeansTransformation implements ASTTransformation {
|
||||
// Implement the interface by adding a public read-only property with the
|
||||
// same name as the method in the interface (getBeans). Make it return the
|
||||
// closure.
|
||||
this.classNode.addProperty(new PropertyNode(BEANS, Modifier.PUBLIC
|
||||
| Modifier.FINAL, ClassHelper.CLOSURE_TYPE
|
||||
.getPlainNodeReference(), this.classNode, closure, null, null));
|
||||
this.classNode.addProperty(
|
||||
new PropertyNode(BEANS, Modifier.PUBLIC | Modifier.FINAL,
|
||||
ClassHelper.CLOSURE_TYPE.getPlainNodeReference(),
|
||||
this.classNode, closure, null, null));
|
||||
// Only do this once per class
|
||||
this.xformed = true;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ import groovy.lang.Grab;
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Order(ResolveDependencyCoordinatesTransformation.ORDER)
|
||||
public class ResolveDependencyCoordinatesTransformation extends
|
||||
AnnotatedNodeASTTransformation {
|
||||
public class ResolveDependencyCoordinatesTransformation
|
||||
extends AnnotatedNodeASTTransformation {
|
||||
|
||||
/**
|
||||
* The order of the transformation.
|
||||
@@ -47,8 +47,8 @@ public class ResolveDependencyCoordinatesTransformation extends
|
||||
public static final int ORDER = DependencyManagementBomTransformation.ORDER + 300;
|
||||
|
||||
private static final Set<String> GRAB_ANNOTATION_NAMES = Collections
|
||||
.unmodifiableSet(new HashSet<String>(Arrays.asList(Grab.class.getName(),
|
||||
Grab.class.getSimpleName())));
|
||||
.unmodifiableSet(new HashSet<String>(
|
||||
Arrays.asList(Grab.class.getName(), Grab.class.getSimpleName())));
|
||||
|
||||
private final DependencyResolutionContext resolutionContext;
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ class SmartImportCustomizer extends ImportCustomizer {
|
||||
|
||||
@Override
|
||||
public ImportCustomizer addImport(String alias, String className) {
|
||||
if (this.source.getAST().getImport(
|
||||
ClassHelper.make(className).getNameWithoutPackage()) == null) {
|
||||
if (this.source.getAST()
|
||||
.getImport(ClassHelper.make(className).getNameWithoutPackage()) == null) {
|
||||
super.addImport(alias, className);
|
||||
}
|
||||
return this;
|
||||
@@ -49,8 +49,8 @@ class SmartImportCustomizer extends ImportCustomizer {
|
||||
@Override
|
||||
public ImportCustomizer addImports(String... imports) {
|
||||
for (String alias : imports) {
|
||||
if (this.source.getAST().getImport(
|
||||
ClassHelper.make(alias).getNameWithoutPackage()) == null) {
|
||||
if (this.source.getAST()
|
||||
.getImport(ClassHelper.make(alias).getNameWithoutPackage()) == null) {
|
||||
super.addImports(alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ public class GroovyTemplatesCompilerAutoConfiguration extends CompilerAutoConfig
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("groovy.text.TemplateEngine").add(
|
||||
"groovy-templates");
|
||||
dependencies.ifAnyMissingClasses("groovy.text.TemplateEngine")
|
||||
.add("groovy-templates");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,16 +37,15 @@ public class SpringBatchCompilerAutoConfiguration extends CompilerAutoConfigurat
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.batch.core.Job").add(
|
||||
"spring-boot-starter-batch");
|
||||
dependencies.ifAnyMissingClasses("org.springframework.batch.core.Job")
|
||||
.add("spring-boot-starter-batch");
|
||||
dependencies.ifAnyMissingClasses("org.springframework.jdbc.core.JdbcTemplate")
|
||||
.add("spring-jdbc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addImports(
|
||||
"org.springframework.batch.repeat.RepeatStatus",
|
||||
imports.addImports("org.springframework.batch.repeat.RepeatStatus",
|
||||
"org.springframework.batch.core.scope.context.ChunkContext",
|
||||
"org.springframework.batch.core.step.tasklet.Tasklet",
|
||||
"org.springframework.batch.core.configuration.annotation.StepScope",
|
||||
|
||||
@@ -45,10 +45,8 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addImports(
|
||||
"javax.annotation.PostConstruct",
|
||||
"javax.annotation.PreDestroy",
|
||||
"groovy.util.logging.Log",
|
||||
imports.addImports("javax.annotation.PostConstruct",
|
||||
"javax.annotation.PreDestroy", "groovy.util.logging.Log",
|
||||
"org.springframework.stereotype.Controller",
|
||||
"org.springframework.stereotype.Service",
|
||||
"org.springframework.stereotype.Component",
|
||||
|
||||
@@ -28,7 +28,8 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
* @author Dave Syer
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
public class SpringIntegrationCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
@@ -38,9 +39,10 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses(
|
||||
"org.springframework.integration.config.EnableIntegration").add(
|
||||
"spring-boot-starter-integration");
|
||||
dependencies
|
||||
.ifAnyMissingClasses(
|
||||
"org.springframework.integration.config.EnableIntegration")
|
||||
.add("spring-boot-starter-integration");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,17 +33,16 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
return AstUtils.hasAtLeastOneAnnotation(classNode, "Controller",
|
||||
"RestController", "EnableWebMvc");
|
||||
return AstUtils.hasAtLeastOneAnnotation(classNode, "Controller", "RestController",
|
||||
"EnableWebMvc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies
|
||||
.ifAnyMissingClasses("org.springframework.web.servlet.mvc.Controller")
|
||||
dependencies.ifAnyMissingClasses("org.springframework.web.servlet.mvc.Controller")
|
||||
.add("spring-boot-starter-web");
|
||||
dependencies.ifAnyMissingClasses("groovy.text.TemplateEngine").add(
|
||||
"groovy-templates");
|
||||
dependencies.ifAnyMissingClasses("groovy.text.TemplateEngine")
|
||||
.add("groovy-templates");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SpringSocialFacebookCompilerAutoConfiguration extends
|
||||
CompilerAutoConfiguration {
|
||||
public class SpringSocialFacebookCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
@@ -40,9 +40,9 @@ public class SpringSocialFacebookCompilerAutoConfiguration extends
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies.ifAnyMissingClasses(
|
||||
"org.springframework.social.facebook.api.Facebook").add(
|
||||
"spring-boot-starter-social-facebook");
|
||||
dependencies
|
||||
.ifAnyMissingClasses("org.springframework.social.facebook.api.Facebook")
|
||||
.add("spring-boot-starter-social-facebook");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SpringSocialLinkedInCompilerAutoConfiguration extends
|
||||
CompilerAutoConfiguration {
|
||||
public class SpringSocialLinkedInCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
@@ -40,9 +40,9 @@ public class SpringSocialLinkedInCompilerAutoConfiguration extends
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies.ifAnyMissingClasses(
|
||||
"org.springframework.social.linkedin.api.LinkedIn").add(
|
||||
"spring-boot-starter-social-linkedin");
|
||||
dependencies
|
||||
.ifAnyMissingClasses("org.springframework.social.linkedin.api.LinkedIn")
|
||||
.add("spring-boot-starter-social-linkedin");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SpringSocialTwitterCompilerAutoConfiguration extends
|
||||
CompilerAutoConfiguration {
|
||||
public class SpringSocialTwitterCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
@@ -40,8 +40,7 @@ public class SpringSocialTwitterCompilerAutoConfiguration extends
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies
|
||||
.ifAnyMissingClasses("org.springframework.social.twitter.api.Twitter")
|
||||
dependencies.ifAnyMissingClasses("org.springframework.social.twitter.api.Twitter")
|
||||
.add("spring-boot-starter-social-twitter");
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.http.HttpHeaders").add(
|
||||
"spring-boot-starter-web");
|
||||
dependencies.ifAnyMissingClasses("org.springframework.http.HttpHeaders")
|
||||
.add("spring-boot-starter-web");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(GroovyClassLoader loader,
|
||||
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
|
||||
SourceUnit source, ClassNode classNode) throws CompilationFailedException {
|
||||
public void apply(GroovyClassLoader loader, GroovyCompilerConfiguration configuration,
|
||||
GeneratorContext generatorContext, SourceUnit source, ClassNode classNode)
|
||||
throws CompilationFailedException {
|
||||
if (!AstUtils.hasAtLeastOneAnnotation(classNode, "RunWith")) {
|
||||
AnnotationNode runwith = new AnnotationNode(ClassHelper.make("RunWith"));
|
||||
runwith.addMember("value",
|
||||
@@ -67,7 +67,7 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.junit.runner", "org.springframework.boot.test",
|
||||
"org.springframework.http", "org.springframework.test.context.junit4",
|
||||
"org.springframework.test.annotation").addImports(
|
||||
"org.springframework.test.context.web.WebAppConfiguration");
|
||||
"org.springframework.test.annotation")
|
||||
.addImports("org.springframework.test.context.web.WebAppConfiguration");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public class SpringWebsocketCompilerAutoConfiguration extends CompilerAutoConfig
|
||||
"org.springframework.messaging.simp.config",
|
||||
"org.springframework.web.socket.handler",
|
||||
"org.springframework.web.socket.sockjs.transport.handler",
|
||||
"org.springframework.web.socket.config.annotation").addImports(
|
||||
"org.springframework.web.socket.WebSocketHandler");
|
||||
"org.springframework.web.socket.config.annotation")
|
||||
.addImports("org.springframework.web.socket.WebSocketHandler");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class TransactionManagementCompilerAutoConfiguration extends
|
||||
CompilerAutoConfiguration {
|
||||
public class TransactionManagementCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
@@ -38,9 +38,10 @@ public class TransactionManagementCompilerAutoConfiguration extends
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses(
|
||||
"org.springframework.transaction.annotation.Transactional").add(
|
||||
"spring-tx", "spring-boot-starter-aop");
|
||||
dependencies
|
||||
.ifAnyMissingClasses(
|
||||
"org.springframework.transaction.annotation.Transactional")
|
||||
.add("spring-tx", "spring-boot-starter-aop");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,9 +44,9 @@ import groovy.grape.GrapeEngine;
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
|
||||
/**
|
||||
* A {@link GrapeEngine} implementation that uses <a
|
||||
* href="http://eclipse.org/aether">Aether</a>, the dependency resolution system used by
|
||||
* Maven.
|
||||
* A {@link GrapeEngine} implementation that uses
|
||||
* <a href="http://eclipse.org/aether">Aether</a>, the dependency resolution system used
|
||||
* by Maven.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
@@ -55,6 +55,7 @@ import groovy.lang.GroovyClassLoader;
|
||||
public class AetherGrapeEngine implements GrapeEngine {
|
||||
|
||||
private static final Collection<Exclusion> WILDCARD_EXCLUSION;
|
||||
|
||||
static {
|
||||
List<Exclusion> exclusions = new ArrayList<Exclusion>();
|
||||
exclusions.add(new Exclusion("*", "*", "*", "*"));
|
||||
@@ -199,8 +200,8 @@ public class AetherGrapeEngine implements GrapeEngine {
|
||||
private List<Dependency> getDependencies(DependencyResult dependencyResult) {
|
||||
List<Dependency> dependencies = new ArrayList<Dependency>();
|
||||
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
|
||||
dependencies.add(new Dependency(artifactResult.getArtifact(),
|
||||
JavaScopes.COMPILE));
|
||||
dependencies.add(
|
||||
new Dependency(artifactResult.getArtifact(), JavaScopes.COMPILE));
|
||||
}
|
||||
return dependencies;
|
||||
}
|
||||
@@ -239,8 +240,8 @@ public class AetherGrapeEngine implements GrapeEngine {
|
||||
}
|
||||
|
||||
private RemoteRepository getPossibleMirror(RemoteRepository remoteRepository) {
|
||||
RemoteRepository mirror = this.session.getMirrorSelector().getMirror(
|
||||
remoteRepository);
|
||||
RemoteRepository mirror = this.session.getMirrorSelector()
|
||||
.getMirror(remoteRepository);
|
||||
if (mirror != null) {
|
||||
return mirror;
|
||||
}
|
||||
@@ -298,8 +299,8 @@ public class AetherGrapeEngine implements GrapeEngine {
|
||||
try {
|
||||
CollectRequest collectRequest = getCollectRequest(dependencies);
|
||||
DependencyRequest dependencyRequest = getDependencyRequest(collectRequest);
|
||||
DependencyResult result = this.repositorySystem.resolveDependencies(
|
||||
this.session, dependencyRequest);
|
||||
DependencyResult result = this.repositorySystem
|
||||
.resolveDependencies(this.session, dependencyRequest);
|
||||
addManagedDependencies(result);
|
||||
return getFiles(result);
|
||||
}
|
||||
@@ -314,8 +315,8 @@ public class AetherGrapeEngine implements GrapeEngine {
|
||||
private CollectRequest getCollectRequest(List<Dependency> dependencies) {
|
||||
CollectRequest collectRequest = new CollectRequest((Dependency) null,
|
||||
dependencies, new ArrayList<RemoteRepository>(this.repositories));
|
||||
collectRequest.setManagedDependencies(this.resolutionContext
|
||||
.getManagedDependencies());
|
||||
collectRequest
|
||||
.setManagedDependencies(this.resolutionContext.getManagedDependencies());
|
||||
return collectRequest;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ public abstract class AetherGrapeEngineFactory {
|
||||
List<RepositoryConfiguration> repositoryConfigurations,
|
||||
DependencyResolutionContext dependencyResolutionContext) {
|
||||
|
||||
RepositorySystem repositorySystem = createServiceLocator().getService(
|
||||
RepositorySystem.class);
|
||||
RepositorySystem repositorySystem = createServiceLocator()
|
||||
.getService(RepositorySystem.class);
|
||||
|
||||
DefaultRepositorySystemSession repositorySystemSession = MavenRepositorySystemUtils
|
||||
.newSession();
|
||||
@@ -60,8 +60,8 @@ public abstract class AetherGrapeEngineFactory {
|
||||
autoConfiguration.apply(repositorySystemSession, repositorySystem);
|
||||
}
|
||||
|
||||
new DefaultRepositorySystemSessionAutoConfiguration().apply(
|
||||
repositorySystemSession, repositorySystem);
|
||||
new DefaultRepositorySystemSessionAutoConfiguration()
|
||||
.apply(repositorySystemSession, repositorySystem);
|
||||
|
||||
return new AetherGrapeEngine(classLoader, repositorySystem,
|
||||
repositorySystemSession, createRepositories(repositoryConfigurations),
|
||||
@@ -84,13 +84,13 @@ public abstract class AetherGrapeEngineFactory {
|
||||
repositoryConfigurations.size());
|
||||
for (RepositoryConfiguration repositoryConfiguration : repositoryConfigurations) {
|
||||
RemoteRepository.Builder builder = new RemoteRepository.Builder(
|
||||
repositoryConfiguration.getName(), "default", repositoryConfiguration
|
||||
.getUri().toASCIIString());
|
||||
repositoryConfiguration.getName(), "default",
|
||||
repositoryConfiguration.getUri().toASCIIString());
|
||||
|
||||
if (!repositoryConfiguration.getSnapshotsEnabled()) {
|
||||
builder.setSnapshotPolicy(new RepositoryPolicy(false,
|
||||
RepositoryPolicy.UPDATE_POLICY_NEVER,
|
||||
RepositoryPolicy.CHECKSUM_POLICY_IGNORE));
|
||||
builder.setSnapshotPolicy(
|
||||
new RepositoryPolicy(false, RepositoryPolicy.UPDATE_POLICY_NEVER,
|
||||
RepositoryPolicy.CHECKSUM_POLICY_IGNORE));
|
||||
}
|
||||
repositories.add(builder.build());
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class DefaultRepositorySystemSessionAutoConfiguration implements
|
||||
RepositorySystemSessionAutoConfiguration {
|
||||
public class DefaultRepositorySystemSessionAutoConfiguration
|
||||
implements RepositorySystemSessionAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void apply(DefaultRepositorySystemSession session,
|
||||
|
||||
@@ -31,7 +31,8 @@ import org.eclipse.aether.transfer.TransferResource;
|
||||
*/
|
||||
final class DetailedProgressReporter implements ProgressReporter {
|
||||
|
||||
DetailedProgressReporter(DefaultRepositorySystemSession session, final PrintStream out) {
|
||||
DetailedProgressReporter(DefaultRepositorySystemSession session,
|
||||
final PrintStream out) {
|
||||
|
||||
session.setTransferListener(new AbstractTransferListener() {
|
||||
|
||||
@@ -56,8 +57,8 @@ final class DetailedProgressReporter implements ProgressReporter {
|
||||
|
||||
private String getTransferSpeed(TransferEvent event) {
|
||||
long kb = event.getTransferredBytes() / 1024;
|
||||
float seconds = (System.currentTimeMillis() - event.getResource()
|
||||
.getTransferStartTime()) / 1000.0f;
|
||||
float seconds = (System.currentTimeMillis()
|
||||
- event.getResource().getTransferStartTime()) / 1000.0f;
|
||||
|
||||
return String.format("%dKB at %.1fKB/sec", kb, (kb / seconds));
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.2.5
|
||||
*/
|
||||
public class GrapeRootRepositorySystemSessionAutoConfiguration implements
|
||||
RepositorySystemSessionAutoConfiguration {
|
||||
public class GrapeRootRepositorySystemSessionAutoConfiguration
|
||||
implements RepositorySystemSessionAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void apply(DefaultRepositorySystemSession session,
|
||||
|
||||
@@ -61,8 +61,8 @@ public final class PackagedSpringApplicationLauncher {
|
||||
return loadClasses(classLoader, sources.split(","));
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Cannot locate " + SOURCE_ENTRY
|
||||
+ " in MANIFEST.MF");
|
||||
throw new IllegalStateException(
|
||||
"Cannot locate " + SOURCE_ENTRY + " in MANIFEST.MF");
|
||||
}
|
||||
|
||||
private boolean isCliPackaged(Manifest manifest) {
|
||||
|
||||
@@ -77,8 +77,8 @@ public abstract class ResourceUtils {
|
||||
return getUrlsFromWildcardPath(path, classLoader);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalArgumentException("Cannot create URL from path [" + path
|
||||
+ "]", ex);
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot create URL from path [" + path + "]", ex);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -160,8 +160,9 @@ public abstract class ResourceUtils {
|
||||
public Resource getResource(String location) {
|
||||
Assert.notNull(location, "Location must not be null");
|
||||
if (location.startsWith(CLASSPATH_URL_PREFIX)) {
|
||||
return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX
|
||||
.length()), getClassLoader());
|
||||
return new ClassPathResource(
|
||||
location.substring(CLASSPATH_URL_PREFIX.length()),
|
||||
getClassLoader());
|
||||
}
|
||||
else {
|
||||
if (location.startsWith(FILE_URL_PREFIX)) {
|
||||
|
||||
@@ -37,18 +37,19 @@ import groovy.text.TemplateEngine;
|
||||
*/
|
||||
public abstract class GroovyTemplate {
|
||||
|
||||
public static String template(String name) throws IOException,
|
||||
CompilationFailedException, ClassNotFoundException {
|
||||
public static String template(String name)
|
||||
throws IOException, CompilationFailedException, ClassNotFoundException {
|
||||
return template(name, Collections.<String, Object>emptyMap());
|
||||
}
|
||||
|
||||
public static String template(String name, Map<String, ?> model) throws IOException,
|
||||
CompilationFailedException, ClassNotFoundException {
|
||||
public static String template(String name, Map<String, ?> model)
|
||||
throws IOException, CompilationFailedException, ClassNotFoundException {
|
||||
return template(new GStringTemplateEngine(), name, model);
|
||||
}
|
||||
|
||||
public static String template(TemplateEngine engine, String name, Map<String, ?> model)
|
||||
throws IOException, CompilationFailedException, ClassNotFoundException {
|
||||
public static String template(TemplateEngine engine, String name,
|
||||
Map<String, ?> model) throws IOException, CompilationFailedException,
|
||||
ClassNotFoundException {
|
||||
Writable writable = getTemplate(engine, name).make(model);
|
||||
StringWriter result = new StringWriter();
|
||||
writable.writeTo(result);
|
||||
|
||||
@@ -160,8 +160,8 @@ public class CliTester implements TestRule {
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement base, final Description description) {
|
||||
final Statement statement = CliTester.this.outputCapture.apply(
|
||||
new RunLauncherStatement(base), description);
|
||||
final Statement statement = CliTester.this.outputCapture
|
||||
.apply(new RunLauncherStatement(base), description);
|
||||
return new Statement() {
|
||||
|
||||
@Override
|
||||
@@ -181,8 +181,8 @@ public class CliTester implements TestRule {
|
||||
|
||||
public String getHttpOutput(String uri) {
|
||||
try {
|
||||
InputStream stream = URI.create("http://localhost:" + this.port + uri)
|
||||
.toURL().openStream();
|
||||
InputStream stream = URI.create("http://localhost:" + this.port + uri).toURL()
|
||||
.openStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
String line;
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
@@ -155,8 +155,8 @@ public class CommandRunnerTests {
|
||||
willThrow(new NullPointerException()).given(this.regularCommand).run();
|
||||
int status = this.commandRunner.runAndHandleErrors("command");
|
||||
assertThat(status, equalTo(1));
|
||||
assertThat(this.calls, equalTo((Set<Call>) EnumSet.of(Call.ERROR_MESSAGE,
|
||||
Call.PRINT_STACK_TRACE)));
|
||||
assertThat(this.calls, equalTo(
|
||||
(Set<Call>) EnumSet.of(Call.ERROR_MESSAGE, Call.PRINT_STACK_TRACE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,8 +165,8 @@ public class CommandRunnerTests {
|
||||
int status = this.commandRunner.runAndHandleErrors("command", "-d");
|
||||
assertEquals("true", System.getProperty("debug"));
|
||||
assertThat(status, equalTo(1));
|
||||
assertThat(this.calls, equalTo((Set<Call>) EnumSet.of(Call.ERROR_MESSAGE,
|
||||
Call.PRINT_STACK_TRACE)));
|
||||
assertThat(this.calls, equalTo(
|
||||
(Set<Call>) EnumSet.of(Call.ERROR_MESSAGE, Call.PRINT_STACK_TRACE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,8 +175,8 @@ public class CommandRunnerTests {
|
||||
int status = this.commandRunner.runAndHandleErrors("command", "--debug");
|
||||
assertEquals("true", System.getProperty("debug"));
|
||||
assertThat(status, equalTo(1));
|
||||
assertThat(this.calls, equalTo((Set<Call>) EnumSet.of(Call.ERROR_MESSAGE,
|
||||
Call.PRINT_STACK_TRACE)));
|
||||
assertThat(this.calls, equalTo(
|
||||
(Set<Call>) EnumSet.of(Call.ERROR_MESSAGE, Call.PRINT_STACK_TRACE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -87,8 +87,8 @@ public abstract class AbstractHttpClientMockTests {
|
||||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
mockHttpEntity(response, request.content, request.contentType);
|
||||
mockStatus(response, 200);
|
||||
String header = (request.fileName != null ? contentDispositionValue(request.fileName)
|
||||
: null);
|
||||
String header = (request.fileName != null
|
||||
? contentDispositionValue(request.fileName) : null);
|
||||
mockHttpHeader(response, "Content-Disposition", header);
|
||||
given(this.http.execute(argThat(getForNonMetadata()))).willReturn(response);
|
||||
}
|
||||
@@ -117,8 +117,8 @@ public abstract class AbstractHttpClientMockTests {
|
||||
try {
|
||||
HttpEntity entity = mock(HttpEntity.class);
|
||||
given(entity.getContent()).willReturn(new ByteArrayInputStream(content));
|
||||
Header contentTypeHeader = contentType != null ? new BasicHeader(
|
||||
"Content-Type", contentType) : null;
|
||||
Header contentTypeHeader = contentType != null
|
||||
? new BasicHeader("Content-Type", contentType) : null;
|
||||
given(entity.getContentType()).willReturn(contentTypeHeader);
|
||||
given(response.getEntity()).willReturn(entity);
|
||||
return entity;
|
||||
|
||||
@@ -242,7 +242,8 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
||||
MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", file.getAbsolutePath());
|
||||
mockSuccessfulProjectGeneration(request);
|
||||
assertEquals("Should not have failed", ExitStatus.OK, this.command.run("--force"));
|
||||
assertEquals("Should not have failed", ExitStatus.OK,
|
||||
this.command.run("--force"));
|
||||
assertTrue("File should have changed", fileLength != file.length());
|
||||
}
|
||||
|
||||
@@ -379,8 +380,8 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
private static class TestableInitCommandOptionHandler extends
|
||||
InitCommand.InitOptionHandler {
|
||||
private static class TestableInitCommandOptionHandler
|
||||
extends InitCommand.InitOptionHandler {
|
||||
|
||||
private boolean disableProjectGeneration;
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ public class InitializrServiceMetadataTests {
|
||||
// Security description
|
||||
assertEquals("AOP", metadata.getDependency("aop").getName());
|
||||
assertEquals("Security", metadata.getDependency("security").getName());
|
||||
assertEquals("Security description", metadata.getDependency("security")
|
||||
.getDescription());
|
||||
assertEquals("Security description",
|
||||
metadata.getDependency("security").getDescription());
|
||||
assertEquals("JDBC", metadata.getDependency("jdbc").getName());
|
||||
assertEquals("JPA", metadata.getDependency("data-jpa").getName());
|
||||
assertEquals("MongoDB", metadata.getDependency("data-mongodb").getName());
|
||||
@@ -88,12 +88,12 @@ public class InitializrServiceMetadataTests {
|
||||
}
|
||||
|
||||
private static JSONObject readJson(String version) throws IOException {
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-" + version
|
||||
+ ".json");
|
||||
Resource resource = new ClassPathResource(
|
||||
"metadata/service-metadata-" + version + ".json");
|
||||
InputStream stream = resource.getInputStream();
|
||||
try {
|
||||
return new JSONObject(StreamUtils.copyToString(stream,
|
||||
Charset.forName("UTF-8")));
|
||||
return new JSONObject(
|
||||
StreamUtils.copyToString(stream, Charset.forName("UTF-8")));
|
||||
}
|
||||
finally {
|
||||
stream.close();
|
||||
|
||||
@@ -57,7 +57,8 @@ public class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/xml", "foo.zip");
|
||||
ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
|
||||
assertProjectEntity(entity, mockHttpRequest.contentType, mockHttpRequest.fileName);
|
||||
assertProjectEntity(entity, mockHttpRequest.contentType,
|
||||
mockHttpRequest.fileName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,8 +159,8 @@ public class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
assertNull("No content type expected", entity.getContentType());
|
||||
}
|
||||
else {
|
||||
assertEquals("wrong mime type", mimeType, entity.getContentType()
|
||||
.getMimeType());
|
||||
assertEquals("wrong mime type", mimeType,
|
||||
entity.getContentType().getMimeType());
|
||||
}
|
||||
assertEquals("wrong filename", fileName, entity.getFileName());
|
||||
}
|
||||
|
||||
@@ -60,8 +60,9 @@ public class ProjectGenerationRequestTests {
|
||||
String customServerUrl = "http://foo:8080/initializr";
|
||||
this.request.setServiceUrl(customServerUrl);
|
||||
this.request.getDependencies().add("security");
|
||||
assertEquals(new URI(customServerUrl
|
||||
+ "/starter.zip?dependencies=security&type=test-type"),
|
||||
assertEquals(
|
||||
new URI(customServerUrl
|
||||
+ "/starter.zip?dependencies=security&type=test-type"),
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@@ -108,8 +109,9 @@ public class ProjectGenerationRequestTests {
|
||||
InitializrServiceMetadata metadata = new InitializrServiceMetadata(projectType);
|
||||
this.request.setType("custom");
|
||||
this.request.getDependencies().add("data-rest");
|
||||
assertEquals(new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL
|
||||
+ "/foo?dependencies=data-rest&type=custom"),
|
||||
assertEquals(
|
||||
new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL
|
||||
+ "/foo?dependencies=data-rest&type=custom"),
|
||||
this.request.generateUrl(metadata));
|
||||
}
|
||||
|
||||
@@ -249,8 +251,8 @@ public class ProjectGenerationRequestTests {
|
||||
|
||||
private static InitializrServiceMetadata readMetadata(String version) {
|
||||
try {
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-"
|
||||
+ version + ".json");
|
||||
Resource resource = new ClassPathResource(
|
||||
"metadata/service-metadata-" + version + ".json");
|
||||
String content = StreamUtils.copyToString(resource.getInputStream(),
|
||||
Charset.forName("UTF-8"));
|
||||
JSONObject json = new JSONObject(content);
|
||||
|
||||
@@ -85,16 +85,16 @@ public class GroovyGrabDependencyResolverTests {
|
||||
|
||||
@Test
|
||||
public void resolveArtifactWithNoDependencies() throws Exception {
|
||||
List<File> resolved = this.resolver.resolve(Arrays
|
||||
.asList("commons-logging:commons-logging:1.1.3"));
|
||||
List<File> resolved = this.resolver
|
||||
.resolve(Arrays.asList("commons-logging:commons-logging:1.1.3"));
|
||||
assertThat(resolved, hasSize(1));
|
||||
assertThat(getNames(resolved), hasItems("commons-logging-1.1.3.jar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArtifactWithDependencies() throws Exception {
|
||||
List<File> resolved = this.resolver.resolve(Arrays
|
||||
.asList("org.springframework:spring-core:4.1.1.RELEASE"));
|
||||
List<File> resolved = this.resolver
|
||||
.resolve(Arrays.asList("org.springframework:spring-core:4.1.1.RELEASE"));
|
||||
assertThat(resolved, hasSize(2));
|
||||
assertThat(getNames(resolved),
|
||||
hasItems("commons-logging-1.1.3.jar", "spring-core-4.1.1.RELEASE.jar"));
|
||||
@@ -114,10 +114,8 @@ public class GroovyGrabDependencyResolverTests {
|
||||
List<File> resolved = this.resolver.resolve(Arrays.asList("junit:junit:4.11",
|
||||
"commons-logging:commons-logging:1.1.3"));
|
||||
assertThat(resolved, hasSize(3));
|
||||
assertThat(
|
||||
getNames(resolved),
|
||||
hasItems("junit-4.11.jar", "commons-logging-1.1.3.jar",
|
||||
"hamcrest-core-1.3.jar"));
|
||||
assertThat(getNames(resolved), hasItems("junit-4.11.jar",
|
||||
"commons-logging-1.1.3.jar", "hamcrest-core-1.3.jar"));
|
||||
}
|
||||
|
||||
public Set<String> getNames(Collection<File> files) {
|
||||
|
||||
@@ -84,18 +84,18 @@ public class InstallerTests {
|
||||
File alpha = createTemporaryFile("alpha.jar");
|
||||
File bravo = createTemporaryFile("bravo.jar");
|
||||
File charlie = createTemporaryFile("charlie.jar");
|
||||
given(this.resolver.resolve(Arrays.asList("bravo"))).willReturn(
|
||||
Arrays.asList(bravo, alpha));
|
||||
given(this.resolver.resolve(Arrays.asList("charlie"))).willReturn(
|
||||
Arrays.asList(charlie, alpha));
|
||||
given(this.resolver.resolve(Arrays.asList("bravo")))
|
||||
.willReturn(Arrays.asList(bravo, alpha));
|
||||
given(this.resolver.resolve(Arrays.asList("charlie")))
|
||||
.willReturn(Arrays.asList(charlie, alpha));
|
||||
|
||||
this.installer.install(Arrays.asList("bravo"));
|
||||
assertThat(getNamesOfFilesInLib(),
|
||||
containsInAnyOrder("alpha.jar", "bravo.jar", ".installed"));
|
||||
|
||||
this.installer.install(Arrays.asList("charlie"));
|
||||
assertThat(getNamesOfFilesInLib(),
|
||||
containsInAnyOrder("alpha.jar", "bravo.jar", "charlie.jar", ".installed"));
|
||||
assertThat(getNamesOfFilesInLib(), containsInAnyOrder("alpha.jar", "bravo.jar",
|
||||
"charlie.jar", ".installed"));
|
||||
|
||||
this.installer.uninstall(Arrays.asList("bravo"));
|
||||
assertThat(getNamesOfFilesInLib(),
|
||||
@@ -111,15 +111,15 @@ public class InstallerTests {
|
||||
File bravo = createTemporaryFile("bravo.jar");
|
||||
File charlie = createTemporaryFile("charlie.jar");
|
||||
|
||||
given(this.resolver.resolve(Arrays.asList("bravo"))).willReturn(
|
||||
Arrays.asList(bravo, alpha));
|
||||
given(this.resolver.resolve(Arrays.asList("charlie"))).willReturn(
|
||||
Arrays.asList(charlie, alpha));
|
||||
given(this.resolver.resolve(Arrays.asList("bravo")))
|
||||
.willReturn(Arrays.asList(bravo, alpha));
|
||||
given(this.resolver.resolve(Arrays.asList("charlie")))
|
||||
.willReturn(Arrays.asList(charlie, alpha));
|
||||
|
||||
this.installer.install(Arrays.asList("bravo"));
|
||||
this.installer.install(Arrays.asList("charlie"));
|
||||
assertThat(getNamesOfFilesInLib(),
|
||||
containsInAnyOrder("alpha.jar", "bravo.jar", "charlie.jar", ".installed"));
|
||||
assertThat(getNamesOfFilesInLib(), containsInAnyOrder("alpha.jar", "bravo.jar",
|
||||
"charlie.jar", ".installed"));
|
||||
|
||||
this.installer.uninstallAll();
|
||||
assertThat(getNamesOfFilesInLib(), containsInAnyOrder(".installed"));
|
||||
|
||||
@@ -45,10 +45,11 @@ public class ResourceMatcherTests {
|
||||
|
||||
@Test
|
||||
public void nonExistentRoot() throws IOException {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("alpha/**",
|
||||
"bravo/*", "*"), Arrays.asList(".*", "alpha/**/excluded"));
|
||||
List<MatchedResource> matchedResources = resourceMatcher.find(Arrays
|
||||
.asList(new File("does-not-exist")));
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(
|
||||
Arrays.asList("alpha/**", "bravo/*", "*"),
|
||||
Arrays.asList(".*", "alpha/**/excluded"));
|
||||
List<MatchedResource> matchedResources = resourceMatcher
|
||||
.find(Arrays.asList(new File("does-not-exist")));
|
||||
assertEquals(0, matchedResources.size());
|
||||
}
|
||||
|
||||
@@ -67,18 +68,18 @@ public class ResourceMatcherTests {
|
||||
public void excludedWins() throws Exception {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"),
|
||||
Arrays.asList("**/*.jar"));
|
||||
List<MatchedResource> found = resourceMatcher.find(Arrays.asList(new File(
|
||||
"src/test/resources")));
|
||||
List<MatchedResource> found = resourceMatcher
|
||||
.find(Arrays.asList(new File("src/test/resources")));
|
||||
assertThat(found, not(hasItem(new FooJarMatcher(MatchedResource.class))));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void includedDeltas() throws Exception {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(
|
||||
Arrays.asList("-static/**"), Arrays.asList(""));
|
||||
Collection<String> includes = (Collection<String>) ReflectionTestUtils.getField(
|
||||
resourceMatcher, "includes");
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("-static/**"),
|
||||
Arrays.asList(""));
|
||||
Collection<String> includes = (Collection<String>) ReflectionTestUtils
|
||||
.getField(resourceMatcher, "includes");
|
||||
assertTrue(includes.contains("templates/**"));
|
||||
assertFalse(includes.contains("static/**"));
|
||||
}
|
||||
@@ -86,10 +87,10 @@ public class ResourceMatcherTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void includedDeltasAndNewEntries() throws Exception {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("-static/**",
|
||||
"foo.jar"), Arrays.asList("-**/*.jar"));
|
||||
Collection<String> includes = (Collection<String>) ReflectionTestUtils.getField(
|
||||
resourceMatcher, "includes");
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(
|
||||
Arrays.asList("-static/**", "foo.jar"), Arrays.asList("-**/*.jar"));
|
||||
Collection<String> includes = (Collection<String>) ReflectionTestUtils
|
||||
.getField(resourceMatcher, "includes");
|
||||
assertTrue(includes.contains("foo.jar"));
|
||||
assertTrue(includes.contains("templates/**"));
|
||||
assertFalse(includes.contains("static/**"));
|
||||
@@ -110,8 +111,9 @@ public class ResourceMatcherTests {
|
||||
public void jarFileAlwaysMatches() throws Exception {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"),
|
||||
Arrays.asList("**/*.jar"));
|
||||
List<MatchedResource> found = resourceMatcher.find(Arrays.asList(new File(
|
||||
"src/test/resources/templates"), new File("src/test/resources/foo.jar")));
|
||||
List<MatchedResource> found = resourceMatcher
|
||||
.find(Arrays.asList(new File("src/test/resources/templates"),
|
||||
new File("src/test/resources/foo.jar")));
|
||||
FooJarMatcher matcher = new FooJarMatcher(MatchedResource.class);
|
||||
assertThat(found, hasItem(matcher));
|
||||
// A jar file is always treated as a dependency (stick it in /lib)
|
||||
@@ -120,12 +122,13 @@ public class ResourceMatcherTests {
|
||||
|
||||
@Test
|
||||
public void resourceMatching() throws IOException {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("alpha/**",
|
||||
"bravo/*", "*"), Arrays.asList(".*", "alpha/**/excluded"));
|
||||
List<MatchedResource> matchedResources = resourceMatcher.find(Arrays.asList(
|
||||
new File("src/test/resources/resource-matcher/one"), new File(
|
||||
"src/test/resources/resource-matcher/two"), new File(
|
||||
"src/test/resources/resource-matcher/three")));
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(
|
||||
Arrays.asList("alpha/**", "bravo/*", "*"),
|
||||
Arrays.asList(".*", "alpha/**/excluded"));
|
||||
List<MatchedResource> matchedResources = resourceMatcher
|
||||
.find(Arrays.asList(new File("src/test/resources/resource-matcher/one"),
|
||||
new File("src/test/resources/resource-matcher/two"),
|
||||
new File("src/test/resources/resource-matcher/three")));
|
||||
System.out.println(matchedResources);
|
||||
List<String> paths = new ArrayList<String>();
|
||||
for (MatchedResource resource : matchedResources) {
|
||||
|
||||
@@ -35,8 +35,8 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
|
||||
@Test
|
||||
public void simple() throws Exception {
|
||||
String s = "one two";
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
|
||||
"one", "two" }));
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(),
|
||||
equalTo(new String[] { "one", "two" }));
|
||||
assertThat(this.delimiter.parseArguments(s),
|
||||
equalTo(new String[] { "one", "two" }));
|
||||
assertThat(this.delimiter.isDelimiter(s, 2), equalTo(false));
|
||||
@@ -47,8 +47,8 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
|
||||
@Test
|
||||
public void escaped() throws Exception {
|
||||
String s = "o\\ ne two";
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
|
||||
"o\\ ne", "two" }));
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(),
|
||||
equalTo(new String[] { "o\\ ne", "two" }));
|
||||
assertThat(this.delimiter.parseArguments(s),
|
||||
equalTo(new String[] { "o ne", "two" }));
|
||||
assertThat(this.delimiter.isDelimiter(s, 2), equalTo(false));
|
||||
@@ -60,28 +60,28 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
|
||||
@Test
|
||||
public void quoted() throws Exception {
|
||||
String s = "'o ne' 't w o'";
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
|
||||
"'o ne'", "'t w o'" }));
|
||||
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { "o ne",
|
||||
"t w o" }));
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(),
|
||||
equalTo(new String[] { "'o ne'", "'t w o'" }));
|
||||
assertThat(this.delimiter.parseArguments(s),
|
||||
equalTo(new String[] { "o ne", "t w o" }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleQuoted() throws Exception {
|
||||
String s = "\"o ne\" \"t w o\"";
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
|
||||
"\"o ne\"", "\"t w o\"" }));
|
||||
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { "o ne",
|
||||
"t w o" }));
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(),
|
||||
equalTo(new String[] { "\"o ne\"", "\"t w o\"" }));
|
||||
assertThat(this.delimiter.parseArguments(s),
|
||||
equalTo(new String[] { "o ne", "t w o" }));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedQuotes() throws Exception {
|
||||
String s = "\"o 'n''e\" 't \"w o'";
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
|
||||
"\"o 'n''e\"", "'t \"w o'" }));
|
||||
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { "o 'n''e",
|
||||
"t \"w o" }));
|
||||
assertThat(this.delimiter.delimit(s, 0).getArguments(),
|
||||
equalTo(new String[] { "\"o 'n''e\"", "'t \"w o'" }));
|
||||
assertThat(this.delimiter.parseArguments(s),
|
||||
equalTo(new String[] { "o 'n''e", "t \"w o" }));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +95,8 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
|
||||
@Test
|
||||
public void escapes() throws Exception {
|
||||
String s = "\\ \\\\.\\\\\\t";
|
||||
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { " \\.\\\t" }));
|
||||
assertThat(this.delimiter.parseArguments(s),
|
||||
equalTo(new String[] { " \\.\\\t" }));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,38 +58,36 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void noLocalRepositoryWhenNoGrapeRoot() {
|
||||
given(
|
||||
this.repositorySystem.newLocalRepositoryManager(eq(this.session),
|
||||
any(LocalRepository.class))).willAnswer(
|
||||
new Answer<LocalRepositoryManager>() {
|
||||
given(this.repositorySystem.newLocalRepositoryManager(eq(this.session),
|
||||
any(LocalRepository.class)))
|
||||
.willAnswer(new Answer<LocalRepositoryManager>() {
|
||||
|
||||
@Override
|
||||
public LocalRepositoryManager answer(InvocationOnMock invocation)
|
||||
throws Throwable {
|
||||
LocalRepository localRepository = invocation.getArgumentAt(1,
|
||||
LocalRepository.class);
|
||||
return new SimpleLocalRepositoryManagerFactory()
|
||||
.newInstance(
|
||||
GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session,
|
||||
localRepository);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public LocalRepositoryManager answer(
|
||||
InvocationOnMock invocation) throws Throwable {
|
||||
LocalRepository localRepository = invocation
|
||||
.getArgumentAt(1, LocalRepository.class);
|
||||
return new SimpleLocalRepositoryManagerFactory()
|
||||
.newInstance(
|
||||
GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session,
|
||||
localRepository);
|
||||
}
|
||||
});
|
||||
|
||||
new GrapeRootRepositorySystemSessionAutoConfiguration().apply(this.session,
|
||||
this.repositorySystem);
|
||||
|
||||
verify(this.repositorySystem, times(0)).newLocalRepositoryManager(
|
||||
eq(this.session), any(LocalRepository.class));
|
||||
verify(this.repositorySystem, times(0))
|
||||
.newLocalRepositoryManager(eq(this.session), any(LocalRepository.class));
|
||||
|
||||
assertThat(this.session.getLocalRepository(), is(nullValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void grapeRootConfiguresLocalRepositoryLocation() {
|
||||
given(
|
||||
this.repositorySystem.newLocalRepositoryManager(eq(this.session),
|
||||
any(LocalRepository.class))).willAnswer(
|
||||
new LocalRepositoryManagerAnswer());
|
||||
given(this.repositorySystem.newLocalRepositoryManager(eq(this.session),
|
||||
any(LocalRepository.class)))
|
||||
.willAnswer(new LocalRepositoryManagerAnswer());
|
||||
|
||||
System.setProperty("grape.root", "foo");
|
||||
try {
|
||||
@@ -100,8 +98,8 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
System.clearProperty("grape.root");
|
||||
}
|
||||
|
||||
verify(this.repositorySystem, times(1)).newLocalRepositoryManager(
|
||||
eq(this.session), any(LocalRepository.class));
|
||||
verify(this.repositorySystem, times(1))
|
||||
.newLocalRepositoryManager(eq(this.session), any(LocalRepository.class));
|
||||
|
||||
assertThat(this.session.getLocalRepository(), is(notNullValue()));
|
||||
assertThat(this.session.getLocalRepository().getBasedir().getAbsolutePath(),
|
||||
|
||||
Reference in New Issue
Block a user