在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):JetBrains/gradle-changelog-plugin开源软件地址(OpenSource Url):https://github.com/JetBrains/gradle-changelog-plugin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Gradle Changelog PluginThis project requires Gradle 6.7.1 or newer
A Gradle plugin providing tasks and helper methods to simplify working with a changelog that is managed in the keep a changelog style. Table of contents
Usage
The latest available version is: build.gradle.kts (Kotlin) import org.jetbrains.changelog.date
plugins {
id("org.jetbrains.changelog") version "..."
}
tasks {
// ...
patchPluginXml {
changeNotes(provider { changelog.getUnreleased().toHTML() })
}
}
changelog {
version.set("1.0.0")
path.set("${project.projectDir}/CHANGELOG.md")
header.set(provider { "[${version.get()}] - ${date()}" })
itemPrefix.set("-")
keepUnreleasedSection.set(true)
unreleasedTerm.set("[Unreleased]")
groups.set(listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"))
} build.gradle (Groovy) import java.text.SimpleDateFormat
import org.jetbrains.changelog.ExtensionsKt
plugins {
id 'org.jetbrains.changelog' version '...'
}
apply plugin: 'org.jetbrains.changelog'
intellij {
// ...
patchPluginXml {
changeNotes({ changelog.getUnreleased().toHTML() })
}
}
changelog {
version = "1.0.0"
path = "${project.projectDir}/CHANGELOG.md"
header = "[${-> version.get()}] - ${new SimpleDateFormat("yyyy-MM-dd").format(new Date())}"
headerParserRegex = ~/(\d+\.\d+)/
itemPrefix = "-"
keepUnreleasedSection = true
unreleasedTerm = "[Unreleased]"
groups = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]
}
ConfigurationPlugin can be configured with the following properties set in the
TasksThe plugin introduces the following tasks:
|
Option | Description |
---|---|
--no-header |
Skips the first version header line in the output. |
--unreleased |
Returns Unreleased change notes. |
$ ./gradlew getChangelog --console=plain -q --no-header
### Added
- Initial project scaffold
- GitHub Actions to automate testing and deployment
- Kotlin support
initializeChangelog
Creates new changelog file with Unreleased section and empty groups.
$ ./gradlew initializeChangelog
$ cat CHANGELOG.md
## [Unreleased]
### Added
- Example item
### Changed
### Deprecated
### Removed
### Fixed
### Security
patchChangelog
Updates the unreleased section to the given version. Requires unreleased section to be present in the changelog file.
Option | Description |
---|---|
--release-note |
Adds custom release note to the latest changelog entry. |
$ cat CHANGELOG.md
## [Unreleased]
### Added
- A based new feature
$ ./gradlew patchChangelog
$ cat CHANGELOG.md
## [Unreleased]
### Added
## [1.0.0]
### Added
- A based new feature
$ cat CHANGELOG.md
## [Unreleased]
### Added
- This note will get overridden by the `--release-note`
$ ./gradlew patchChangelog --release-note='- Foo'
$ cat CHANGELOG.md
## [Unreleased]
### Added
## [1.0.0]
- Foo
All the methods are available via the changelog
extension and allow for reading the changelog file within the Gradle tasks to provide the latest (or specific) change notes.
Note: Following methods depend on the
changelog
extension, which is set in the Configuration build phase. To make it run properly, it's required to place the configuration before the first usage of such a method. Alternatively, you can pass the Gradle closure to the task, which will postpone the method invocation.
get
The method returns a Changelog.Item
object for the specified version.
Throws MissingVersionException
if the version is not available.
It is possible to specify the unreleased section with setting the ${changelog.unreleasedTerm}
value.
Parameter | Type | Description | Default value |
---|---|---|---|
version |
String |
Change note version. | ${changelog.version} |
build.gradle.kts (Kotlin)
tasks {
patchPluginXml {
changeNotes.set(provider { changelog.get("1.0.0").toHTML() })
}
}
build.gradle (Groovy)
tasks {
patchPluginXml {
changeNotes = { changelog.get("1.0.0").toHTML() }
}
}
getOrNull
Same as get
, but returns null
instead of throwing MissingVersionException
.
Parameter | Type | Description | Default value |
---|---|---|---|
version |
String |
Change note version. | ${changelog.version} |
getUnreleased
The method returns a Changelog.Item
object for the unreleased version.
build.gradle.kts (Kotlin)
tasks {
patchPluginXml {
changeNotes.set(provider { changelog.getUnreleased().toHTML() })
}
}
build.gradle (Groovy)
tasks {
patchPluginXml {
changeNotes = { changelog.getUnreleased().toHTML() }
}
}
getLatest
The method returns the latest Changelog.Item
object (first on the list).
build.gradle.kts (Kotlin)
tasks {
patchPluginXml {
changeNotes.set(provider { changelog.getLatest().toHTML() })
}
}
build.gradle (Groovy)
tasks {
patchPluginXml {
changeNotes = { changelog.getLatest().toHTML() }
}
}
getAll
The method returns all available Changelog.Item
objects.
build.gradle.kts (Kotlin)
extension.getAll().values.map { it.toText() }
build.gradle (Groovy)
extension.getAll().values().each { it.toText() }
has
The method checks if the given version exists in the changelog.
build.gradle.kts (Kotlin)
tasks {
patchPluginXml {
provider { changelog.has("1.0.0") }
}
}
build.gradle (Groovy)
tasks {
patchPluginXml {
{ changelog.has("1.0.0") }
}
}
Changelog.Item
Methods described in the above section return Changelog.Item
object, which is a representation of the single changelog section for the specific version.
It provides a couple of properties and methods that allow altering the output form of the change notes:
Name | Type | Description |
---|---|---|
version |
String |
Change note version. |
Name | Description | Returned type |
---|---|---|
noHeader() |
Excludes header part. | this |
noHeader(Boolean) |
Includes/excludes header part. | this |
getHeader() |
Returns header text. | String |
toText() |
Generates Markdown output. | String |
toPlainText() |
Generates Plain Text output. | String |
toString() |
Generates Markdown output. | String |
toHTML() |
Generates HTML output. | String |
Name | Description | Returned type |
---|---|---|
date(pattern: String = "yyyy-MM-dd") |
Shorthand for retrieving the current date in the given format. | String |
markdownToHTML(input: String) |
Converts given Markdown content to HTML output. | String |
markdownToPlainText(input: String) |
Converts given Markdown content to Plain Text output. | String |
Note: To use package-level Kotlin functions in Groovy, you need to import the containing file as a class:
import org.jetbrains.changelog.ExtensionsKt changelog { header = { "[$version] - ${ExtensionsKt.date('yyyy-MM-dd')}" } }
All releases are available in the Releases section. The latest available version is:
Please see CONTRIBUTING on how to submit feedback and contribute to this project.
Licensed under the Apache License, Version 2.0 (the "License"), see LICENCE.
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论