Merge branch '1.2.x'
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user