From 1156013b19bf9605716ff038909f8876d933a8a1 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Fri, 8 Dec 2023 11:26:08 +0100 Subject: [PATCH] Copy Maven compiler properties when generating the Maven plugin module --- .../platformgen/GeneratePlatformProjectMojo.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 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 3eae18b5..189671a2 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 @@ -1101,7 +1101,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) final Model originalEffectiveModel = new EffectiveModelResolver(nonWorkspaceResolver()) .resolveEffectiveModel(originalCoords); var effectivePlugins = originalEffectiveModel.getBuild().getPlugins().stream() - .collect(Collectors.toMap(p -> p.getArtifactId(), p -> p)); + .collect(Collectors.toMap(Plugin::getArtifactId, p -> p)); int i = 0; while (i < build.getPlugins().size()) { var plugin = build.getPlugins().get(i++); @@ -1113,6 +1113,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) } } + // copy maven.* properties + copyMavenCompilerProperties(originalEffectiveModel, pom); + var originalDeps = originalEffectiveModel.getDependencies(); final Map originalDepVersions = new HashMap<>(originalDeps.size()); @@ -1159,7 +1162,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) } // make sure the original properties do not override the platform ones - final Properties originalProps = pom.getProperties(); + var originalProps = pom.getProperties(); if (!originalProps.isEmpty()) { pom.setProperties(new Properties()); for (Map.Entry originalProp : originalProps.entrySet()) { @@ -1177,6 +1180,15 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) persistPom(pom); } + private static void copyMavenCompilerProperties(Model srcModel, Model targetModel) { + var srcProps = srcModel.getProperties(); + for (var propName : srcProps.stringPropertyNames()) { + if (propName.startsWith("maven.compiler.")) { + targetModel.getProperties().setProperty(propName, srcProps.getProperty(propName)); + } + } + } + private void configureFlattenPlugin(Model pom, boolean updatePomFile, Map elementConfig) { Build build = pom.getBuild(); if (build == null) {