From 94eff92a4700e25b3679691a6f5a57cfb735c554 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Wed, 25 Sep 2024 13:44:29 +0200 Subject: [PATCH] Make sure the Maven plugin module has relevant project properties set --- .../maven/platformgen/GeneratePlatformProjectMojo.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java b/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java index 36f79035..f4a42793 100644 --- a/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java +++ b/maven-plugin/src/main/java/io/quarkus/bom/decomposer/maven/platformgen/GeneratePlatformProjectMojo.java @@ -1229,7 +1229,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { pom.setProperties(new Properties()); for (Map.Entry originalProp : originalProps.entrySet()) { final String propName = originalProp.getKey().toString(); - if (!project.getOriginalModel().getProperties().containsKey(propName)) { + // if it's not a version property, we add it + if (propName.startsWith("maven.") || getArtifactGroupIdsForVersionProperty(propName).isEmpty()) { pom.getProperties().setProperty(propName, originalProp.getValue().toString()); } } @@ -2215,7 +2216,7 @@ private void mapProjectProperties(Properties props) { private Collection getArtifactGroupIdsForVersionProperty(final String versionProperty) { var propExpr = "${" + versionProperty + "}"; - Set result = new HashSet<>(); + Set result = null; for (String s : pomLines()) { int coordsEnd = s.indexOf(propExpr); // looking for

propExpr

, min length will be propExpr.length() + 3 + 4 @@ -2234,10 +2235,13 @@ private Collection getArtifactGroupIdsForVersionProperty(final String ve var coords = s.substring(coordsStart + 1, coordsEnd); var arr = coords.split(COLON); if (arr.length > 2 && arr.length < 6) { + if (result == null) { + result = new HashSet<>(2); + } result.add(arr[0]); } } - return result; + return result == null ? Set.of() : result; } private void addDependencies(final Model pom, List dependencies, boolean test) {