[bs-134] CLI app cannot resolve snapshot jars

Moved the Grab.addResolver() call to before any other compiler
customizations.

That got it working locally (removed ~/.m2 and ~/.groovy/grapes)
but still not working on cloudfoundry for some reason.  We need
more help from buildpacks there (to get a cache going for the
grapes), but there seems to be more than just that stopping it
(maybe just timeouts?).

[#50351963]
pull/1/merge
Dave Syer 12 years ago
parent a71bb1c972
commit 6e52d7dd39

@ -16,6 +16,7 @@
package org.springframework.bootstrap.cli.compiler;
import groovy.grape.Grape;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyClassLoader.ClassCollector;
@ -23,7 +24,9 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import org.codehaus.groovy.ast.ClassNode;
@ -69,6 +72,10 @@ public class GroovyCompiler {
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
this.loader = new ExtendedGroovyClassLoader(getClass().getClassLoader(),
compilerConfiguration);
// FIXME: allow the extra resolvers to be switched on (off by default)
addExtraResolvers();
compilerConfiguration
.addCompilationCustomizers(new CompilerAutoConfigureCustomizer());
}
@ -135,6 +142,7 @@ public class GroovyCompiler {
@Override
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
throws CompilationFailedException {
ImportCustomizer importCustomizer = new ImportCustomizer();
ServiceLoader<CompilerAutoConfiguration> customizers = ServiceLoader.load(
@ -177,4 +185,14 @@ public class GroovyCompiler {
}
private void addExtraResolvers() {
Map<String, Object> resolver = new HashMap<String, Object>();
resolver.put("name", "spring-milestone");
resolver.put("root", "http://repo.springsource.org/milestone");
Grape.addResolver(resolver);
resolver.put("name", "spring-snapshot");
resolver.put("root", "http://repo.springsource.org/snapshot");
Grape.addResolver(resolver);
}
}

@ -38,9 +38,9 @@ public class SpringBatchCompilerAutoConfiguration extends CompilerAutoConfigurat
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses("org.springframework.batch.core.Job").add(
"org.springframework.batch", "spring-batch-core", "2.2.0.RC1");
"org.springframework.batch", "spring-batch-core", "2.2.0.RC2");
dependencies.ifAnyMissingClasses("org.springframework.jdbc.core.JdbcTemplate")
.add("org.springframework", "spring-jdbc", "4.0.0.BOOTSTRAP-SNAPSHOT");
.add("org.springframework", "spring-jdbc", "4.0.0.BUILD-SNAPSHOT");
}
@Override

@ -16,12 +16,8 @@
package org.springframework.bootstrap.cli.compiler.autoconfigure;
import groovy.grape.Grape;
import groovy.lang.GroovyClassLoader;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.groovy.ast.AnnotationNode;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.classgen.GeneratorContext;
@ -44,7 +40,8 @@ public class SpringBootstrapCompilerAutoConfiguration extends CompilerAutoConfig
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses(
"org.springframework.bootstrap.SpringApplication").add(
"org.springframework.bootstrap", "spring-bootstrap", "0.5.0.BUILD-SNAPSHOT");
"org.springframework.bootstrap", "spring-bootstrap",
"0.5.0.BUILD-SNAPSHOT");
dependencies.ifAnyResourcesPresent("logback.xml").add("ch.qos.logback",
"logback-classic", "1.0.7");
dependencies.ifNotAdded("cg.qos.logback", "logback-classic")
@ -90,18 +87,6 @@ public class SpringBootstrapCompilerAutoConfiguration extends CompilerAutoConfig
if (true) { // FIXME: add switch for auto config
addEnableAutoConfigurationAnnotation(source, classNode);
}
// FIXME: allow the extra resolvers to be switched on (off by default)
addExtraResolvers();
}
private void addExtraResolvers() {
Map<String, Object> resolver = new HashMap<String, Object>();
resolver.put("name", "spring-milestone");
resolver.put("root", "http://repo.springframework.org/milestone");
Grape.addResolver(resolver);
resolver.put("name", "spring-snapshot");
resolver.put("root", "http://repo.springframework.org/snapshot");
Grape.addResolver(resolver);
}
private void addEnableAutoConfigurationAnnotation(SourceUnit source,

@ -34,7 +34,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies
.ifAnyMissingClasses("org.springframework.web.servlet.mvc.Controller")
.add("org.springframework", "spring-webmvc", "4.0.0.BOOTSTRAP-SNAPSHOT");
.add("org.springframework", "spring-webmvc", "4.0.0.BUILD-SNAPSHOT");
dependencies.ifAnyMissingClasses("org.apache.catalina.startup.Tomcat",
"org.eclipse.jetty.server.Server").add("org.eclipse.jetty",

Loading…
Cancel
Save