-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
94 lines (85 loc) · 2.76 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
import org.gradle.configurationcache.extensions.capitalized
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.multiJvmTesting)
alias(libs.plugins.taskTree)
}
repositories { mavenCentral() }
sourceSets {
main {
resources {
srcDir("src/main/protelis")
srcDir("src/main/yaml")
}
}
}
multiJvm {
jvmVersionForCompilation.set(17)
}
// Modules, versions, and bundles are declared in gradle/libs.versions.toml
dependencies {
implementation(libs.bundles.alchemist)
testImplementation(libs.bundles.kotest)
}
val batch: String by project
val maxTime: String by project
val alchemistGroup = "Run Alchemist"
/*
* This task is used to run all experiments in sequence
*/
val runAll by tasks.register<DefaultTask>("runAll") {
group = alchemistGroup
description = "Launches all simulations"
}
/*
* Scan the folder with the simulation files, and create a task for each one of them.
*/
File(rootProject.rootDir.path + "/src/main/yaml").listFiles()
.orEmpty()
.apply { check(isNotEmpty()) }
.filter { it.extension == "yml" }
.sortedBy { it.nameWithoutExtension }
.forEach {
val task by tasks.register<JavaExec>("run${it.nameWithoutExtension.capitalized()}") {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(multiJvm.latestJava))
}
)
group = alchemistGroup
description = "Launches simulation ${it.nameWithoutExtension}"
mainClass.set("it.unibo.alchemist.Alchemist")
classpath = sourceSets["main"].runtimeClasspath
val exportsDir = File("${projectDir.path}/build/exports/${it.nameWithoutExtension}")
doFirst {
if (!exportsDir.exists()) {
exportsDir.mkdirs()
}
}
args("run", it.absolutePath)
if (System.getenv("CI") == "true" || batch == "true") {
args(
"--override",
"""
{
terminate: { type: AfterTime, parameters: 2 }
}
""".trimIndent()
)
} else {
args(
"--override",
"{ monitors: { type: SwingGUI, parameters: { graphics: \"effects/${it.nameWithoutExtension}.json\" } } }"
)
}
outputs.dir(exportsDir)
}
runAll.dependsOn(task)
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed", "standardError")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}