-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
290 lines (250 loc) · 10.1 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
290 lines (250 loc) · 10.1 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import com.github.jk1.license.filter.LicenseBundleNormalizer
import net.researchgate.release.ReleaseExtension
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.net.URI
import java.nio.file.Files
import java.util.*
plugins {
`kotlin-dsl`
`maven-publish`
idea
`java-gradle-plugin`
id("net.researchgate.release") version "3.1.0"
id("com.github.jk1.dependency-license-report") version "3.1.1"
id("org.cyclonedx.bom") version "1.10.0"
}
tasks.withType<JavaCompile> {
options.release.set(11)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
val fsmAnnotationsVersion = "3.3.0"
val branchName = rootDir.resolve(".git/HEAD").readText().substringAfterLast("/").trim()
Regex("(?:.*/)?[^A-Z]*([A-Z]+-[0-9]+).*").matchEntire(branchName)?.let {
project.version = "${it.groupValues[1]}-SNAPSHOT"
}
description = "Gradle plugin to build FirstSpirit modules (FSMs)."
group = "de.espirit.gradle"
repositories {
maven(url = "https://artifactory.e-spirit.de/artifactory/repo") {
credentials {
username = property("artifactory_username") as String
password = property("artifactory_password") as String
}
}
}
gradlePlugin {
plugins {
register("firstSpiritModule") {
id = "de.espirit.firstspirit-module"
implementationClass = "org.gradle.plugins.fsm.FSMPlugin"
}
register("firstSpiritModuleAnnotations") {
id = "de.espirit.firstspirit-module-annotations"
implementationClass = "org.gradle.plugins.fsm.annotations.FSMAnnotationsPlugin"
}
register("firstSpiritModuleConfigurations") {
id = "de.espirit.firstspirit-module-configurations"
implementationClass = "org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin"
}
}
}
val fsRuntimeVersion = "5.2.251108" // FirstSpirit 2025-11
dependencies {
implementation("io.github.classgraph:classgraph:4.8.184")
implementation("com.github.jk1:gradle-license-report:3.1.1")
implementation("org.redundent:kotlin-xml-builder:1.9.3")
implementation("org.apache.maven:maven-artifact:3.9.11")
implementation("com.espirit.moddev.components:annotations:${fsmAnnotationsVersion}")
implementation("de.espirit.firstspirit:fs-isolated-runtime:${fsRuntimeVersion}")
compileOnly("com.tngtech.archunit:archunit-junit5:1.4.1")
testImplementation("de.espirit.firstspirit:fs-isolated-runtime:${fsRuntimeVersion}")
testImplementation("org.junit.jupiter:junit-jupiter:5.14.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("org.mockito:mockito-junit-jupiter:5.21.0")
testImplementation("org.ow2.asm:asm:9.9")
}
licenseReport {
allowedLicensesFile = projectDir.resolve("config/allowed-licenses.json")
filters = arrayOf(LicenseBundleNormalizer())
}
tasks.checkLicense {
dependsOn(tasks.cyclonedxBom)
}
tasks.cyclonedxBom {
setIncludeConfigs(listOf("runtimeClasspath"))
setOutputFormat("json")
}
val bom by configurations.creating
val bomFile = layout.buildDirectory.file("reports/bom.json")
val bomArtifact = artifacts.add(bom.name, bomFile.get().asFile) {
type = "bom"
extension = "bom"
builtBy(tasks.cyclonedxBom)
}
sourceSets {
test {
resources.srcDirs += file("src/test/resources")
resources.srcDirs += file("src/main/resources")
}
}
val writePropertiesToResourceFile by tasks.registering {
outputs.upToDateWhen { false }
doLast {
val props = Properties()
props.setProperty("fsm-annotations-version", fsmAnnotationsVersion)
props.setProperty("version", version as String)
val propsFile = sourceSets.main.get().output.resourcesDir!!.resolve("fsm-gradle-plugin/versions.properties")
val propsFileTest = sourceSets.test.get().output.resourcesDir!!.resolve("fsm-gradle-plugin/versions.properties")
listOf(propsFile, propsFileTest).forEach { targetFile ->
targetFile.parentFile.mkdirs()
if (!targetFile.exists()) {
Files.createFile(targetFile.toPath())
}
targetFile.writer().use { writer ->
props.store(writer, null)
}
}
}
}
tasks.jar {
dependsOn(writePropertiesToResourceFile)
manifest {
attributes["Implementation-Title"] = "Gradle FSM plugin"
attributes["Implementation-Version"] = archiveVersion
attributes["Built-By"] = System.getProperty("user.name")
attributes["Built-Date"] = Date()
attributes["Built-JDK"] = System.getProperty("java.version")
attributes["Built-Gradle"] = gradle.gradleVersion
}
}
/**
* Bundles together test classes for component scan tests
*/
val testJar by tasks.registering(Jar::class) {
dependsOn(tasks.testClasses)
archiveClassifier.set("tests")
from("build/classes/groovy/test")
from("build/classes/java/test")
from("build/classes/kotlin/test")
// These files should only be visible for certain test cases and will be added when needed
exclude("org/gradle/plugins/fsm/TestModuleImpl.class")
exclude("org/gradle/plugins/fsm/TestWebAppWithProjectProperties.class")
exclude("org/gradle/plugins/fsm/TestProjectAppComponentWithProperties.class")
exclude("org/gradle/plugins/fsm/AbstractWebAppComponent.class")
exclude("org/gradle/plugins/fsm/NoInterfaceWebAppComponent.class")
exclude("org/gradle/plugins/fsm/NoInterfaceProjectAppComponent.class")
}
tasks.test {
dependsOn(writePropertiesToResourceFile)
dependsOn(testJar)
filter {
excludeTestsMatching("*IT")
}
systemProperty("artifactory_username", findProperty("artifactory_username") as String)
systemProperty("artifactory_password", findProperty("artifactory_password") as String)
systemProperty("gradle.version", gradle.gradleVersion)
systemProperty("version", version)
systemProperty("testJar", testJar.get().archiveFile.get().asFile.absolutePath)
systemProperty("classesDir", layout.buildDirectory.dir("classes").get().asFile.absolutePath)
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// Gradle may keep locks on Windows systems, causing the @TempDir cleanup to fail
systemProperty("junit.jupiter.tempdir.cleanup.mode.default", "NEVER")
}
maxHeapSize = "2048m"
useJUnitPlatform()
}
val integrationTest by tasks.registering(Test::class) {
filter {
includeTestsMatching("*IT")
}
systemProperty("artifactory_username", findProperty("artifactory_username") as String)
systemProperty("artifactory_password", findProperty("artifactory_password") as String)
useJUnitPlatform()
}
tasks.check {
dependsOn(tasks.checkLicense)
}
tasks.publish {
dependsOn(tasks.checkLicense)
}
publishing {
publications {
create<MavenPublication>("pluginMaven") {
pom.withXml {
val root = asNode()
root.appendNode("name", "FSM Gradle plugin")
root.appendNode("description", "Gradle plugin to build FirstSpirit modules (FSMs).")
root.appendNode("inceptionYear", "2013")
val license = root.appendNode("licenses").appendNode("license")
license.appendNode("name", "The Apache Software License, Version 2.0")
license.appendNode("url", "https://www.apache.org/licenses/LICENSE-2.0.txt")
license.appendNode("distribution", "repo")
val developers = root.appendNode("developers")
val originalDeveloper = developers.appendNode("developer")
originalDeveloper.appendNode("id", "moritzzimmer")
originalDeveloper.appendNode("name", "Moritz Zimmer")
originalDeveloper.appendNode("email", "moritz.zmmr@gmail.com")
val developer = developers.appendNode("developer")
developer.appendNode("id", "crownpeak")
developer.appendNode("name", "Crownpeak Technology GmbH")
developer.appendNode("url", "https://www.crownpeak.com")
}
artifact(bomArtifact)
}
}
repositories {
maven {
credentials {
username = property("artifactory_username") as String?
password = property("artifactory_password") as String?
}
url = if (version.toString().endsWith("SNAPSHOT")) {
URI.create("https://artifactory.e-spirit.de/artifactory/core-platform-mvn-snapshot")
} else {
URI.create("https://artifactory.e-spirit.de/artifactory/core-platform-mvn-release")
}
}
}
}
rootProject.tasks.afterReleaseBuild {
dependsOn(tasks.publish)
}
// CI-facing wrappers that build the test-project/ fixture from the repo root.
// The Bamboo plan invokes Gradle on the root project, so we expose
// the two interesting fixture invocations (default descriptor + custom template)
// as separate tasks so a CI run shows a distinct failure per code path.
val testProjectDir = layout.projectDirectory.dir("test-project")
val testProjectWrapper = if (Os.isFamily(Os.FAMILY_WINDOWS)) "gradlew.bat" else "gradlew"
val buildTestProject by tasks.registering(Exec::class) {
group = "verification"
description = "Builds the test-project/ fixture with the plugin-provided default descriptor template."
workingDir(testProjectDir)
commandLine(testProjectDir.file(testProjectWrapper).asFile.absolutePath, ":fsm:build")
}
val buildTestProjectWithTemplate by tasks.registering(Exec::class) {
group = "verification"
description = "Builds the test-project/ fixture with the fixture's own custom descriptor template."
workingDir(testProjectDir)
commandLine(
testProjectDir.file(testProjectWrapper).asFile.absolutePath,
":fsm:build",
"-PuseModuleDescriptorTemplate=true"
)
}
configure<ReleaseExtension> {
with(git) {
requireBranch.set("master")
}
}
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}