]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java
Simplify new runtime
[gpl/argeo-slc.git] / org.argeo.slc.agent / src / main / java / org / argeo / slc / ant / AntSlcApplication.java
index 76865aef57d8fafe032add61fd3f4a0f00d81632..1a69c493bf7509eac155dfbc3d4e4e10ab15f8da 100644 (file)
@@ -17,6 +17,7 @@ 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.DefaultSRegistry;
 import org.argeo.slc.core.structure.SimpleSElement;
@@ -47,6 +48,20 @@ public class AntSlcApplication {
 
        public void init() {
                try {
+                       try {
+                               if (rootDir != null)
+                                       System.setProperty(SlcAntConstants.ROOT_DIR_PROPERTY,
+                                                       rootDir.getURL().toString());
+                               if (confDir != null)
+                                       System.setProperty(SlcAntConstants.CONF_DIR_PROPERTY,
+                                                       confDir.getURL().toString());
+                       } catch (IOException e) {
+                               throw new SlcAntException("Cannot interpret dir as URL.", e);
+                       }
+                       if (workDir != null)
+                               System.setProperty(SlcAntConstants.WORK_DIR_PROPERTY, workDir
+                                               .toString());
+
                        if (confDir != null && contextLocation == null) {
                                contextLocation = confDir
                                                .createRelative("applicationContext.xml");
@@ -70,24 +85,13 @@ public class AntSlcApplication {
 
        public SlcExecutionContext execute(SlcExecution slcExecution,
                        Properties properties, Map<String, Object> references) {
+               log.info("### Start SLC execution " + slcExecution.getUuid() + " ###");
                if (log.isDebugEnabled()) {
-                       log.debug("### Start SLC execution " + slcExecution.getUuid()
-                                       + " ###");
                        log.debug("rootDir=" + rootDir);
                        log.debug("confDir=" + confDir);
                        log.debug("workDir=" + workDir);
                }
 
-               if (rootDir != null)
-                       properties.put(SlcAntConstants.ROOT_DIR_PROPERTY, rootDir
-                                       .toString());
-               if (confDir != null)
-                       properties.put(SlcAntConstants.CONF_DIR_PROPERTY, confDir
-                                       .toString());
-               if (workDir != null)
-                       properties.put(SlcAntConstants.WORK_DIR_PROPERTY, workDir
-                                       .toString());
-
                // Ant coordinates
                Resource script = findAntScript(slcExecution);
                List<String> targets = findAntTargets(slcExecution);
@@ -133,7 +137,7 @@ public class AntSlcApplication {
                                log.trace("script(absolute)=" + script);
                        if (script.exists())
                                return script;
-                       
+
                        script = new FileSystemResource(scriptStr);
                        if (log.isTraceEnabled())
                                log.trace("script(fs)=" + script);
@@ -169,6 +173,11 @@ public class AntSlcApplication {
                                        .toString()));
                }
 
+               if (System.getProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {
+                       System.setProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY,
+                                       "defaultTestRun");
+               }
+
                try {
                        GenericApplicationContext ctx = new GenericApplicationContext(
                                        context);
@@ -253,7 +262,6 @@ public class AntSlcApplication {
                        }
                        log.debug("scriptPath=" + scriptPath);
 
-                       List<String> dirNames = new Vector<String>();
                        StringTokenizer st = new StringTokenizer(scriptPath, "/");
                        TreeSPath currPath = null;
                        while (st.hasMoreTokens()) {