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=410098d212aceee51bdc7d31a8c87edd0b66e0a1;hb=4af418ad1d16e736d7e205567d994eb73c8f7e83;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..410098d21 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 @@ -19,7 +19,6 @@ import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.helper.ProjectHelper2; -import org.apache.tools.ant.listener.CommonsLoggingListener; import org.argeo.slc.core.SlcException; import org.argeo.slc.core.process.SlcExecution; import org.argeo.slc.core.structure.SimpleSElement; @@ -112,11 +111,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 +133,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 +149,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 +173,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()); @@ -246,7 +260,7 @@ public class AntSlcApplication { } } - project.addBuildListener(new CommonsLoggingListener()); + //project.addBuildListener(new CommonsLoggingListener()); ListableBeanFactory context = (ListableBeanFactory) project .getReference(AntConstants.REF_ROOT_CONTEXT);