Set user dir property for tests
@@ -555,6 +555,7 @@ public class DevMojo extends StartDebugMojoSupport {
injectTestId(config);
} else if (phase.equals("integration-test")) {
injectTestId(config);
+ injectLibertyProperties(config);
// clean up previous summary file
File summaryFile = null;
Xpp3Dom summaryFileElement = config.getChild("summaryFile");
@@ -597,6 +598,30 @@ public class DevMojo extends StartDebugMojoSupport {
}
}
+ /**
+ * Add Liberty system properties for tests to consume.
+ *
+ * @param config The configuration element
+ * @throws MojoExecutionException if the userDirectory canonical path cannot be resolved
+ */
+ private void injectLibertyProperties(Xpp3Dom config) throws MojoExecutionException {
+ Xpp3Dom sysProps = config.getChild("systemPropertyVariables");
+ if (sysProps == null) {
+ Element e = element(name("systemPropertyVariables"));
+ sysProps = e.toDom();
+ config.addChild(sysProps);
+ }
+ // don't overwrite existing properties if they are already defined
+ if (sysProps.getChild("liberty.user.dir") == null) {
+ // pass in userDirectory parameter
+ try {
+ sysProps.addChild(element(name("liberty.user.dir"), userDirectory.getCanonicalPath()).toDom());
+ } catch (IOException e) {
+ throw new MojoExecutionException("Could not resolve canonical path of userDirectory parameter: " + userDirectory.getAbsolutePath(), e);
+ }
+ }
+ }
+
private Element[] getPluginConfigurationElements(String goal, String testServerName, List<String> dependencies) {
List<Element> elements = new ArrayList<Element>();
try {
