@@ -364,7 +364,7 @@ public void execute() throws MojoExecutionException {
364364 commitIdGenerationModeEnum = CommitIdGenerationMode .FLAT ;
365365 }
366366
367- properties = initProperties ();
367+ properties = new Properties ();
368368
369369 String trimmedPrefix = prefix .trim ();
370370 prefixDot = trimmedPrefix .equals ("" ) ? "" : trimmedPrefix + "." ;
@@ -376,15 +376,15 @@ public void execute() throws MojoExecutionException {
376376 propertiesReplacer .performReplacement (properties , replacementProperties );
377377 propertiesFilterer .filter (properties , includeOnlyProperties , this .prefixDot );
378378 propertiesFilterer .filterNot (properties , excludeProperties , this .prefixDot );
379- logProperties (properties );
379+ logProperties ();
380380
381381 if (generateGitPropertiesFile ) {
382382 maybeGeneratePropertiesFile (properties , project .getBasedir (), generateGitPropertiesFilename );
383- project .getProperties ().putAll (properties ); // add to maven project properties also when file is generated
384383 }
384+ publishPropertiesInto (project );
385385
386386 if (injectAllReactorProjects ) {
387- appendPropertiesToReactorProjects (properties );
387+ appendPropertiesToReactorProjects ();
388388 }
389389 } catch (Exception e ) {
390390 handlePluginFailure (e );
@@ -394,6 +394,10 @@ public void execute() throws MojoExecutionException {
394394 }
395395 }
396396
397+ private void publishPropertiesInto (MavenProject target ) {
398+ target .getProperties ().putAll (properties );
399+ }
400+
397401 /**
398402 * Reacts to an exception based on the {@code failOnUnableToExtractRepoInfo} setting.
399403 * If it's true, an GitCommitIdExecutionException will be thrown, otherwise we just log an error message.
@@ -409,18 +413,13 @@ private void handlePluginFailure(Exception e) throws GitCommitIdExecutionExcepti
409413 }
410414 }
411415
412- private void appendPropertiesToReactorProjects (@ NotNull Properties properties ) {
416+ private void appendPropertiesToReactorProjects () {
413417 for (MavenProject mavenProject : reactorProjects ) {
414- Properties mavenProperties = mavenProject .getProperties ();
415418
416419 // TODO check message
417420 log .info ("{}] project {}" , mavenProject .getName (), mavenProject .getName ());
418421
419- for (Object key : properties .keySet ()) {
420- if (isOurProperty (key .toString ())) {
421- mavenProperties .put (key , properties .get (key ));
422- }
423- }
422+ publishPropertiesInto (mavenProject );
424423 }
425424 }
426425
@@ -434,27 +433,13 @@ private void appendPropertiesToReactorProjects(@NotNull Properties properties) {
434433 return new GitDirLocator (project , reactorProjects ).lookupGitDirectory (dotGitDirectory );
435434 }
436435
437- private Properties initProperties () throws GitCommitIdExecutionException {
438- if (generateGitPropertiesFile ) {
439- return properties = new Properties ();
440- } else {
441- return properties = project .getProperties ();
442- }
443- }
444-
445- private void logProperties (@ NotNull Properties properties ) {
436+ private void logProperties () {
446437 for (Object key : properties .keySet ()) {
447438 String keyString = key .toString ();
448- if (isOurProperty (keyString )) {
449- log .info ("found property {}" , keyString );
450- }
439+ log .info ("found property {}" , keyString );
451440 }
452441 }
453442
454- private boolean isOurProperty (@ NotNull String keyString ) {
455- return keyString .startsWith (prefixDot );
456- }
457-
458443 void loadBuildVersionAndTimeData (@ NotNull Properties properties ) {
459444 Date buildDate = new Date ();
460445 SimpleDateFormat smf = new SimpleDateFormat (dateFormat );
0 commit comments