-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
93 lines (79 loc) · 3.19 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
import org.gradle.configurationcache.extensions.capitalized
import java.io.ByteArrayOutputStream
import java.io.OutputStream
plugins {
id("java")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
implementation(files("lib/jpf-classes.jar"))
implementation(files("lib/jpf-annotations.jar"))
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
// create task for run Main
tasks.register<JavaExec>("runMain") {
group = "Verification"
description = "Run the main class"
mainClass.set("Main")
classpath = sourceSets["main"].runtimeClasspath
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
vendor.set(JvmVendorSpec.ADOPTIUM)
}
}
// Utility function for verification through JPF
val verificationGroup = "Verification"
val verifyAll by tasks.register<DefaultTask>("runVerifyAll") {
group = verificationGroup
description = "Run all the JPF verification"
}
/**
* This function will return an array of string that will be used to mount the container
* The container will be mounted with all the files and folders of the project, except the build folder
*/
val allFileButBuildAndHide = File(rootProject.rootDir.path)
.listFiles { a -> !(a.name.startsWith(".") || a.name == "build") }
.map { it -> "type=bind,source=${it.absolutePath},target=/home/${it.name}" }
.flatMap { it -> listOf("--mount", it) }
.toTypedArray()
// Path in which the search of other jpf file starts
val searchingPath = "/src/main/jpf/"
// Output for all tasks
val noOutput = ByteArrayOutputStream()
/**
* This will create a task for each jpf file in the src/main/jpf folder
* Particularly, it will create two tasks called run<FileName>Verify and run<FileName>Clean
* The first one will run the verification, the second one will clean the container
* With cleanAll you can clean all the containers, you can do that when you want clean the environment
* If you have a jpf in another path, then it is better to use the jpfVerify task
*/
File(rootProject.rootDir.path + searchingPath).listFiles()
?.filter { it.extension == "jpf" }
?.sortedBy { it.nameWithoutExtension }
?.forEach {
fun launchVerificationTask(taskName: String, file: File) = tasks.register<JavaExec>(taskName) {
group = verificationGroup
description = "Verify the ${file.nameWithoutExtension} using JPF"
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(8))
}
)
main = "-jar"
args = listOf("./jpf-runner/build/RunJPF.jar", ".${searchingPath}" + file.name)
}
val capitalizedName = it.nameWithoutExtension.capitalize()
val jpfVerification by launchVerificationTask("run${capitalizedName}Verify", it)
jpfVerification.dependsOn(tasks.getByName("compileJava"))
verifyAll.dependsOn(jpfVerification)
}