import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.DefaultResourceLoader;
log.debug("workDir=" + workDir);
}
- // Spring initialization
- ConfigurableApplicationContext ctx = createExecutionContext(slcExecution);
-
// Ant coordinates
String scriptRelativePath = findAntScript(slcExecution);
List<String> targets = findAntTargets(slcExecution);
+ // Spring initialization
+ ConfigurableApplicationContext ctx = createExecutionContext(slcExecution);
+
// Ant project initialization
Project project = new Project();
AntExecutionContext executionContext = new AntExecutionContext(project);
project.addReference(AntConstants.REF_ROOT_CONTEXT, ctx);
project.addReference(AntConstants.REF_SLC_EXECUTION, slcExecution);
- initProject(project, properties, references);
- parseProject(project, scriptRelativePath);
- // Execute project
- initStructure(project, scriptRelativePath);
- runProject(project, targets);
+ try {
+ initProject(project, properties, references);
+ parseProject(project, scriptRelativePath);
- if (executionOutput != null)
- executionOutput.postExecution(executionContext);
+ // Execute project
+ initStructure(project, scriptRelativePath);
+ runProject(project, targets);
- ctx.close();
+ if (executionOutput != null)
+ executionOutput.postExecution(executionContext);
+ } finally {
+ ctx.close();
+ }
}
protected void initSystemProperties(Properties userProperties) {
try {
if (rootDir != null)
- System.setProperty(AntConstants.ROOT_DIR_PROPERTY, rootDir
- .getURL().toString());
+ setSystemPropertyForRes(AntConstants.ROOT_DIR_PROPERTY, rootDir);
if (confDir != null)
- System.setProperty(AntConstants.CONF_DIR_PROPERTY, confDir
- .getURL().toString());
+ setSystemPropertyForRes(AntConstants.CONF_DIR_PROPERTY, confDir);
if (workDir != null)
System.setProperty(AntConstants.WORK_DIR_PROPERTY, workDir
.getCanonicalPath());
IOUtils.closeQuietly(in);
}
- for (String key : slcProperties.stringPropertyNames()) {
+ for (Object obj : slcProperties.keySet()) {
+ String key = obj.toString();
if (!System.getProperties().containsKey(key)) {
String value = SystemPropertyUtils
.resolvePlaceholders(slcProperties
}
}
+ /**
+ * Set property as an absolute file path if the resource can be located on
+ * the file system, or as an url.
+ */
+ private void setSystemPropertyForRes(String key, Resource res)
+ throws IOException {
+ String value = null;
+ try {
+ value = res.getFile().getCanonicalPath();
+ } catch (IOException e) {
+ value = res.getURL().toString();
+ }
+ System.setProperty(key, value);
+ }
+
protected ConfigurableApplicationContext createExecutionContext(
SlcExecution slcExecution) {
try {
String runtimeStr = slcExecution.getAttributes().get(
AntConstants.EXECATTR_RUNTIME);
if (runtimeStr == null)
- runtimeStr = "default";
+ runtimeStr = System.getProperty(AntConstants.RUNTIME_PROPERTY,
+ "default");
ResourceLoader rl = new DefaultResourceLoader(getClass()
.getClassLoader());