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