Skip to content

Propagation of Surefire/Failsafe plugin configuration does not correctly remove unresolvable properties #1916

@kwin

Description

@kwin

Sometimes properties are not explicitly set in the pom.xml but are rather set through some other plugins. Most prominent example is https://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html#propertyName.
As this property can obviously not be resolved when extracting the surefire/failsafe plugins, all unknown placeholder inside ${...} should just be replaced by the empty string.

For example I have this configuration in my pom.xml

<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<executions>
  <execution>
    <id>default-test</id>
    <phase>test</phase>
    <goals>
      <goal>test</goal>
    </goals>
    <configuration>
      <argLine>${test.opts.coverage} -Xmx512m</argLine>
    </configuration>
  </execution>
</executions>

Usually test.opts.coverage is populated from

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
  <execution>
    <id>pre-unit-test</id>
    <goals>
      <goal>prepare-agent</goal>
    </goals>
    <configuration>
      <propertyName>test.opts.coverage</propertyName>
    </configuration>
  </execution>
</executions>

This leads to the following error launching the auto-created JUnit configuration Reference to undefined variable test.opts.coverage because the VM arguments contain the unresolved ${test.opts.coverage} .
This is a regression of c8bcaaa.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions