-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
77 lines (66 loc) · 2.29 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
77 lines (66 loc) · 2.29 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
import groovy.json.JsonSlurper
// include the mendix defined variables (mendix install dir, public api jars, userlib dir, vendorlib dir, ...)
// due to that usage this gradle build only works on windows
apply(from = "deployment/variables.gradle")
plugins {
// Apply the java-library plugin for API and implementation separation.
`java-library`
}
java {
sourceSets {
getByName("main") {
java.setSrcDirs(listOf("javasource"))
resources.setSrcDirs(listOf("javasource"))
resources.exclude("**/*.java")
}
getByName("test") {
java.setSrcDirs(listOf("javatestsource"))
resources.setSrcDirs(listOf("javatestsource"))
resources.exclude("**/*.java")
}
}
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
val mendixInstallDir: String? by extra
val publicApiJars: List<String>? by extra
val userlibDirName: String? by extra
val vendorlibDirName: String? by extra
dependencies {
// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.11.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.4")
// Mendix public API jars
publicApiJars?.forEach { apiJar ->
implementation(files("$mendixInstallDir/$apiJar"))
}
// userlib jars
fileTree("$userlibDirName") { include("*.jar") }.forEach { libFile ->
implementation(files(libFile.path))
}
// vendorlib jars
val sbomFile = file("$vendorlibDirName/vendorlib-sbom.json")
if (sbomFile.exists()) {
val jsonSlurper = JsonSlurper()
val sbom = jsonSlurper.parse(sbomFile)
val components = (sbom as Map<String, Any>)["components"] as List<Map<String, Any>>
components.forEach { component ->
val group = component["group"] as String
val name = component["name"] as String
val version = component["version"] as String
implementation(group = group, name = name, version = version)
}
}
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}