]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.agent/src/main/java/org/argeo/slc/cli/DefaultSlcRuntime.java
Prepare for release candidate
[gpl/argeo-slc.git] / org.argeo.slc.agent / src / main / java / org / argeo / slc / cli / DefaultSlcRuntime.java
index fcf27246462847e5db34c439298451b0d2ee9dbf..3596dd61c6411141406e4c6172d0e446e8419e86 100644 (file)
@@ -14,11 +14,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.ant.AntExecutionContext;
 import org.argeo.slc.ant.AntSlcApplication;
-import org.argeo.slc.ant.SlcAntConstants;
-import org.argeo.slc.ant.SlcAntException;
+import org.argeo.slc.ant.AntConstants;
 import org.argeo.slc.core.SlcException;
 import org.argeo.slc.core.process.SlcExecution;
-import org.argeo.slc.runtime.SlcExecutionContext;
 import org.argeo.slc.runtime.SlcExecutionOutput;
 import org.argeo.slc.spring.SpringUtils;
 import org.springframework.core.io.DefaultResourceLoader;
@@ -71,6 +69,10 @@ public class DefaultSlcRuntime {
 
                Resource scriptRes = findScript(script);
                Resource slcRootFile = findSlcRootFile(scriptRes);
+               if (slcRootFile == null)
+                       throw new SlcException(
+                                       "Could not find any SLC root file, "
+                                                       + "please configure one at the root of your scripts hierarchy.");
 
                SlcExecution slcExecution = createSlcExecution(runtime, slcRootFile,
                                scriptRes, targets);
@@ -101,21 +103,21 @@ public class DefaultSlcRuntime {
                        slcExecution.setHost(SlcExecution.UNKOWN_HOST);
                }
 
-               slcExecution.setType(SlcAntConstants.EXECTYPE_SLC_ANT);
+               slcExecution.setType(AntConstants.EXECTYPE_SLC_ANT);
 
                slcExecution.setUser(System.getProperty("user.name"));
 
                if (runtimeStr != null)
-                       slcExecution.getAttributes().put(SlcAntConstants.EXECATTR_RUNTIME,
+                       slcExecution.getAttributes().put(AntConstants.EXECATTR_RUNTIME,
                                        runtimeStr);
                String scriptRelativePath = SpringUtils.extractRelativePath(SpringUtils
                                .getParent(slcRootFile), script);
 
-               slcExecution.getAttributes().put(SlcAntConstants.EXECATTR_ANT_FILE,
+               slcExecution.getAttributes().put(AntConstants.EXECATTR_ANT_FILE,
                                scriptRelativePath);
                if (targets != null)
-                       slcExecution.getAttributes().put(
-                                       SlcAntConstants.EXECATTR_ANT_TARGETS, targets);
+                       slcExecution.getAttributes().put(AntConstants.EXECATTR_ANT_TARGETS,
+                                       targets);
 
                slcExecution.setStatus(SlcExecution.STATUS_SCHEDULED);
                return slcExecution;
@@ -139,7 +141,7 @@ public class DefaultSlcRuntime {
 
                        // Conf dir
                        String confDirStr = rootProps
-                                       .getProperty(SlcAntConstants.CONF_DIR_PROPERTY);
+                                       .getProperty(AntConstants.CONF_DIR_PROPERTY);
                        if (confDirStr != null)
                                confDir = new DefaultResourceLoader(application.getClass()
                                                .getClassLoader()).getResource(confDirStr);
@@ -152,7 +154,7 @@ public class DefaultSlcRuntime {
 
                        // Work dir
                        String workDirStr = rootProps
-                                       .getProperty(SlcAntConstants.WORK_DIR_PROPERTY);
+                                       .getProperty(AntConstants.WORK_DIR_PROPERTY);
                        if (workDirStr != null) {
                                workDir = new File(workDirStr);
                        }
@@ -197,6 +199,8 @@ public class DefaultSlcRuntime {
                try {
                        Resource slcRootFile = currDir.createRelative(SLC_ROOT_FILE_NAME);
                        if (slcRootFile.exists()) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Found SLC root file: " + slcRootFile);
                                return slcRootFile;
                        } else {
                                String currPath = currDir.getURL().getPath();
@@ -218,7 +222,7 @@ public class DefaultSlcRuntime {
                try {
                        p.load(in);
                } catch (IOException e) {
-                       throw new SlcAntException("Cannot read SLC root file", e);
+                       throw new SlcException("Cannot read SLC root file", e);
                }
                return p;
        }