X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.agent%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fant%2FAntSlcApplication.java;h=37bdff0dce8f93f352dd6dbfaf4e8e5fb1306998;hb=4a8845940afb3a147f23dedbf75dea5e26103352;hp=b6c98ebbc3e44f6c571783fd190c05a0c8ce0872;hpb=c0460581ca0679267f9c66759ea9ecf598e1b6d0;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java index b6c98ebbc..37bdff0dc 100644 --- a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java +++ b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java @@ -112,11 +112,9 @@ public class AntSlcApplication { 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()); @@ -136,7 +134,8 @@ public class AntSlcApplication { 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 @@ -151,6 +150,21 @@ public class AntSlcApplication { } } + /** + * 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 { @@ -160,7 +174,8 @@ public class AntSlcApplication { 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());