-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
163 lines (142 loc) · 4.6 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
@file:Suppress("UnstableApiUsage")
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
import java.time.LocalDate
import java.time.format.DateTimeFormatter
plugins {
`kotlin-dsl`
`java-gradle-plugin`
id("com.gradle.plugin-publish") version "1.3.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
id("io.gitlab.arturbosch.detekt") version "1.23.7"
id("net.researchgate.release") version "3.0.2"
}
group = "io.github.f-cramer.gradle"
version = properties["version"]
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
repositories {
mavenCentral()
maven { url = uri("https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/") }
}
val jasperreportsVersion = "6.17.0"
dependencies {
compileOnly(group = "net.sf.jasperreports", name = "jasperreports", version = jasperreportsVersion)
testCompileOnly(group = "net.sf.jasperreports", name = "jasperreports", version = jasperreportsVersion)
testImplementation(group = "com.willowtreeapps.assertk", name = "assertk-jvm", version = "0.28.1")
testImplementation(gradleTestKit())
}
ktlint {
enableExperimentalRules.set(true)
reporters {
reporter(ReporterType.PLAIN)
reporter(ReporterType.HTML)
reporter(ReporterType.CHECKSTYLE)
}
}
detekt {
buildUponDefaultConfig = true
config.from(".config/detekt.yml")
}
testing.suites.named<JvmTestSuite>("test") {
useJUnitJupiter()
targets {
all {
testTask.configure {
enabled = false
}
}
}
}
val javaVersions = listOf(
8,
17,
21,
23,
)
val jasperreportsVersions = listOf(
jasperreportsVersion,
"6.18.1",
"6.19.1",
"6.20.6",
"6.21.4",
"7.0.1",
)
for (javaVersion in javaVersions) {
for (jasperreportsVersion in jasperreportsVersions) {
testing.suites.create<JvmTestSuite>("test-jdk$javaVersion-jasperreports$jasperreportsVersion") {
useJUnitJupiter()
dependencies {
implementation("net.sf.jasperreports:jasperreports:$jasperreportsVersion")
runtimeOnly(sourceSets.test.get().runtimeClasspath)
compileOnly(sourceSets.test.get().compileClasspath)
annotationProcessor(sourceSets.test.get().annotationProcessorPath)
}
sources {
kotlin.setSrcDirs(listOf("src/test/kotlin"))
resources.setSrcDirs(listOf("src/test/resources"))
}
targets.configureEach {
testTask.configure {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
},
)
systemProperty("jasperreports.version", jasperreportsVersion)
}
}
}
tasks.named("check") {
dependsOn(testing.suites)
}
}
}
gradlePlugin {
website.set("https://github.com/f-cramer/jasperreports-gradle-plugin")
vcsUrl.set(website)
plugins {
create("jasperreportsPlugin") {
id = "io.github.f-cramer.jasperreports"
displayName = "JasperReports Gradle Plugin"
description = "A plugin for compiling JasperReports design files"
implementationClass = "com.github.fcramer.gradle.jasperreports.JasperReportsPlugin"
tags.add("jasperreports")
}
}
}
release {
tagTemplate.set("v\$version")
preTagCommitMessage.set("[Gradle Release Plugin] - release version ")
newVersionCommitMessage.set("[Gradle Release Plugin] - start work on ")
git {
requireBranch.set("master")
}
}
val changelogFile = File(rootDir, "CHANGELOG.md")
val setChangelogDate = tasks.register("setChangelogDate") {
doLast {
val changelog = changelogFile.readText()
val now = LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE)
val version = project.version.toString().removeSuffix("-SNAPSHOT")
changelogFile.writeText(changelog.replace("[unreleased]", "$version ($now)"))
}
}
val addChangelogEntry = tasks.register("addChangelogEntry") {
doLast {
val changelog = changelogFile.readText()
val version = project.version.toString().removeSuffix("-SNAPSHOT")
val entry = "## [unreleased]"
if (!changelog.startsWith(entry)) {
changelogFile.writeText(entry + "\n\n" + changelog)
}
}
}
tasks.named("preTagCommit") {
dependsOn(setChangelogDate)
}
tasks.named("updateVersion") {
finalizedBy(addChangelogEntry)
}