Skip to content

Commit 74f24bb

Browse files
committed
docs: add documentation to custom changelog tasks
1 parent 5a62e7a commit 74f24bb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

build-logic/src/main/groovy/buildlogic.changelog-conventions.gradle

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,28 @@ spotlessChangelog {
2020

2121
version = spotlessChangelog.versionNext
2222

23+
def changelogTaskGroup = 'Changelog'
2324
tasks.register('changelogPrintCurrentVersion') {
25+
group = changelogTaskGroup
26+
description = 'Prints the current version of the project based on the changelog'
2427
def versionToPrint = spotlessChangelog.versionNext
2528
doLast {
2629
println "${versionToPrint}"
2730
}
2831
}
2932

3033
tasks.register('changelogPrintUnreleasedVersionContent') {
34+
group = changelogTaskGroup
35+
description = 'Prints the content of the unreleased version in the changelog'
3136
def changelog = spotlessChangelog.parsedChangelog
3237
doLast {
3338
println "${changelog.unreleasedChanges()}"
3439
}
3540
}
3641

3742
tasks.register('changelogPrintLatestVersionContent') {
43+
group = changelogTaskGroup
44+
description = 'Prints the content of the latest version in the changelog'
3845
def changelog = spotlessChangelog.parsedChangelog
3946
doLast {
4047
String changelogString = changelog.toStringUnix()
@@ -48,12 +55,15 @@ tasks.register('changelogPrintLatestVersionContent') {
4855
}
4956
}
5057
tasks.register('changelogPrintVersionContent') {
58+
group = changelogTaskGroup
59+
description = 'Prints the content of a specific version in the changelog'
5160
def changelog = spotlessChangelog.parsedChangelog
52-
if (!project.hasProperty('changelogPrintVersion') || project.changelogPrintVersion == '') {
53-
throw new IllegalArgumentException("Please provide a version to print with -PchangelogPrintVersion=<version>")
54-
}
55-
def versionToPrint = project.changelogPrintVersion
61+
62+
def versionToPrint = project.getProperties().getOrDefault('changelogPrintVersion', '')
5663
doLast {
64+
if (versionToPrint == '') {
65+
throw new IllegalArgumentException("Please provide a version to print with -PchangelogPrintVersion=<version>")
66+
}
5767
String changelogString = changelog.toStringUnix()
5868
String changeLog = changelogString.lines()
5969
.dropWhile { String line -> !line.startsWith("## [${versionToPrint}]") }

0 commit comments

Comments
 (0)