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

Copy Maven compiler properties when generating the Maven plugin module #306

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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++);
Expand All @@ -1113,6 +1113,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
}
}

// copy maven.* properties
copyMavenCompilerProperties(originalEffectiveModel, pom);

var originalDeps = originalEffectiveModel.getDependencies();

final Map<ArtifactKey, String> originalDepVersions = new HashMap<>(originalDeps.size());
Expand Down Expand Up @@ -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()) {
Expand All @@ -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<String, String> elementConfig) {
Build build = pom.getBuild();
if (build == null) {
Expand Down
Loading