Reformat code use Eclipse Mars
This commit is contained in:
@@ -56,8 +56,8 @@ public 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());
|
||||
}
|
||||
|
||||
@@ -149,8 +149,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;
|
||||
}
|
||||
}
|
||||
@@ -284,8 +284,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,
|
||||
|
||||
@@ -46,8 +46,9 @@ public class InitCommand extends OptionParsingCommand {
|
||||
}
|
||||
|
||||
public InitCommand(InitOptionHandler handler) {
|
||||
super("init", "Initialize a new project using Spring "
|
||||
+ "Initialzr (start.spring.io)", handler);
|
||||
super("init",
|
||||
"Initialize a new project using Spring " + "Initialzr (start.spring.io)",
|
||||
handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,8 +107,8 @@ public class InitCommand extends OptionParsingCommand {
|
||||
@Override
|
||||
protected void options() {
|
||||
this.target = option(Arrays.asList("target"), "URL of the service to use")
|
||||
.withRequiredArg().defaultsTo(
|
||||
ProjectGenerationRequest.DEFAULT_SERVICE_URL);
|
||||
.withRequiredArg()
|
||||
.defaultsTo(ProjectGenerationRequest.DEFAULT_SERVICE_URL);
|
||||
this.listCapabilities = option(Arrays.asList("list", "l"),
|
||||
"List the capabilities of the service. Use it to discover the "
|
||||
+ "dependencies and the types that are available");
|
||||
@@ -118,9 +119,8 @@ public class InitCommand extends OptionParsingCommand {
|
||||
private void projectGenerationOptions() {
|
||||
this.bootVersion = option(Arrays.asList("boot-version", "b"),
|
||||
"Spring Boot version to use (for example '1.2.0.RELEASE')")
|
||||
.withRequiredArg();
|
||||
this.dependencies = option(
|
||||
Arrays.asList("dependencies", "d"),
|
||||
.withRequiredArg();
|
||||
this.dependencies = option(Arrays.asList("dependencies", "d"),
|
||||
"Comma separated list of dependencies to include in the "
|
||||
+ "generated project").withRequiredArg();
|
||||
this.javaVersion = option(Arrays.asList("java-version", "j"),
|
||||
@@ -129,14 +129,12 @@ public class InitCommand extends OptionParsingCommand {
|
||||
"Packaging type to use (for example 'jar')").withRequiredArg();
|
||||
this.build = option("build",
|
||||
"The build system to use (for example 'maven' or 'gradle')")
|
||||
.withRequiredArg().defaultsTo("maven");
|
||||
this.format = option(
|
||||
"format",
|
||||
.withRequiredArg().defaultsTo("maven");
|
||||
this.format = option("format",
|
||||
"The format of the generated content (for example 'build' for a build file, "
|
||||
+ "'project' for a project archive)").withRequiredArg()
|
||||
.defaultsTo("project");
|
||||
this.type = option(
|
||||
Arrays.asList("type", "t"),
|
||||
.defaultsTo("project");
|
||||
this.type = option(Arrays.asList("type", "t"),
|
||||
"The project type to use. Not normally needed if you use --build "
|
||||
+ "and/or --format. Check the capabilities of the service "
|
||||
+ "(--list) for more details").withRequiredArg();
|
||||
@@ -171,7 +169,8 @@ public class InitCommand extends OptionParsingCommand {
|
||||
}
|
||||
|
||||
private void generateReport(OptionSet options) throws IOException {
|
||||
Log.info(this.serviceCapabilitiesReport.generate(options.valueOf(this.target)));
|
||||
Log.info(this.serviceCapabilitiesReport
|
||||
.generate(options.valueOf(this.target)));
|
||||
}
|
||||
|
||||
protected void generateProject(OptionSet options) throws IOException {
|
||||
|
||||
@@ -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 {
|
||||
public 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);
|
||||
|
||||
@@ -246,8 +246,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;
|
||||
}
|
||||
@@ -287,8 +287,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);
|
||||
@@ -97,13 +97,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() + "'");
|
||||
@@ -146,8 +146,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 {
|
||||
|
||||
public Installer(OptionSet options, CompilerOptionHandler compilerOptionHandler)
|
||||
throws IOException {
|
||||
this(new GroovyGrabDependencyResolver(createCompilerConfiguration(options,
|
||||
compilerOptionHandler)));
|
||||
this(new GroovyGrabDependencyResolver(
|
||||
createCompilerConfiguration(options, compilerOptionHandler)));
|
||||
}
|
||||
|
||||
public Installer(DependencyResolver resolver) throws IOException {
|
||||
|
||||
@@ -76,8 +76,9 @@ public class JarCommand extends OptionParsingCommand {
|
||||
private static final byte[] ZIP_FILE_HEADER = new byte[] { 'P', 'K', 3, 4 };
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -94,14 +95,12 @@ public class JarCommand extends OptionParsingCommand {
|
||||
|
||||
@Override
|
||||
protected void doOptions() {
|
||||
this.includeOption = option(
|
||||
"include",
|
||||
this.includeOption = option("include",
|
||||
"Pattern applied to directories on the classpath to find files to include in the resulting jar")
|
||||
.withRequiredArg().withValuesSeparatedBy(",").defaultsTo("");
|
||||
this.excludeOption = option(
|
||||
"exclude",
|
||||
.withRequiredArg().withValuesSeparatedBy(",").defaultsTo("");
|
||||
this.excludeOption = option("exclude",
|
||||
"Pattern applied to directories on the claspath to find files to exclude from the resulting jar")
|
||||
.withRequiredArg().withValuesSeparatedBy(",").defaultsTo("");
|
||||
.withRequiredArg().withValuesSeparatedBy(",").defaultsTo("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,8 +111,8 @@ public class JarCommand extends OptionParsingCommand {
|
||||
"The name of the resulting jar and at least one source file must be specified");
|
||||
|
||||
File output = new File((String) nonOptionArguments.remove(0));
|
||||
Assert.isTrue(output.getName().toLowerCase().endsWith(".jar"), "The output '"
|
||||
+ output + "' is not a JAR file.");
|
||||
Assert.isTrue(output.getName().toLowerCase().endsWith(".jar"),
|
||||
"The output '" + output + "' is not a JAR file.");
|
||||
deleteIfExists(output);
|
||||
|
||||
GroovyCompiler compiler = createCompiler(options);
|
||||
@@ -134,8 +133,8 @@ public class JarCommand extends OptionParsingCommand {
|
||||
|
||||
private void deleteIfExists(File file) {
|
||||
if (file.exists() && !file.delete()) {
|
||||
throw new IllegalStateException("Failed to delete existing file "
|
||||
+ file.getPath());
|
||||
throw new IllegalStateException(
|
||||
"Failed to delete existing file " + file.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +166,7 @@ public class JarCommand extends OptionParsingCommand {
|
||||
|
||||
private void writeJar(File file, Class<?>[] compiledClasses,
|
||||
List<MatchedResource> classpathEntries, List<URL> dependencies)
|
||||
throws FileNotFoundException, IOException, URISyntaxException {
|
||||
throws FileNotFoundException, IOException, URISyntaxException {
|
||||
JarWriter writer = new JarWriter(file);
|
||||
try {
|
||||
addManifest(writer, compiledClasses);
|
||||
@@ -254,8 +253,8 @@ public class JarCommand extends OptionParsingCommand {
|
||||
private void addDependency(JarWriter writer, File dependency)
|
||||
throws FileNotFoundException, IOException {
|
||||
if (dependency.isFile() && isZip(dependency)) {
|
||||
writer.writeNestedLibrary("lib/", new Library(dependency,
|
||||
LibraryScope.COMPILE));
|
||||
writer.writeNestedLibrary("lib/",
|
||||
new Library(dependency, LibraryScope.COMPILE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CompilerOptionHandler extends OptionHandler {
|
||||
"Do not attempt to guess dependencies");
|
||||
this.autoconfigureOption = option("autoconfigure",
|
||||
"Add autoconfigure compiler transformations").withOptionalArg()
|
||||
.ofType(Boolean.class).defaultsTo(true);
|
||||
.ofType(Boolean.class).defaultsTo(true);
|
||||
this.classpathOption = option(asList("classpath", "cp"),
|
||||
"Additional classpath entries").withRequiredArg();
|
||||
doOptions();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -97,8 +97,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);
|
||||
@@ -114,9 +114,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 {
|
||||
|
||||
public SpringApplicationRunnerConfigurationAdapter(OptionSet options,
|
||||
CompilerOptionHandler optionHandler,
|
||||
|
||||
@@ -147,7 +147,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));
|
||||
|
||||
@@ -96,7 +96,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);
|
||||
}
|
||||
|
||||
@@ -136,8 +137,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
|
||||
@@ -157,8 +158,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.");
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ public abstract class AnnotatedNodeASTTransformation implements ASTTransformatio
|
||||
private void visitAnnotatedNode(AnnotatedNode annotatedNode) {
|
||||
if (annotatedNode != null) {
|
||||
for (AnnotationNode annotationNode : annotatedNode.getAnnotations()) {
|
||||
if (this.interestingAnnotationNames.contains(annotationNode
|
||||
.getClassNode().getName())) {
|
||||
if (this.interestingAnnotationNames
|
||||
.contains(annotationNode.getClassNode().getName())) {
|
||||
this.annotationNodes.add(annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +84,16 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
||||
|
||||
private void processGrabMetadataAnnotation(AnnotationNode annotationNode) {
|
||||
Expression valueExpression = annotationNode.getMember("value");
|
||||
List<Map<String, String>> metadataDependencies = createDependencyMaps(valueExpression);
|
||||
List<Map<String, String>> metadataDependencies = createDependencyMaps(
|
||||
valueExpression);
|
||||
updateArtifactCoordinatesResolver(metadataDependencies);
|
||||
}
|
||||
|
||||
private List<Map<String, String>> createDependencyMaps(Expression valueExpression) {
|
||||
Map<String, String> dependency = null;
|
||||
|
||||
List<ConstantExpression> constantExpressions = getConstantExpressions(valueExpression);
|
||||
List<ConstantExpression> constantExpressions = getConstantExpressions(
|
||||
valueExpression);
|
||||
List<Map<String, String>> dependencies = new ArrayList<Map<String, String>>(
|
||||
constantExpressions.size());
|
||||
|
||||
@@ -131,7 +133,8 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private List<ConstantExpression> getConstantExpressions(ListExpression valueExpression) {
|
||||
private List<ConstantExpression> getConstantExpressions(
|
||||
ListExpression valueExpression) {
|
||||
List<ConstantExpression> expressions = new ArrayList<ConstantExpression>();
|
||||
for (Expression expression : valueExpression.getExpressions()) {
|
||||
if (expression instanceof ConstantExpression
|
||||
@@ -139,8 +142,9 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
||||
expressions.add((ConstantExpression) expression);
|
||||
}
|
||||
else {
|
||||
reportError("Each entry in the array must be an "
|
||||
+ "inline string constant", expression);
|
||||
reportError(
|
||||
"Each entry in the array must be an " + "inline string constant",
|
||||
expression);
|
||||
}
|
||||
}
|
||||
return expressions;
|
||||
@@ -159,8 +163,8 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
||||
List<Dependencies> managedDependencies = new ArrayList<Dependencies>(uris.length);
|
||||
for (URI uri : uris) {
|
||||
try {
|
||||
managedDependencies.add(new PropertiesFileDependencies(uri.toURL()
|
||||
.openStream()));
|
||||
managedDependencies
|
||||
.add(new PropertiesFileDependencies(uri.toURL().openStream()));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Failed to parse '" + uris[0]
|
||||
@@ -168,8 +172,8 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
||||
}
|
||||
}
|
||||
|
||||
this.resolutionContext.setManagedDependencies(ManagedDependencies
|
||||
.get(managedDependencies));
|
||||
this.resolutionContext
|
||||
.setManagedDependencies(ManagedDependencies.get(managedDependencies));
|
||||
}
|
||||
|
||||
private void handleDuplicateGrabMetadataAnnotation(AnnotationNode annotationNode) {
|
||||
@@ -180,13 +184,14 @@ public class GrabMetadataTransformation extends AnnotatedNodeASTTransformation {
|
||||
}
|
||||
|
||||
private void reportError(String message, ASTNode node) {
|
||||
getSourceUnit().getErrorCollector().addErrorAndContinue(
|
||||
createSyntaxErrorMessage(message, node));
|
||||
getSourceUnit().getErrorCollector()
|
||||
.addErrorAndContinue(createSyntaxErrorMessage(message, node));
|
||||
}
|
||||
|
||||
private Message createSyntaxErrorMessage(String message, ASTNode node) {
|
||||
return new SyntaxErrorMessage(new SyntaxException(message, node.getLineNumber(),
|
||||
node.getColumnNumber(), node.getLastLineNumber(),
|
||||
node.getLastColumnNumber()), getSourceUnit());
|
||||
return new SyntaxErrorMessage(
|
||||
new SyntaxException(message, node.getLineNumber(), node.getColumnNumber(),
|
||||
node.getLastLineNumber(), node.getLastColumnNumber()),
|
||||
getSourceUnit());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,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));
|
||||
}
|
||||
@@ -88,9 +89,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;
|
||||
}
|
||||
|
||||
@@ -56,9 +56,11 @@ import groovy.lang.GroovyCodeSource;
|
||||
* <ul>
|
||||
* <li>{@link CompilerAutoConfiguration} strategies will be read from
|
||||
* <code>META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration</code>
|
||||
* (per the standard java {@link ServiceLoader} contract) and applied during compilation</li>
|
||||
* (per the standard java {@link ServiceLoader} contract) and applied during compilation
|
||||
* </li>
|
||||
*
|
||||
* <li>Multiple classes can be returned if the Groovy source defines more than one Class</li>
|
||||
* <li>Multiple classes can be returned if the Groovy source defines more than one Class
|
||||
* </li>
|
||||
*
|
||||
* <li>Generated class files can also be loaded using
|
||||
* {@link ClassLoader#getResource(String)}</li>
|
||||
@@ -94,8 +96,8 @@ public class GroovyCompiler {
|
||||
|
||||
GrapeEngineInstaller.install(grapeEngine);
|
||||
|
||||
this.loader.getConfiguration().addCompilationCustomizers(
|
||||
new CompilerAutoConfigureCustomizer());
|
||||
this.loader.getConfiguration()
|
||||
.addCompilationCustomizers(new CompilerAutoConfigureCustomizer());
|
||||
if (configuration.isAutoconfigure()) {
|
||||
this.compilerAutoConfigurations = ServiceLoader
|
||||
.load(CompilerAutoConfiguration.class);
|
||||
@@ -110,8 +112,8 @@ public class GroovyCompiler {
|
||||
this.loader, resolutionContext, this.compilerAutoConfigurations));
|
||||
this.transformations.add(new GroovyBeansTransformation());
|
||||
if (this.configuration.isGuessDependencies()) {
|
||||
this.transformations.add(new ResolveDependencyCoordinatesTransformation(
|
||||
resolutionContext));
|
||||
this.transformations.add(
|
||||
new ResolveDependencyCoordinatesTransformation(resolutionContext));
|
||||
}
|
||||
for (ASTTransformation transformation : ServiceLoader
|
||||
.load(SpringBootAstTransformation.class)) {
|
||||
@@ -173,8 +175,8 @@ public class GroovyCompiler {
|
||||
* @throws CompilationFailedException
|
||||
* @throws IOException
|
||||
*/
|
||||
public Class<?>[] compile(String... sources) throws CompilationFailedException,
|
||||
IOException {
|
||||
public Class<?>[] compile(String... sources)
|
||||
throws CompilationFailedException, IOException {
|
||||
|
||||
this.loader.clearCache();
|
||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
@@ -272,8 +274,8 @@ public class GroovyCompiler {
|
||||
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
|
||||
throws CompilationFailedException {
|
||||
|
||||
ImportCustomizer importCustomizer = new SmartImportCustomizer(source,
|
||||
context, classNode);
|
||||
ImportCustomizer importCustomizer = new SmartImportCustomizer(source, context,
|
||||
classNode);
|
||||
ClassNode mainClassNode = getMainClass(source.getAST().getClasses());
|
||||
|
||||
// Additional auto configuration
|
||||
@@ -288,10 +290,9 @@ public class GroovyCompiler {
|
||||
GroovyCompiler.this.configuration, context, source,
|
||||
classNode);
|
||||
}
|
||||
autoConfiguration
|
||||
.apply(GroovyCompiler.this.loader,
|
||||
GroovyCompiler.this.configuration, context, source,
|
||||
classNode);
|
||||
autoConfiguration.apply(GroovyCompiler.this.loader,
|
||||
GroovyCompiler.this.configuration, context, source,
|
||||
classNode);
|
||||
}
|
||||
}
|
||||
importCustomizer.call(source, context, classNode);
|
||||
|
||||
@@ -95,8 +95,8 @@ public final class RepositoryConfigurationFactory {
|
||||
.getEffectiveSettings();
|
||||
}
|
||||
catch (SettingsBuildingException ex) {
|
||||
throw new IllegalStateException("Failed to build settings from "
|
||||
+ settingsFile, ex);
|
||||
throw new IllegalStateException(
|
||||
"Failed to build settings from " + settingsFile, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,14 +38,14 @@ import groovy.lang.Grab;
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Order(ResolveDependencyCoordinatesTransformation.ORDER)
|
||||
public class ResolveDependencyCoordinatesTransformation extends
|
||||
AnnotatedNodeASTTransformation {
|
||||
public class ResolveDependencyCoordinatesTransformation
|
||||
extends AnnotatedNodeASTTransformation {
|
||||
|
||||
public static final int ORDER = GrabMetadataTransformation.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;
|
||||
|
||||
|
||||
@@ -40,8 +40,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;
|
||||
@@ -50,8 +50,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
|
||||
|
||||
@@ -49,8 +49,8 @@ public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
imports.addStarImports("javax.jms", "org.springframework.jms.annotation",
|
||||
"org.springframework.jms.config", "org.springframework.jms.core",
|
||||
"org.springframework.jms.listener",
|
||||
"org.springframework.jms.listener.adapter").addImports(
|
||||
org.springframework.boot.groovy.EnableJmsMessaging.class
|
||||
"org.springframework.jms.listener.adapter")
|
||||
.addImports(org.springframework.boot.groovy.EnableJmsMessaging.class
|
||||
.getCanonicalName());
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,9 @@ public class RabbitCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
"org.springframework.amqp.rabbit.connection",
|
||||
"org.springframework.amqp.rabbit.listener",
|
||||
"org.springframework.amqp.rabbit.listener.adapter",
|
||||
"org.springframework.amqp.core").addImports(
|
||||
org.springframework.boot.groovy.EnableRabbitMessaging.class.getName());
|
||||
"org.springframework.amqp.core")
|
||||
.addImports(org.springframework.boot.groovy.EnableRabbitMessaging.class
|
||||
.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ManagedDependenciesArtifactCoordinatesResolver implements
|
||||
ArtifactCoordinatesResolver {
|
||||
public class ManagedDependenciesArtifactCoordinatesResolver
|
||||
implements ArtifactCoordinatesResolver {
|
||||
|
||||
private final ManagedDependencies dependencies;
|
||||
|
||||
@@ -35,7 +35,8 @@ public class ManagedDependenciesArtifactCoordinatesResolver implements
|
||||
this(ManagedDependencies.get());
|
||||
}
|
||||
|
||||
public ManagedDependenciesArtifactCoordinatesResolver(ManagedDependencies dependencies) {
|
||||
public ManagedDependenciesArtifactCoordinatesResolver(
|
||||
ManagedDependencies dependencies) {
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
|
||||
@@ -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("*", "*", "*", "*"));
|
||||
@@ -196,8 +197,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;
|
||||
}
|
||||
@@ -236,8 +237,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;
|
||||
}
|
||||
@@ -295,8 +296,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);
|
||||
}
|
||||
@@ -311,8 +312,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,
|
||||
|
||||
@@ -55,8 +55,8 @@ import org.springframework.boot.cli.util.Log;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class SettingsXmlRepositorySystemSessionAutoConfiguration implements
|
||||
RepositorySystemSessionAutoConfiguration {
|
||||
public class SettingsXmlRepositorySystemSessionAutoConfiguration
|
||||
implements RepositorySystemSessionAutoConfiguration {
|
||||
|
||||
private final String homeDir;
|
||||
|
||||
@@ -75,14 +75,15 @@ public class SettingsXmlRepositorySystemSessionAutoConfiguration implements
|
||||
Settings settings = loadSettings();
|
||||
SettingsDecryptionResult decryptionResult = decryptSettings(settings);
|
||||
if (!decryptionResult.getProblems().isEmpty()) {
|
||||
Log.error("Maven settings decryption failed. Some Maven repositories may be inaccessible");
|
||||
Log.error(
|
||||
"Maven settings decryption failed. Some Maven repositories may be inaccessible");
|
||||
// Continue - the encrypted credentials may not be used
|
||||
}
|
||||
|
||||
session.setOffline(settings.isOffline());
|
||||
session.setMirrorSelector(createMirrorSelector(settings));
|
||||
session.setAuthenticationSelector(createAuthenticationSelector(decryptionResult
|
||||
.getServers()));
|
||||
session.setAuthenticationSelector(
|
||||
createAuthenticationSelector(decryptionResult.getServers()));
|
||||
session.setProxySelector(createProxySelector(decryptionResult.getProxies()));
|
||||
|
||||
String localRepository = settings.getLocalRepository();
|
||||
@@ -102,8 +103,8 @@ public class SettingsXmlRepositorySystemSessionAutoConfiguration implements
|
||||
.getEffectiveSettings();
|
||||
}
|
||||
catch (SettingsBuildingException ex) {
|
||||
throw new IllegalStateException("Failed to build settings from "
|
||||
+ settingsFile, ex);
|
||||
throw new IllegalStateException(
|
||||
"Failed to build settings from " + settingsFile, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +129,8 @@ public class SettingsXmlRepositorySystemSessionAutoConfiguration implements
|
||||
field.set(target, value);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to set field '" + fieldName
|
||||
+ "' on '" + target + "'", e);
|
||||
throw new IllegalStateException(
|
||||
"Failed to set field '" + fieldName + "' on '" + target + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +160,10 @@ public class SettingsXmlRepositorySystemSessionAutoConfiguration implements
|
||||
Authentication authentication = new AuthenticationBuilder()
|
||||
.addUsername(proxy.getUsername()).addPassword(proxy.getPassword())
|
||||
.build();
|
||||
selector.add(new org.eclipse.aether.repository.Proxy(proxy.getProtocol(),
|
||||
proxy.getHost(), proxy.getPort(), authentication), proxy
|
||||
.getNonProxyHosts());
|
||||
selector.add(
|
||||
new org.eclipse.aether.repository.Proxy(proxy.getProtocol(),
|
||||
proxy.getHost(), proxy.getPort(), authentication),
|
||||
proxy.getNonProxyHosts());
|
||||
}
|
||||
return selector;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ final class SummaryProgressReporter implements ProgressReporter {
|
||||
|
||||
private boolean finished;
|
||||
|
||||
public SummaryProgressReporter(DefaultRepositorySystemSession session, PrintStream out) {
|
||||
public SummaryProgressReporter(DefaultRepositorySystemSession session,
|
||||
PrintStream out) {
|
||||
this.out = out;
|
||||
|
||||
session.setTransferListener(new AbstractTransferListener() {
|
||||
@@ -74,13 +75,15 @@ final class SummaryProgressReporter implements ProgressReporter {
|
||||
}
|
||||
|
||||
private void reportProgress() {
|
||||
if (!this.finished && System.currentTimeMillis() - this.startTime > INITIAL_DELAY) {
|
||||
if (!this.finished
|
||||
&& System.currentTimeMillis() - this.startTime > INITIAL_DELAY) {
|
||||
if (!this.started) {
|
||||
this.started = true;
|
||||
this.out.print("Resolving dependencies..");
|
||||
this.lastProgressTime = System.currentTimeMillis();
|
||||
}
|
||||
else if (System.currentTimeMillis() - this.lastProgressTime > PROGRESS_DELAY) {
|
||||
else if (System.currentTimeMillis()
|
||||
- this.lastProgressTime > PROGRESS_DELAY) {
|
||||
this.out.print(".");
|
||||
this.lastProgressTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public 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);
|
||||
|
||||
Reference in New Issue
Block a user