openrewrite / rewrite-maven-plugin

OpenRewrite's Maven plugin.
https://openrewrite.github.io/rewrite-maven-plugin/plugin-info.html
Apache License 2.0
134 stars 70 forks source link

Cant' exclude dependency-reduced-pom.xml #650

Open philippe-granet opened 10 months ago

philippe-granet commented 10 months ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

<plugin>
  <groupId>org.openrewrite.maven</groupId>
  <artifactId>rewrite-maven-plugin</artifactId>
  <version>8.8.4</version>
</plugin>

What is the smallest, simplest way to reproduce the problem?

Use Maven Shade plugin and add dependency-reduced-pom.xml to excluded files (-Drewrite.exclusions=dependency-reduced-pom.xml)

What did you expect to see?

No patch generated for dependency-reduced-pom.xml

What did you see instead?

Patch generated for dependency-reduced-pom.xml

Bananeweizen commented 9 months ago

I've also not been able to use exclusions successfully. I have this configuration to match folders like src-gen and similar, but generated files are still modified:

<exclusions>
    <!-- generated code -->
    <exclusion>**/*-gen/**</exclusion>
</exclusions>
timtebeek commented 9 months ago

Hmm; the reason for this will be that we ask Maven what files to process, and likely this is one of the files returned.

https://github.com/openrewrite/rewrite-maven-plugin/blob/d1b68cdce46e9dfc2efa6fd133d2873ddf08e8ce/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L150-L153 https://github.com/openrewrite/rewrite-maven-plugin/blob/d1b68cdce46e9dfc2efa6fd133d2873ddf08e8ce/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L463-L467

The Maven shade plugin dependency-reduced-pom.xml has bitten me in the past as well, but went away when I added -DuseDependencyReducedPomInJar=false. Does that work for you as well @philippe-granet ?