From cb2490d8e9a97426debbff1cfba8cf062186ae0f Mon Sep 17 00:00:00 2001 From: TheSnoozer <6849390+TheSnoozer@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:49:53 +0200 Subject: [PATCH] https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/754: Fix an issue where empty git.properties had been generated in submodules when injectAllReactorProjects=true --- .../java/pl/project13/maven/git/GitCommitIdMojo.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java index a61e8f64..022bd887 100644 --- a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java +++ b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java @@ -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; } } @@ -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 = @@ -1484,14 +1486,16 @@ 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) {