Change Log Builder Gradle Plugin

The Change Log Builder Gradle plugin lets you generate and maintain a change log file based on the Git commits in your project. A change log file generated by this plugin looks like this

    #
    # Bundle Version 1.0.1
    #
    9c77ff4c95cb1a325db3bdd089be105206e8b63c^..b421f00ac84b065685b131833fecc594fc01c760=LPS-123 LPS-1321

    #
    # Bundle Version 1.0.2
    #
    b421f00ac84b065685b131833fecc594fc01c760^..bc15d8d84e12b9544f78e4e3743c510dbaec2d89=LPS-456

Every time the buildChangeLog task is executed, a new line is added to the change log, which lists all Git commit prefixes (usually issue ticket IDs) that occurred in a certain range. The end of the range is always the tip of the current branch. The start range can vary, depending on the case:

  • If buildChangeLog has never been executed for the project, the change log does not exist. Therefore, the most recent commit from two years ago is used for the range start.
  • If a change log already exists for your project, the start range begins at the range end of the last line in the change log.

The plugin has been successfully tested with Gradle 4.10.2.

Usage

To use the plugin, include it in your build script:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.change.log.builder", version: "1.1.3"
    }

    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}

apply plugin: "com.liferay.change.log.builder"

Tasks

The plugin adds one task to your project:

NameDepends OnTypeDescription
buildChangeLog-BuildChangeLogTaskBuilds the change log file for this project.

The buildChangeLog task is automatically configured with sensible defaults, depending on whether the java plugin is applied:

Property NameDefault Value
changeLogHeader"Bundle Version ${project.version}"
changeLogFile

If the java plugin is applied: The META-INF/liferay-releng.changelog file in the first resources directory of the main source set (by default, src/main/resources/META-INF/liferay-releng.changelog).

Otherwise: "${project.projectDir}/liferay-releng.changelog"

dirs[project.projectDir]

BuildChangeLogTask

Task Properties

Property NameTypeDefault ValueDescription
changeLogFileFilenullThe change log file to build.
changeLogHeaderStringnullThe header for the new line in the change log.
dirsFileCollection[]The directories to consider when listing the commits in the range specified.
gitDirFileproject.rootDirThe base directory to start searching for the .git directory. The search proceeds in all the ancestors of the directory specified.
rangeEndStringnullThe hash of the last commit to consider. If not set, it corresponds to the range end of the last line in the change log, or the most recent commit from at least two years ago if the change log file does not exist yet.
rangeStartStringnullThe hash of the first commit to consider. If not set, it corresponds to the hash of the tip of the current branch.
ticketIdPrefixesSet<String>["CLDSVCS", "LPS", "SOS", "SYNC"]The valid prefix of the Git commit messages to add to the change log. For example, if a commit message is "LPS-123 Bugfix", "LPS-123" will be added to the change log.

The properties of type File support any type that can be resolved by project.file. Moreover, it is possible to use Closures and Callables as values for the String properties to defer evaluation until task execution.

Task Methods

MethodDescription
BuildChangeLogTask dirs(Iterable<?> dirs)Adds directories to consider when listing the commits in the range specified.
BuildChangeLogTask dirs(Object... dirs)Adds directories to consider when listing the commits in the range specified.
BuildChangeLogTask ticketIdPrefixes(Iterable<String> ticketIdPrefixes)Adds valid prefixes of the Git commit messages to add to the change log.
BuildChangeLogTask ticketIdPrefixes(String... ticketIdPrefixes)Adds valid prefixes of the Git commit messages to add to the change log.
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています