import java.util.Properties;\r
import java.util.StringTokenizer;\r
\r
+import org.springframework.util.Log4jConfigurer;\r
+\r
import org.apache.tools.ant.Project;\r
\r
/** Load reference to directories from an slcRoot.properties file */\r
project.setUserProperty(key, all.getProperty(key));\r
}\r
}\r
-\r
- /*\r
- Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
-\r
- final File confDir;\r
- final File workDir;\r
- // Root dir\r
- final File rootDir = slcRootFile.getParentFile();\r
- project.setUserProperty(ROOT_DIR_PROPERTY, rootDir.getAbsolutePath());\r
-\r
- // Conf dir\r
- if (project.getUserProperty(CONF_DIR_PROPERTY) == null) {\r
- confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY, rootDir\r
- .getAbsolutePath()\r
- + "/../conf")).getAbsoluteFile();\r
- project.setUserProperty(CONF_DIR_PROPERTY, confDir\r
- .getAbsolutePath());\r
- } else {\r
- confDir = new File(project.getUserProperty(CONF_DIR_PROPERTY))\r
- .getAbsoluteFile();\r
- }\r
-\r
- // Work dir\r
- if (project.getUserProperty(WORK_DIR_PROPERTY) == null) {\r
- workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY, rootDir\r
- .getAbsolutePath()\r
- + "/../work")).getAbsoluteFile();\r
- project.setUserProperty(WORK_DIR_PROPERTY, workDir\r
- .getAbsolutePath());\r
- } else {\r
- workDir = new File(project.getUserProperty(WORK_DIR_PROPERTY))\r
- .getAbsoluteFile();\r
- }\r
-\r
- // Properties from the conf dir files\r
- Properties properties = new Properties();\r
- StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
- PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
- while (st.hasMoreTokens()) {\r
- String fileName = st.nextToken();\r
- properties.putAll(loadFile(confDir.getAbsolutePath() + "/"\r
- + fileName));\r
- }\r
-\r
- for (Object o : properties.keySet()) {\r
- String key = o.toString();\r
- if (project.getUserProperty(key) == null) {// not already set\r
- project.setUserProperty(key, properties.getProperty(key));\r
- }\r
- }\r
-\r
- // Default application context\r
- if (project.getUserProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
- project.setUserProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
- .getAbsolutePath()\r
- + "/applicationContext.xml");\r
- }\r
- // Default test run\r
- if (project.getUserProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
- project\r
- .setUserProperty(DEFAULT_TEST_RUN_PROPERTY,\r
- "defaultTestRun");\r
- }\r
- */\r
}\r
\r
public static Properties prepareAllProperties() {\r
- Properties all = new Properties();\r
- all.putAll(System.getProperties());\r
+ try {\r
+ Properties all = new Properties();\r
+ all.putAll(System.getProperties());\r
\r
- if (all.getProperty(ROOT_FILE_PROPERTY) == null) {\r
- throw new RuntimeException("System Property " + ROOT_FILE_PROPERTY\r
- + " has to be set.");\r
- }\r
+ if (all.getProperty(ROOT_FILE_PROPERTY) == null) {\r
+ throw new RuntimeException("System Property "\r
+ + ROOT_FILE_PROPERTY + " has to be set.");\r
+ }\r
\r
- File slcRootFile = new File(all.getProperty(ROOT_FILE_PROPERTY))\r
- .getAbsoluteFile();\r
- Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
-\r
- final File confDir;\r
- final File workDir;\r
- // Root dir\r
- final File rootDir = slcRootFile.getParentFile();\r
- all.setProperty(ROOT_DIR_PROPERTY, rootDir.getAbsolutePath());\r
-\r
- // Conf dir\r
- if (all.getProperty(CONF_DIR_PROPERTY) == null) {\r
- confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY, rootDir\r
- .getAbsolutePath()\r
- + "/../conf")).getAbsoluteFile();\r
- all.setProperty(CONF_DIR_PROPERTY, confDir.getAbsolutePath());\r
- } else {\r
- confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
+ File slcRootFile = new File(all.getProperty(ROOT_FILE_PROPERTY))\r
.getAbsoluteFile();\r
- }\r
+ Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
+\r
+ final File confDir;\r
+ final File workDir;\r
+ // Root dir\r
+ final File rootDir = slcRootFile.getParentFile();\r
+ all.setProperty(ROOT_DIR_PROPERTY, 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
+ } else {\r
+ confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
+ .getCanonicalFile();\r
+ }\r
\r
- // Work dir\r
- if (all.getProperty(WORK_DIR_PROPERTY) == null) {\r
- workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY, rootDir\r
- .getAbsolutePath()\r
- + "/../work")).getAbsoluteFile();\r
- all.setProperty(WORK_DIR_PROPERTY, workDir.getAbsolutePath());\r
- } else {\r
- workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
- .getAbsoluteFile();\r
- }\r
+ // Work dir\r
+ if (all.getProperty(WORK_DIR_PROPERTY) == null) {\r
+ workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY,\r
+ rootDir.getAbsolutePath() + "/../work"))\r
+ .getCanonicalFile();\r
+ all.setProperty(WORK_DIR_PROPERTY, workDir.getAbsolutePath());\r
+ } else {\r
+ workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
+ .getCanonicalFile();\r
+ }\r
\r
- // Properties from the conf dir files\r
- Properties properties = new Properties();\r
- StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
- PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
- while (st.hasMoreTokens()) {\r
- String fileName = st.nextToken();\r
- properties.putAll(loadFile(confDir.getAbsolutePath() + "/"\r
- + fileName));\r
- }\r
+ // Properties from the conf dir files\r
+ Properties properties = new Properties();\r
+ StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
+ PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
+ while (st.hasMoreTokens()) {\r
+ String fileName = st.nextToken();\r
+ properties.putAll(loadFile(confDir.getAbsolutePath() + File.separator\r
+ + fileName));\r
+ }\r
\r
- for (Object o : properties.keySet()) {\r
- String key = o.toString();\r
- if (all.getProperty(key) == null) {// not already set\r
- all.setProperty(key, properties.getProperty(key));\r
+ for (Object o : properties.keySet()) {\r
+ String key = o.toString();\r
+ if (all.getProperty(key) == null) {// not already set\r
+ all.setProperty(key, properties.getProperty(key));\r
+ }\r
}\r
- }\r
\r
- // Default application context\r
- if (all.getProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
- all.setProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
- .getAbsolutePath()\r
- + "/applicationContext.xml");\r
- }\r
- // Default test run\r
- if (all.getProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
- all.setProperty(DEFAULT_TEST_RUN_PROPERTY, "defaultTestRun");\r
- }\r
+ // Default application context\r
+ if (all.getProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
+ all.setProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
+ .getAbsolutePath()\r
+ + "/applicationContext.xml");\r
+ }\r
+ // Default test run\r
+ if (all.getProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
+ all.setProperty(DEFAULT_TEST_RUN_PROPERTY, "defaultTestRun");\r
+ }\r
+\r
+ // Default log4j\r
+ if (all.getProperty("log4j.configuration") == null) {\r
+ System.setProperty("log4j.configuration",confDir\r
+ .getCanonicalPath()\r
+ + File.separator + "log4j.properties" );\r
+ // TODO: fix dependency to log4j\r
+ Log4jConfigurer.initLogging(confDir\r
+ .getCanonicalPath()\r
+ + File.separator + "log4j.properties");\r
+ }\r
\r
- return all;\r
+ return all;\r
+ } catch (Exception e) {\r
+ throw new SlcAntException("Unexpected exception while configuring",\r
+ e);\r
+ }\r
}\r
\r
public static Properties loadFile(String path) {\r