Skip to content

Preserve @{argLine} in AddSurefireFailsafeArgLine for JaCoCo coverage#1138

Merged
timtebeek merged 2 commits into
mainfrom
tim/java25-argline-jacoco-spring-test
Jun 22, 2026
Merged

Preserve @{argLine} in AddSurefireFailsafeArgLine for JaCoCo coverage#1138
timtebeek merged 2 commits into
mainfrom
tim/java25-argline-jacoco-spring-test

Conversation

@timtebeek

Copy link
Copy Markdown
Member

AddSurefireFailsafeArgLine now prepends Surefire's @{argLine} late property reference whenever it writes or merges a surefire/failsafe argLine, so an -javaagent injected into the argLine property by an earlier plugin (most notably the JaCoCo coverage agent from jacoco-maven-plugin:prepare-agent, but also the Mockito/ByteBuddy agent) is preserved instead of clobbered. The reference is not added when the existing argLine already references the argLine property (@{argLine} or ${argLine}), so the recipe stays idempotent and never duplicates it. Unlike ${argLine}, the @{...} form is resolved when Surefire executes rather than at POM interpolation, so it picks up the value set during the build and resolves to an empty string when unset. Tests are updated for the new prefix, plus new cases covering JaCoCo coverage preservation and no-duplication of an existing reference; the generated examples.yml is regenerated to match.

When writing or merging a surefire/failsafe `argLine`, prepend Surefire's
`@{argLine}` late property reference so an agent injected into the `argLine`
property by an earlier plugin (e.g. JaCoCo `prepare-agent`) is preserved
rather than overwritten. The reference is not added when the existing
`argLine` already references the `argLine` property (`@{argLine}`/`${argLine}`).
@timtebeek timtebeek merged commit a897423 into main Jun 22, 2026
1 check passed
@timtebeek timtebeek deleted the tim/java25-argline-jacoco-spring-test branch June 22, 2026 11:34
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant