Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include parent properties when doing late replacement of argLine #1976

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private static UnaryOperator<String> getDynamicConfigurationProperties(Module mo
return s -> s;
}
Properties staticProperties = MavenPropertyResolver.collectPropertiesFromDOM(mavenProject, domModel);
Properties modelProperties = mavenProject.getProperties();
String jaCoCoConfigProperty = getJaCoCoArgLineProperty(mavenProject);
ParametersList vmParameters = javaParameters.getVMParametersList();
return name -> {
Expand All @@ -99,6 +100,10 @@ private static UnaryOperator<String> getDynamicConfigurationProperties(Module mo
if (staticPropertyValue != null) {
return MavenPropertyResolver.resolve(staticPropertyValue, domModel);
}
String modelPropertyValue = modelProperties.getProperty(name);
if (modelPropertyValue != null) {
return modelPropertyValue;
}
if (name.equals(jaCoCoConfigProperty)) {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,58 @@ public void ArgLineLateReplacement() {
javaParameters.getVMParametersList().getList());
}

@Test
public void ArgLineLateReplacementParentProperty() {
createProjectPom(
"<groupId>test</groupId>\n"
+ "<artifactId>project</artifactId>\n"
+ "<version>1</version>\n"
+ "<packaging>pom</packaging>\n"
+ "<properties>\n"
+ " <parentProp>parent.value</parentProp>\n"
+ "</properties>\n"
+ "<modules>\n"
+ " <module>m1</module>\n"
+ "</modules>\n");

createModulePom(
"m1",
"<groupId>test</groupId>\n"
+ "<artifactId>m1</artifactId>\n"
+ "<version>1</version>\n"
+ "<properties>\n"
+ " <moduleProp>module.value</moduleProp>\n"
+ "</properties>\n"
+ "<parent>\n"
+ " <groupId>test</groupId>\n"
+ " <artifactId>project</artifactId>\n"
+ " <version>1</version>\n"
+ "</parent>\n"
+ "<build>\n"
+ " <plugins>\n"
+ " <plugin>\n"
+ " <groupId>org.apache.maven.plugins</groupId>\n"
+ " <artifactId>maven-surefire-plugin</artifactId>\n"
+ " <version>2.16</version>\n"
+ " <configuration>\n"
+ " <argLine>@{moduleProp} @{parentProp}</argLine>\n"
+ " </configuration>\n"
+ " </plugin>\n"
+ " </plugins>\n"
+ "</build>\n");

importProject();
Module module = getModule("m1");

MavenJUnitPatcher mavenJUnitPatcher = new MavenJUnitPatcher();
JavaParameters javaParameters = new JavaParameters();
javaParameters.getVMParametersList().add("-ea");
mavenJUnitPatcher.patchJavaParameters(module, javaParameters);
assertEquals(
asList("-ea", "module.value", "parent.value"),
javaParameters.getVMParametersList().getList());
}

@Test
public void ArgLineRefersAnotherProperty() {
VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" +
Expand Down