This is a Maven plugin for Git Changelog Lib.
Version | Java Version |
---|---|
version < 2.0.0 | 8 |
2.0.0 <= version < 2.2.0 | 11 |
2.2.0 <= version | 17 |
There is a running example here. See also bjurr-bom.
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>
<dependencies>
<!-- This dependency is only needed if you add your own javascript-helpers //-->
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>GenerateGitChangelog</id>
<phase>generate-sources</phase>
<goals>
<goal>git-changelog</goal>
</goals>
<configuration>
<templateContent>
<![CDATA[
Optional template here!
Context documented here: https://github.com/tomasbjerre/git-changelog-lib
]]>
</templateContent>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
If you have a multimodule you may want to put <inherited>false</inherited>
within the <plugin>
tag to avoid it being applied to all child projects.
##
### []() ** **
### ** **
###
**}**
*
[](https://github.com///commit/) **
If you are using conventional commits:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
A changelog can be rendered (using Helpers) like this:
# Changelog
## [](https://gitservice/) ()
### Features
- **** } ([](https://gitservice/commit/))
### Bug Fixes
- **** } ([](https://gitservice/commit/))
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>
<dependencies>
<!-- This dependency is only needed if you add your own javascript-helpers //-->
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.4</version>
</dependency>
</dependencies>
<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[
Starts with Removing: ""
first 10 letters of hash is:
]]>
</templateContent>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
More documentation can be found in the Git Changelog Lib.
Have a look at the pom.xml where you will find some more examples.
The version in pom.xml
can be automatically updated based on conventional commits.
From command line:
mvn se.bjurr.gitchangelog:git-changelog-maven-plugin:VERSION_HERE:semantic-version
You can combine it with maven release plugin like this:
mvn \
se.bjurr.gitchangelog:git-changelog-maven-plugin:VERSION_HERE:semantic-version \
release:prepare release:perform
Or in pom.xml
:
<build>
<plugins>
<plugin>
<groupId>se.bjurr.gitchangelog</groupId>
<artifactId>git-changelog-maven-plugin</artifactId>
<version>${changelog}</version>
<dependencies>
<!-- This dependency is only needed if you add your own javascript-helpers //-->
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>GenerateGitChangelog</id>
<phase>generate-sources</phase>
<goals>
<goal>semantic-version</goal>
</goals>
<configuration>
<!-- Suffix version with -SNAPSHOT //-->
<updatePomWithNextSemanticVersionSuffixSnapshot>false</updatePomWithNextSemanticVersionSuffixSnapshot>
<updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged>true</updatePomWithCurrentSemanticVersionSuffixSnapshotIfNotTagged>
<!-- Regexp patterns used to identify next version can optionally be adjusted //-->
<semanticMajorVersionPattern>^[Bb]reaking</semanticMajorVersionPattern>
<semanticMinorVersionPattern>[Ff]eature</semanticMinorVersionPattern>
<semanticPatchVersionPattern>[Ff]ix</semanticPatchVersionPattern>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>