Skip to content

Remove stale maven.compiler.source/target properties after release replacement#7315

Draft
timtebeek wants to merge 3 commits intomainfrom
tim/fix-stale-compiler-props
Draft

Remove stale maven.compiler.source/target properties after release replacement#7315
timtebeek wants to merge 3 commits intomainfrom
tim/fix-stale-compiler-props

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Apr 8, 2026

Summary

  • Converts UseMavenCompilerPluginReleaseConfiguration from Recipe to ScanningRecipe so it can remove maven.compiler.source/maven.compiler.target properties that become unused after <source>/<target> is replaced with <release>

  • The scanner tracks ${maven.compiler.source/target} references and which POMs have <release> configured; the visitor removes properties only when they have no remaining references and <release> is present

  • Properties are preserved when referenced by other plugins or when no compiler plugin exists

  • Fixes UpgradeJavaVersion leaves behind stale unused properties rewrite-migrate-java#668

Test plan

  • removesStaleSourceTargetProperties — main issue scenario (properties referenced by source/target, both removed after release replacement)
  • removesImplicitlyStaleProperties — hardcoded source/target with unreferenced properties
  • keepsPropertiesWhenReferencedElsewhere — properties stay when used by other plugins
  • keepsPropertiesWithoutCompilerPlugin — properties stay when no compiler plugin exists
  • All existing tests pass (full rewrite-maven suite)

…placement

Convert UseMavenCompilerPluginReleaseConfiguration from Recipe to ScanningRecipe
so it can detect and remove maven.compiler.source/maven.compiler.target properties
that become unused after source/target is replaced with release.

Fixes openrewrite/rewrite-migrate-java#668
…property cleanup

When test sources use a different Java version than main sources, introduce
<testRelease> to preserve the higher version. Also clean up stale
maven.compiler.testSource/testTarget properties when <release> or <testRelease>
is configured.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

UpgradeJavaVersion leaves behind stale unused properties

1 participant