]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc/src/main/java/org/argeo/slc/ant/SlcAntConfig.java
Improve reporting
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / ant / SlcAntConfig.java
index 93502245d080a862c27304526d68c7156461de19..6085c663531082223c70947cc2c11852170e44e1 100644 (file)
@@ -106,9 +106,13 @@ import org.argeo.slc.core.test.WritableTestRun;
  */\r
 public class SlcAntConfig {\r
        // SLC ROOT PROPERTIES\r
+       /** Property for the root file (SLC root property file). */\r
        public final static String ROOT_FILE_PROPERTY = "slc.rootFile";\r
+       /** Property for the root dir (SLC root property file). */\r
        public final static String ROOT_DIR_PROPERTY = "slc.rootDir";\r
+       /** Property for the conf dir (SLC root property file). */\r
        public final static String CONF_DIR_PROPERTY = "slc.confDir";\r
+       /** Property for the work dir (SLC root property file). */\r
        public final static String WORK_DIR_PROPERTY = "slc.workDir";\r
        /**\r
         * Comma-separated list of property file names to load from the conf dir and\r
@@ -123,6 +127,7 @@ public class SlcAntConfig {
        public static String DEFAULT_TEST_RUN_PROPERTY = "slc.defaultTestRun";\r
 \r
        // SLC LOCAL PROPERTIES\r
+       /** Property for the dir description (SLC local property file). */\r
        public static String DIR_DESCRIPTION_PROPERTY = "slc.dirDescription";\r
 \r
        private String slcRootFileName = "slcRoot.properties";\r
@@ -136,13 +141,16 @@ public class SlcAntConfig {
         * \r
         * @param project\r
         *            the Ant <code>Project</code> being run.\r
+        * @return whether the project could be initialized for SLC usage (e.g.\r
+        *         presence of an SLC root file)\r
         */\r
-       public void initProject(Project project) {\r
+       public boolean initProject(Project project) {\r
                File projectBaseDir = project.getBaseDir();\r
                File slcRootFile = findSlcRootFile(projectBaseDir);\r
                if (slcRootFile == null) {\r
-                       throw new SlcAntException("Cannot find SLC root file");\r
+                       return false;\r
                }\r
+\r
                // pass the project properties through the System properties\r
                System.getProperties().putAll((Map<?, ?>) project.getUserProperties());\r
                Properties all = prepareAllProperties(slcRootFile);\r
@@ -152,6 +160,7 @@ public class SlcAntConfig {
                                project.setUserProperty(key, all.getProperty(key));\r
                        }\r
                }\r
+               return true;\r
        }\r
 \r
        /**\r
@@ -165,6 +174,8 @@ public class SlcAntConfig {
         */\r
        protected Properties prepareAllProperties(File slcRootFile) {\r
                try {\r
+                       final String fileUrlPrefix = "";\r
+\r
                        Properties all = new Properties();\r
                        all.putAll(System.getProperties());\r
                        all.put(ROOT_FILE_PROPERTY, slcRootFile.getCanonicalPath());\r
@@ -175,14 +186,16 @@ public class SlcAntConfig {
                        final File workDir;\r
                        // Root dir\r
                        final File rootDir = slcRootFile.getParentFile();\r
-                       all.setProperty(ROOT_DIR_PROPERTY, rootDir.getCanonicalPath());\r
+                       all.setProperty(ROOT_DIR_PROPERTY, fileUrlPrefix\r
+                                       + rootDir.getCanonicalPath());\r
 \r
                        // Conf dir\r
                        if (all.getProperty(CONF_DIR_PROPERTY) == null) {\r
                                confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY,\r
                                                rootDir.getAbsolutePath() + "/../conf"))\r
                                                .getCanonicalFile();\r
-                               all.setProperty(CONF_DIR_PROPERTY, confDir.getAbsolutePath());\r
+                               all.setProperty(CONF_DIR_PROPERTY, fileUrlPrefix\r
+                                               + confDir.getAbsolutePath());\r
                        } else {\r
                                confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
                                                .getCanonicalFile();\r
@@ -193,7 +206,8 @@ public class SlcAntConfig {
                                workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY,\r
                                                rootDir.getAbsolutePath() + "/../work"))\r
                                                .getCanonicalFile();\r
-                               all.setProperty(WORK_DIR_PROPERTY, workDir.getAbsolutePath());\r
+                               all.setProperty(WORK_DIR_PROPERTY, fileUrlPrefix\r
+                                               + workDir.getAbsolutePath());\r
                        } else {\r
                                workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
                                                .getCanonicalFile();\r