use of org.jetbrains.idea.maven.project.MavenTestRunningSettings in project intellij-community by JetBrains.
the class MavenJUnitPatcher method patchJavaParameters.
private static void patchJavaParameters(@NotNull Module module, @NotNull JavaParameters javaParameters, @NotNull MavenProject mavenProject, @NotNull String plugin, @NotNull Element config) {
MavenDomProjectModel domModel = MavenDomUtil.getMavenDomProjectModel(module.getProject(), mavenProject.getFile());
MavenTestRunningSettings testRunningSettings = MavenProjectSettings.getInstance(module.getProject()).getTestRunningSettings();
List<String> paths = MavenJDOMUtil.findChildrenValuesByPath(config, "additionalClasspathElements", "additionalClasspathElement");
if (paths.size() > 0) {
for (String path : paths) {
javaParameters.getClassPath().add(resolvePluginProperties(plugin, path, domModel));
}
}
if (testRunningSettings.isPassSystemProperties() && isEnabled(plugin, "systemPropertyVariables")) {
Element systemPropertyVariables = config.getChild("systemPropertyVariables");
if (systemPropertyVariables != null) {
for (Element element : systemPropertyVariables.getChildren()) {
String propertyName = element.getName();
if (!javaParameters.getVMParametersList().hasProperty(propertyName)) {
String value = resolvePluginProperties(plugin, element.getValue(), domModel);
value = resolveVmProperties(javaParameters.getVMParametersList(), value);
if (isResolved(plugin, value)) {
javaParameters.getVMParametersList().addProperty(propertyName, value);
}
}
}
}
}
if (testRunningSettings.isPassEnvironmentVariables() && isEnabled(plugin, "environmentVariables")) {
Element environmentVariables = config.getChild("environmentVariables");
if (environmentVariables != null) {
for (Element element : environmentVariables.getChildren()) {
String variableName = element.getName();
if (!javaParameters.getEnv().containsKey(variableName)) {
String value = resolvePluginProperties(plugin, element.getValue(), domModel);
value = resolveVmProperties(javaParameters.getVMParametersList(), value);
if (isResolved(plugin, value)) {
javaParameters.addEnv(variableName, value);
}
}
}
}
}
if (testRunningSettings.isPassArgLine() && isEnabled(plugin, "argLine")) {
Element argLine = config.getChild("argLine");
if (argLine != null) {
String value = resolvePluginProperties(plugin, argLine.getTextTrim(), domModel);
value = resolveVmProperties(javaParameters.getVMParametersList(), value);
if (StringUtil.isNotEmpty(value) && isResolved(plugin, value)) {
javaParameters.getVMParametersList().addParametersString(value);
}
}
}
}
Aggregations