@@ -280,6 +280,8 @@ public class GitCommitIdMojo extends AbstractMojo {
280280
281281 boolean runningTests = false ;
282282
283+ static int projectCounter ;
284+
283285 @ NotNull
284286 LoggerBridge loggerBridge = new MavenLoggerBridge (getLog (), true );
285287
@@ -486,21 +488,19 @@ void loadGitDataWithJGit(@NotNull Properties properties) throws IOException, Moj
486488 jGitProvider .loadGitData (properties );
487489 }
488490
489- static int counter ;
490-
491491 void generatePropertiesFile (@ NotNull Properties properties , File base , String propertiesFilename ) throws IOException {
492492 FileWriter fileWriter = null ;
493- File gitPropsFile = new File (base , propertiesFilename );
493+ File gitPropsFile = craftPropertiesOutputFile (base , propertiesFilename );
494494 try {
495495 Files .createParentDirs (gitPropsFile );
496496
497497 fileWriter = new FileWriter (gitPropsFile );
498498 if ("json" .equalsIgnoreCase (format )) {
499- log ("Writing json file to [" , gitPropsFile .getAbsolutePath (), "] (for module " , project .getName () + (++counter ), ")..." );
499+ log ("Writing json file to [" , gitPropsFile .getAbsolutePath (), "] (for module " , project .getName () + (++projectCounter ), ")..." );
500500 ObjectMapper mapper = new ObjectMapper ();
501501 mapper .writeValue (fileWriter , properties );
502502 } else {
503- log ("Writing properties file to [" , gitPropsFile .getAbsolutePath (), "] (for module " , project .getName () + (++counter ), ")..." );
503+ log ("Writing properties file to [" , gitPropsFile .getAbsolutePath (), "] (for module " , project .getName () + (++projectCounter ), ")..." );
504504 properties .store (fileWriter , "Generated by Git-Commit-Id-Plugin" );
505505 }
506506
@@ -511,6 +511,19 @@ void generatePropertiesFile(@NotNull Properties properties, File base, String pr
511511 }
512512 }
513513
514+ @ VisibleForTesting
515+ File craftPropertiesOutputFile (File base , String propertiesFilename ){
516+ File returnPath = new File (base , propertiesFilename );
517+
518+ File currentPropertiesFilepath = new File (propertiesFilename );
519+ if (currentPropertiesFilepath .isAbsolute ()){
520+ returnPath = currentPropertiesFilepath ;
521+ }
522+
523+ return returnPath ;
524+ }
525+
526+
514527 boolean isPomProject (@ NotNull MavenProject project ) {
515528 return project .getPackaging ().equalsIgnoreCase ("pom" );
516529 }
0 commit comments