[bs-72] Add Batch compiler by default

We could take this out again when we decide what to do about plugins
but it's good to have it in for now because it shows how to do it,
and exposes some holes.  The job.groovy script now works, but
a lot of it should be defaulted through auto-configuration.

(See also [bs-73] for a non-Batch related bug.)

[#48716881]
This commit is contained in:
Dave Syer
2013-04-25 09:09:46 +01:00
parent 214b3a28db
commit c9a8cb9341
4 changed files with 98 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.customizers.CompilationCustomizer;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.springframework.bootstrap.cli.compiler.autoconfigure.SpringBatchCompilerAutoConfiguration;
import org.springframework.bootstrap.cli.compiler.autoconfigure.SpringBootstrapCompilerAutoConfiguration;
import org.springframework.bootstrap.cli.compiler.autoconfigure.SpringMvcCompilerAutoConfiguration;
@@ -54,6 +55,7 @@ public class GroovyCompiler {
private static final CompilerAutoConfiguration[] COMPILER_AUTO_CONFIGURATIONS = {
new SpringBootstrapCompilerAutoConfiguration(),
new SpringMvcCompilerAutoConfiguration(),
new SpringBatchCompilerAutoConfiguration(),
new SpringBootstrapCompilerAutoConfiguration() };
private GroovyCompilerConfiguration configuration;

View File

@@ -38,7 +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.1.9.RELEASE");
"org.springframework.batch", "spring-batch-core", "2.2.0.RC1");
dependencies.ifAnyMissingClasses("org.springframework.jdbc.core.JdbcTemplate")
.add("org.springframework", "spring-jdbc", "4.0.0.BOOTSTRAP-SNAPSHOT");
}
@Override
@@ -59,6 +61,7 @@ public class SpringBatchCompilerAutoConfiguration extends CompilerAutoConfigurat
"org.springframework.batch.core.JobParameter",
"org.springframework.batch.core.JobParameters",
"org.springframework.batch.core.launch.JobLauncher",
"org.springframework.batch.core.converter.JobParametersConverter",
"org.springframework.batch.core.converter.DefaultJobParametersConverter");
}
}

View File

@@ -55,7 +55,8 @@ public class SpringBootstrapCompilerAutoConfiguration extends CompilerAutoConfig
@Override
public void applyImports(ImportCustomizer imports) {
imports.addImports("javax.sql.DataSource",
imports.addImports("javax.sql.DataSource", "javax.annotation.PostConstruct",
"javax.annotation.PreDestroy",
"org.springframework.stereotype.Controller",
"org.springframework.stereotype.Service",
"org.springframework.stereotype.Component",
@@ -67,6 +68,8 @@ public class SpringBootstrapCompilerAutoConfiguration extends CompilerAutoConfig
"org.springframework.context.annotation.Scope",
"org.springframework.context.annotation.Configuration",
"org.springframework.context.annotation.Bean",
"org.springframework.core.io.ResourceLoader",
"org.springframework.bootstrap.CommandLineRunner",
"org.springframework.bootstrap.context.annotation.EnableAutoConfiguration");
imports.addStarImports("org.springframework.stereotype");
}