Git Changelog Maven Plugin
This is a Maven plugin for Git Changelog Lib.
Usage
There is a running example here.
Have a look at the pom.xml where you will find some more examples.
Here is and example that will generate a CHANGELOG.md when running mvn generate-resources
.
<build>
<plugins>
<plugin>
<groupId>se.bjurr.gitchangelog</groupId>
<artifactId>git-changelog-maven-plugin</artifactId>
<version>${changelog}</version>
<executions>
<execution>
<id>GenerateGitChangelog</id>
<phase>generate-sources</phase>
<goals>
<goal>git-changelog</goal>
</goals>
<configuration>
<templateContent>
<![CDATA[
Template here!
]]>
</templateContent>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Template - Simple
Template - Semantic versioning from conventional commits
If you are using conventional commits:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
A changelog can be rendered (using Helpers) like this:
Example - custom helpers
You can add your own helpers and use them in the template. There are also built in Helpers.
<build>
<plugins>
<plugin>
<groupId>se.bjurr.gitchangelog</groupId>
<artifactId>git-changelog-maven-plugin</artifactId>
<version>${changelog}</version>
<executions>
<execution>
<id>GenerateGitChangelog</id>
<phase>generate-sources</phase>
<goals>
<goal>git-changelog</goal>
</goals>
<configuration>
<javascriptHelper>
<![CDATA[
Handlebars.registerHelper('startsWith', function(messageTitle, options) {
const s = options.hash['s']
if (new RegExp('^' + s + '.*').test(messageTitle)) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
Handlebars.registerHelper('firstLetters', function(from, options) {
const num = parseInt(options.hash['number'])
return from.substring(0,num)
});
]]>
</javascriptHelper>
<templateContent>
<![CDATA[
{{#commits}}
{{#startsWith messageTitle s='Removing'}}
Starts with Removing: "{{messageTitle}}"
first 10 letters of hash is: {{firstLetters hash number='10'}}
{{/startsWith}}
{{/commits}}
]]>
</templateContent>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
More documentation can be found in the Git Changelog Lib.