Skip to content

Commit cceda8c

Browse files
authored
Merge pull request #311 from kit-data-manager/development
Next Version (v2.2.1)
2 parents e4dde7e + d31aa4c commit cceda8c

2 files changed

Lines changed: 79 additions & 2 deletions

File tree

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ plugins {
2626

2727
lombok {
2828
// check here for new versions: https://projectlombok.org/download
29-
version = '1.18.30'
29+
version = '1.18.38'
3030
}
3131

3232
jacoco {
3333
// check here for new versions: https://www.jacoco.org/jacoco/
34-
toolVersion = "0.8.11"
34+
toolVersion = "0.8.13"
3535
}
3636

3737
description = "A gateway to manage PIDs containing profiles and typed attributes."
@@ -223,3 +223,5 @@ tasks.withType(Jar).configureEach { duplicatesStrategy(DuplicatesStrategy.EXCLUD
223223
tasks.withType(Tar).configureEach { duplicatesStrategy(DuplicatesStrategy.EXCLUDE) }
224224
tasks.withType(Copy).configureEach { duplicatesStrategy(DuplicatesStrategy.EXCLUDE) }
225225
tasks.withType(Zip).configureEach { duplicatesStrategy(DuplicatesStrategy.EXCLUDE) }
226+
227+
apply from: 'gradle/updateCff.gradle'

gradle/updateCff.gradle

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import java.time.LocalDate
2+
import java.time.format.DateTimeFormatter
3+
4+
/**
5+
* This file defines the updateCff task.
6+
*
7+
* This task hooks into the workflow of the release task,
8+
* which, according to the source code of the release plugin,
9+
* seems to be defined like this:
10+
*
11+
* tasks = [
12+
* "${p}createScmAdapter" as String,
13+
* "${p}initScmAdapter" as String,
14+
* "${p}checkCommitNeeded" as String,
15+
* "${p}checkUpdateNeeded" as String,
16+
* "${p}checkoutMergeToReleaseBranch" as String,
17+
* "${p}unSnapshotVersion" as String,
18+
* "${p}confirmReleaseVersion" as String,
19+
* -> we insert our task here <-
20+
* "${p}checkSnapshotDependencies" as String,
21+
* "${p}runBuildTasks" as String,
22+
* "${p}preTagCommit" as String,
23+
* "${p}createReleaseTag" as String,
24+
* "${p}checkoutMergeFromReleaseBranch" as String,
25+
* "${p}updateVersion" as String,
26+
* "${p}commitNewVersion" as String
27+
* ]
28+
*/
29+
30+
tasks.register('updateCff') {
31+
group = 'release'
32+
description = 'Updates the version in CITATION.cff file'
33+
34+
inputs.file("CITATION.cff")
35+
outputs.file("CITATION.cff")
36+
37+
doLast {
38+
def version = project.version.toString()
39+
def today = LocalDate.now().format(DateTimeFormatter.ISO_DATE)
40+
41+
def cffFile = file('CITATION.cff')
42+
def content = cffFile.text
43+
44+
if (!content.endsWith("\n")) {
45+
content += "\n" // Ensure the file ends with a newline
46+
}
47+
48+
// Update or insert version
49+
if (content =~ /(?m)^version:/) {
50+
content = content.replaceAll(/(?m)^version:\s*.+$/, "version: ${version}")
51+
} else {
52+
content = content + "version: ${version}\n"
53+
}
54+
55+
// Update or insert date-released
56+
if (content =~ /(?m)^date-released:/) {
57+
content = content.replaceAll(/(?m)^date-released:\s*.+$/, "date-released: ${today}")
58+
} else {
59+
content = content + "date-released: ${today}\n"
60+
}
61+
62+
cffFile.text = content
63+
println "Updated CITATION.cff to version ${version} and date-released ${today}"
64+
}
65+
}
66+
67+
// Make sure your custom task runs after a specific task in the release sequence
68+
tasks.named('updateCff') {
69+
mustRunAfter(tasks.named('confirmReleaseVersion'))
70+
}
71+
72+
// Ensure subsequent tasks in the release sequence run after your custom task
73+
tasks.named('checkSnapshotDependencies') {
74+
dependsOn('updateCff')
75+
}

0 commit comments

Comments
 (0)