openrewrite / rewrite-apache

OpenRewrite recipes for Apache projects.
Apache License 2.0
2 stars 8 forks source link

Migrate from `sources` to `resolve-sources` for the maven-dependency-plugin #20

Open yeikel opened 3 months ago

yeikel commented 3 months ago

What problem are you trying to solve?

What precondition(s) should be checked before applying this recipe?

Describe the situation before applying the recipe


<plugin>
 <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>${maven-dependency-plugin.version}</version>
  <executions>
    <execution>
      <goals>
        <goal>sources</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Describe the situation after applying the recipe


diff --git a/pom.xml b/pom.xml
index 6f1d54220..fbee73aba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1027,7 +1027,7 @@
                     <executions>
                         <execution>
                             <goals>
-                                <goal>sources</goal>
+                                <goal>resolve-sources</goal>
                             </goals>
                         </execution>
                     </executions>

Any additional context

https://issues.apache.org/jira/browse/MDEP-941 https://github.com/apache/maven-dependency-plugin/pull/411/files

timtebeek commented 3 months ago

Thanks for the suggestion @yeikel , and the helpful links out to Jira & the associated PR. I've moved this issue to rewrite-apache, as we might want to shift some of the none-core Maven best practices recipes here.

We can use a precondition to limit this to only apply to projects using that particular range of versions, and then within that replace any goals as needed.