openrewrite / rewrite-jenkins

OpenRewrite recipes to continuously modernize Jenkins plugins.
Apache License 2.0
9 stars 8 forks source link

Make AddPluginsBom Order Independent #57

Closed sghill closed 7 months ago

sghill commented 11 months ago

What's changed?

AddPluginsBom recipe now supports properties declared after the bom.

What's your motivation?

Several plugins have this ordering defined. It worked in the previous ScanningRecipe implementation, this restores the behavior with a regular Recipe.

Have you considered any alternatives or workarounds?

Recipe causing another cycle, but this seems simpler.

Checklist

timtebeek commented 11 months ago

This one has started to fail, possibly due to a new wildcard version getting picked up

ModernizePluginTest > shouldDoTheWorks() FAILED
    org.opentest4j.AssertionFailedError: [Unexpected result in "pom.xml":
diff --git a/pom.xml b/pom.xml
index 3dc2751..cedb28d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@ 
             <dependency>
                 <groupId>io.jenkins.tools.bom</groupId>
                 <artifactId>bom-2.401.x</artifactId>
-                <version>2612.v3d6a_2128c0ef</version>
+                <version>2641.v88e707466454</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>

We also have mechanisms for tests to verify not an exact version, through Consumer<SourceSpec<SourceFile>>. Let me know if you need help to set that up!

timtebeek commented 11 months ago

Rewrote one test to indeed not break when a new version comes out; hope that helps! https://github.com/openrewrite/rewrite-jenkins/commit/063e664adc4fdd8c9ed29bdcc742a4e605216d05

sghill commented 11 months ago

Thanks Tim!

sghill commented 7 months ago

Looks good to me, aside from the suggestion to use cursor messaging instead of visitor fields, and run https://docs.openrewrite.org/recipes/maven/orderpomelements as a first step to ensure the projects conform to the pom code convention

Thanks for the suggestion @timtebeek! This has been updated to use cursor messaging.