From fff08128375d22b9c6900557031b74669d747cd1 Mon Sep 17 00:00:00 2001 From: Philippe GRANET Date: Sat, 7 Dec 2024 14:30:37 +0000 Subject: [PATCH 1/2] Ignore generated pom by maven-shade-plugin and ci-friendly-flatten-maven-plugin --- .../org/openrewrite/maven/MavenMojoProjectParser.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java index 068de35f..76f59652 100644 --- a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java +++ b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java @@ -650,6 +650,14 @@ private static Path pomPath(MavenProject mavenProject) { if (pomPath.endsWith(".flattened-pom.xml")) { return mavenProject.getBasedir().toPath().resolve("pom.xml"); } + // org.apache.maven.plugins:maven-shade-plugin produces a simplified POM for the shaded artifact, use the regular pom instead + if (pomPath.endsWith("dependency-reduced-pom.xml")) { + return mavenProject.getBasedir().toPath().resolve("pom.xml"); + } + // com.outbrain.swinfra:ci-friendly-flatten-maven-plugin produces a pom unsuitable for our purposes, use the regular pom instead + if (pomPath.endsWith(".ci-friendly-pom.xml")) { + return mavenProject.getBasedir().toPath().resolve("pom.xml"); + } // org.eclipse.tycho:tycho-packaging-plugin:update-consumer-pom produces a synthetic pom if (pomPath.endsWith(".tycho-consumer-pom.xml")) { Path normalPom = mavenProject.getBasedir().toPath().resolve("pom.xml"); From 784635d085b26f137dbdac0c11d7751051f00d70 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 7 Dec 2024 22:45:57 +0100 Subject: [PATCH 2/2] Collapse handling into a single `if` --- .../maven/MavenMojoProjectParser.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java index 76f59652..20e5eead 100644 --- a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java +++ b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java @@ -646,20 +646,10 @@ private void collectPoms(MavenProject project, Set paths, MavenExecutionCo private static Path pomPath(MavenProject mavenProject) { Path pomPath = mavenProject.getFile().toPath(); - // org.codehaus.mojo:flatten-maven-plugin produces a synthetic pom unsuitable for our purposes, use the regular pom instead - if (pomPath.endsWith(".flattened-pom.xml")) { - return mavenProject.getBasedir().toPath().resolve("pom.xml"); - } - // org.apache.maven.plugins:maven-shade-plugin produces a simplified POM for the shaded artifact, use the regular pom instead - if (pomPath.endsWith("dependency-reduced-pom.xml")) { - return mavenProject.getBasedir().toPath().resolve("pom.xml"); - } - // com.outbrain.swinfra:ci-friendly-flatten-maven-plugin produces a pom unsuitable for our purposes, use the regular pom instead - if (pomPath.endsWith(".ci-friendly-pom.xml")) { - return mavenProject.getBasedir().toPath().resolve("pom.xml"); - } - // org.eclipse.tycho:tycho-packaging-plugin:update-consumer-pom produces a synthetic pom - if (pomPath.endsWith(".tycho-consumer-pom.xml")) { + if (pomPath.endsWith(".flattened-pom.xml") ||// org.codehaus.mojo:flatten-maven-plugin + pomPath.endsWith("dependency-reduced-pom.xml") || // org.apache.maven.plugins:maven-shade-plugin + pomPath.endsWith(".ci-friendly-pom.xml") || // com.outbrain.swinfra:ci-friendly-flatten-maven-plugin + pomPath.endsWith(".tycho-consumer-pom.xml")) { // org.eclipse.tycho:tycho-packaging-plugin:update-consumer-pom Path normalPom = mavenProject.getBasedir().toPath().resolve("pom.xml"); // check for the existence of the POM, since Tycho can work pom-less if (Files.isReadable(normalPom) && Files.isRegularFile(normalPom)) {