Skip to content

Commit

Permalink
Work around reported exception in AddAnnotationProcessor
Browse files Browse the repository at this point in the history
org.openrewrite.maven.AddAnnotationProcessor$1$1 tried to access protected method 'org.openrewrite.maven.tree.MavenResolutionResult org.openrewrite.maven.MavenVisitor.getResolutionResult()'

org.openrewrite.maven.AddAnnotationProcessor$1$1.visitTag(AddAnnotationProcessor.java:79)
  • Loading branch information
sambsnyd committed Feb 3, 2025
1 parent 4e28652 commit c11da8d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.maven.tree.MavenResolutionResult;
import org.openrewrite.semver.Semver;
import org.openrewrite.semver.VersionComparator;
import org.openrewrite.xml.XmlIsoVisitor;
Expand Down Expand Up @@ -75,6 +76,7 @@ public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
plugins = (Xml.Tag) mavenPlugin().asVisitor(plugin -> {
if (MAVEN_COMPILER_PLUGIN_GROUP_ID.equals(plugin.getGroupId()) &&
MAVEN_COMPILER_PLUGIN_ARTIFACT_ID.equals(plugin.getArtifactId())) {
MavenResolutionResult mrr = getResolutionResult();
AtomicReference<TreeVisitor<?, ExecutionContext>> afterVisitor = new AtomicReference<>();
Xml.Tag modifiedPlugin = new XmlIsoVisitor<ExecutionContext>() {
@Override
Expand All @@ -89,7 +91,7 @@ public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) {
String oldVersion = child.getChildValue("version").orElse("");
boolean oldVersionUsesProperty = oldVersion.startsWith("${");
String lookupVersion = oldVersionUsesProperty ?
getResolutionResult().getPom().getValue(oldVersion.trim()) :
mrr.getPom().getValue(oldVersion.trim()) :
oldVersion;
VersionComparator comparator = Semver.validate(lookupVersion, null).getValue();
if (comparator.compare(version, lookupVersion) > 0) {
Expand Down

0 comments on commit c11da8d

Please sign in to comment.