[bs-24] Support multi-file compile from command line
* Each non-option arg is tested to see if it is a file * If it is .groovy (or .java) it is compiled [#48127661]
This commit is contained in:
@@ -20,11 +20,18 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.batch.support.DatabaseType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Initialize the Spring Batch schema (ignoring errors, so should be idempotent).
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class BatchDatabaseInitializer {
|
||||
|
||||
@@ -34,6 +41,9 @@ public class BatchDatabaseInitializer {
|
||||
@Autowired
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@Value("${spring.batch.schema:classpath:org/springframework/batch/core/schema-@@platform@@.sql}")
|
||||
private String schemaLocation = "classpath:org/springframework/batch/core/schema-@@platform@@.sql";
|
||||
|
||||
@PostConstruct
|
||||
protected void initialize() throws Exception {
|
||||
String platform = DatabaseType.fromMetaData(this.dataSource).toString()
|
||||
@@ -42,12 +52,9 @@ public class BatchDatabaseInitializer {
|
||||
platform = "hsqldb";
|
||||
}
|
||||
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
|
||||
populator
|
||||
.addScript(this.resourceLoader
|
||||
.getResource("org/springframework/batch/core/schema-" + platform
|
||||
+ ".sql"));
|
||||
populator.addScript(this.resourceLoader.getResource(this.schemaLocation.replace(
|
||||
"@@platform@@", platform)));
|
||||
populator.setContinueOnError(true);
|
||||
DatabasePopulatorUtils.execute(populator, this.dataSource);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.bootstrap.context.annotation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,8 +48,17 @@ public abstract class AutoConfigurationUtils {
|
||||
|
||||
public static void storeBasePackages(ConfigurableListableBeanFactory beanFactory,
|
||||
List<String> basePackages) {
|
||||
beanFactory.registerSingleton(BASE_PACKAGES_BEAN,
|
||||
Collections.unmodifiableList(basePackages));
|
||||
if (!beanFactory.containsBean(BASE_PACKAGES_BEAN)) {
|
||||
beanFactory.registerSingleton(BASE_PACKAGES_BEAN, new ArrayList<String>(
|
||||
basePackages));
|
||||
} else {
|
||||
List<String> packages = getBasePackages(beanFactory);
|
||||
for (String pkg : basePackages) {
|
||||
if (packages.contains(pkg)) {
|
||||
packages.add(pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user