@@ -504,17 +504,11 @@ There's another way to use the plugin, it's a little bit easier I guess. First,
504504 <!-- this is false by default, forces the plugin to generate the git.properties file -->
505505 <generateGitPropertiesFile >true</generateGitPropertiesFile >
506506
507- <!-- The path for the to be generated properties file, it's relative to ${project.basedir} -->
508- <generateGitPropertiesFilename >src/main/resources /git.properties</generateGitPropertiesFilename >
507+ <!-- The path for the properties file to be generated. See Super Pom for default variable reference https://maven.apache.org/guides/introduction/introduction-to-the-pom.html -->
508+ <generateGitPropertiesFilename >${project.build.outputDirectory} /git.properties</generateGitPropertiesFilename >
509509</configuration >
510510```
511511
512- Remember to add this file to your .gitignore as it's quite some garbage changes to your repository if you don't ignore it. Open .gitignore and add:
513-
514- ```
515- src/main/resources/git.properties
516- ```
517-
518512Then run the project as you would normally, the file will be created for you. And you may access it as you'd access any other properties file, for example like this:
519513
520514``` java
@@ -536,28 +530,28 @@ You'd have to add such an constructor to your GitRepositoryState bean:
536530``` java
537531public GitRepositoryState(Properties properties)
538532{
539- this . tags = properties. get(" git.tags" ). toString( );
540- this . branch = properties. get(" git.branch" ). toString( );
541- this . dirty = properties. get(" git.dirty" ). toString( );
542- this . remoteOriginUrl = properties. get(" git.remote.origin.url" ). toString( );
543-
544- this . commitId = properties. get(" git.commit.id.full" ). toString( ); // OR properties.get("git.commit.id") depending on your configuration
545- this . commitIdAbbrev = properties. get(" git.commit.id.abbrev" ). toString( );
546- this . describe = properties. get(" git.commit.id.describe" ). toString( );
547- this . describeShort = properties. get(" git.commit.id.describe-short" ). toString( );
548- this . commitUserName = properties. get(" git.commit.user.name" ). toString( );
549- this . commitUserEmail = properties. get(" git.commit.user.email" ). toString( );
550- this . commitMessageFull = properties. get(" git.commit.message.full" ). toString( );
551- this . commitMessageShort = properties. get(" git.commit.message.short" ). toString( );
552- this . commitTime = properties. get(" git.commit.time" ). toString( );
553- this . closestTagName = properties. get(" git.closest.tag.name" ). toString( );
554- this . closestTagCommitCount = properties. get(" git.closest.tag.commit.count" ). toString( );
555-
556- this . buildUserName = properties. get(" git.build.user.name" ). toString( );
557- this . buildUserEmail = properties. get(" git.build.user.email" ). toString( );
558- this . buildTime = properties. get(" git.build.time" ). toString( );
559- this . buildHost = properties. get(" git.build.host" ). toString( );
560- this . buildVersion = properties. get(" git.build.version" ). toString( );
533+ this . tags = String . valueOf( properties. get(" git.tags" ));
534+ this . branch = String . valueOf( properties. get(" git.branch" ));
535+ this . dirty = String . valueOf( properties. get(" git.dirty" ));
536+ this . remoteOriginUrl = String . valueOf( properties. get(" git.remote.origin.url" ));
537+
538+ this . commitId = String . valueOf( properties. get(" git.commit.id.full" )); // OR properties.get("git.commit.id") depending on your configuration
539+ this . commitIdAbbrev = String . valueOf( properties. get(" git.commit.id.abbrev" ));
540+ this . describe = String . valueOf( properties. get(" git.commit.id.describe" ));
541+ this . describeShort = String . valueOf( properties. get(" git.commit.id.describe-short" ));
542+ this . commitUserName = String . valueOf( properties. get(" git.commit.user.name" ));
543+ this . commitUserEmail = String . valueOf( properties. get(" git.commit.user.email" ));
544+ this . commitMessageFull = String . valueOf( properties. get(" git.commit.message.full" ));
545+ this . commitMessageShort = String . valueOf( properties. get(" git.commit.message.short" ));
546+ this . commitTime = String . valueOf( properties. get(" git.commit.time" ));
547+ this . closestTagName = String . valueOf( properties. get(" git.closest.tag.name" ));
548+ this . closestTagCommitCount = String . valueOf( properties. get(" git.closest.tag.commit.count" ));
549+
550+ this . buildUserName = String . valueOf( properties. get(" git.build.user.name" ));
551+ this . buildUserEmail = String . valueOf( properties. get(" git.build.user.email" ));
552+ this . buildTime = String . valueOf( properties. get(" git.build.time" ));
553+ this . buildHost = String . valueOf( properties. get(" git.build.host" ));
554+ this . buildVersion = String . valueOf( properties. get(" git.build.version" ));
561555}
562556```
563557
0 commit comments