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

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

Open
kwin opened this issue Jan 16, 2025 · 4 comments

Comments

@kwin
Copy link
Member

kwin commented Jan 16, 2025

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.

@kwin
Copy link
Member Author

kwin commented Jan 16, 2025

I think

private TestLaunchArguments getTestLaunchArguments(MavenProject mavenProject, MojoExecution execution,
needs to be modified to both remove deferred and non-deferred unknown properties.

@kwin
Copy link
Member Author

kwin commented Jan 16, 2025

@treilhes Is that something you could look at?

@treilhes
Copy link
Contributor

Hello @kwin
I think your issue was already solved by #1827
Ensure you're using @{test.opts.coverage} instead of ${test.opts.coverage} as it is a deferred variable
and also appply the pluginManagement configuration provided in this post

I think it will solve your issue

@kwin
Copy link
Member Author

kwin commented Jan 18, 2025

M2E should not require POM changes. As this configuration works fine in CLI let's make it work in m2e...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants