Skip to content

#754: Fix an issue where empty git.properties had been generated in submodules when injectAllReactorProjects=true #760

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jul 2, 2024
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
12 changes: 9 additions & 3 deletions src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ public void error(String msg, Throwable t) {
|| PropertiesFileGenerator.craftPropertiesOutputFile(
project.getBasedir(), new File(generateGitPropertiesFilename))
.exists()) {
log.info("Skip mojo execution on incremental builds.");
return;
}
}
Expand Down Expand Up @@ -1237,7 +1238,8 @@ public void error(String msg, Throwable t) {
log.info(
"injectAllReactorProjects is enabled - attempting to use the already computed values");
// makes sure the existing context properties are not mutated
properties = new Properties(contextProperties);
properties = new Properties();
properties.putAll(contextProperties);
}

final GitCommitIdPlugin.Callback cb =
Expand Down Expand Up @@ -1484,14 +1486,18 @@ private void publishPropertiesInto(Properties propertiesToPublish, Properties pr

private void appendPropertiesToReactorProjects(LogInterface log, Properties propertiesToPublish) {
for (MavenProject mavenProject : reactorProjects) {
log.debug("Adding properties to project: '" + mavenProject.getName() + "'");
log.debug(
"Adding '" + propertiesToPublish.size() + "' properties "
+ "to project: '" + mavenProject.getName() + "'");
if (mavenProject.equals(project)) {
continue;
}
publishPropertiesInto(propertiesToPublish, mavenProject.getProperties());
mavenProject.setContextValue(CONTEXT_KEY, propertiesToPublish);
}
log.info("Added properties to '" + reactorProjects.size() + "' projects");
log.info(
"Added '" + propertiesToPublish.size() + "' properties "
+ "to '" + reactorProjects.size() + "' projects");
}

private void logProperties(LogInterface log, Properties propertiesToPublish) {
Expand Down