Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
philippe-granet opened this issue Nov 9, 2023 · 5 comments · Fixed by #908
Closed

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

philippe-granet opened this issue Nov 9, 2023 · 5 comments · Fixed by #908
Labels
bug Something isn't working question Further information is requested

Comments

@philippe-granet
Copy link
Contributor

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.8.4
  • Maven plugin v5.10.0

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

@philippe-granet philippe-granet added the bug Something isn't working label Nov 9, 2023
@Bananeweizen
Copy link
Contributor

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 timtebeek moved this to Backlog in OpenRewrite Dec 11, 2023
@timtebeek
Copy link
Contributor

timtebeek commented Dec 11, 2023

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

Map<MavenProject, List<Marker>> projectProvenances = mavenSession.getProjects().stream()
.collect(Collectors.toMap(Function.identity(), this::generateProvenance));
Map<MavenProject, Xml.Document> projectMap = parseMaven(mavenSession.getProjects(), projectProvenances, ctx);
return mavenSession.getProjects().stream()

Set<Path> allPoms = new LinkedHashSet<>();
mavenProjects.forEach(p -> collectPoms(p, allPoms));
for (MavenProject mavenProject : mavenProjects) {
mavenSession.getProjectDependencyGraph().getUpstreamProjects(mavenProject, true).forEach(p -> collectPoms(p, allPoms));
}

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 ?

@timtebeek timtebeek added the question Further information is requested label Dec 11, 2023
@timtebeek
Copy link
Contributor

Just a quick note here that @rickie has reported seeing the same issue with ci-friendly-flatten-maven-plugin. Any fix ideally takes both into account, to fall back to the original pom.xml, not any modified pom.

@philippe-granet
Copy link
Contributor Author

philippe-granet commented Dec 7, 2024

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 ?

In my case, developer have commited dependency-reduced-pom.xml ...

I propose this MR to fix the problem:

@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Dec 7, 2024
@rickie
Copy link

rickie commented Dec 9, 2024

Thanks @timtebeek for taking that case into account 😄 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
Archived in project
4 participants