+ protected void initSystemProperties(Properties userProperties) {
+ // Set user properties as system properties so that Spring can access
+ // them
+ if (userProperties != null) {
+ for (Object key : userProperties.keySet()) {
+ System.setProperty(key.toString(), userProperties
+ .getProperty(key.toString()));
+ }
+ }
+
+ if (System.getProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {
+ System.setProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY,
+ "defaultTestRun");
+ }
+
+ 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());
+ if (workDir != null)
+ System.setProperty(SlcAntConstants.WORK_DIR_PROPERTY, workDir
+ .getCanonicalPath());
+
+ // Additional properties in slc.properties file. Already set sytem
+ // properties (such as the various directories) can be resolved in
+ // placeholders.
+ if (confDir != null) {
+ Resource slcPropertiesRes = confDir
+ .createRelative("slc.properties");
+ if (slcPropertiesRes.exists()) {
+ Properties slcProperties = new Properties();
+ InputStream in = slcPropertiesRes.getInputStream();
+ try {
+ slcProperties.load(in);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+
+ for (String key : slcProperties.stringPropertyNames()) {
+ if (!System.getProperties().containsKey(key)) {
+ String value = SystemPropertyUtils
+ .resolvePlaceholders(slcProperties
+ .getProperty(key));
+ System.setProperty(key, value);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new SlcAntException("Cannot init system properties.", e);
+ }
+ }
+