-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
117 lines (107 loc) · 3.07 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
import org.sourcegrade.submitter.submit
plugins {
java
application
id("org.sourcegrade.style") version "1.3.0"
id("org.sourcegrade.submitter") version "0.4.0"
}
version = "1.0.1"
repositories {
mavenCentral()
}
submit {
assignmentId = "h07"
studentId = "ab12cdef"
firstName = "sol_first"
lastName = "sol_last"
requireTests = false
}
val grader: SourceSet by sourceSets.creating {
val test = sourceSets.test.get()
compileClasspath += test.output + test.compileClasspath
runtimeClasspath += output + test.runtimeClasspath
}
dependencies {
implementation("org.jetbrains:annotations:23.0.0")
implementation("org.junit.jupiter:junit-jupiter:5.8.1")
"graderCompileOnly"("org.sourcegrade:jagr-launcher:0.4.0") {
exclude("org.jetbrains", "annotations")
}
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.mockito:mockito-core:4.5.1")
}
application {
mainClass.set("h07.Main")
}
tasks {
val runDir = File("build/run")
named<JavaExec>("run") {
doFirst {
runDir.mkdirs()
}
workingDir = runDir
}
test {
doFirst {
runDir.mkdirs()
}
workingDir = runDir
useJUnitPlatform()
}
val graderTest by creating(Test::class) {
group = "verification"
doFirst {
runDir.mkdirs()
}
workingDir = runDir
testClassesDirs = grader.output.classesDirs
classpath = grader.compileClasspath + grader.runtimeClasspath
useJUnitPlatform()
}
named("check") {
dependsOn(graderTest)
}
val graderJar by creating(Jar::class) {
group = "build"
afterEvaluate {
archiveFileName.set("AuD-2022-H07-${project.version}.jar")
from(sourceSets.main.get().allSource)
from(sourceSets.test.get().allSource)
from(grader.allSource)
}
}
val graderLibs by creating(Jar::class) {
group = "build"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// don't include Jagr's runtime dependencies
val jagrRuntime = configurations["graderCompileClasspath"]
.resolvedConfiguration
.firstLevelModuleDependencies
.first { it.moduleGroup == "org.sourcegrade" && it.moduleName == "jagr-launcher" }
.allModuleArtifacts
.map { it.file }
val runtimeDeps = grader.runtimeClasspath.mapNotNull {
if (it.path.toLowerCase().contains("h07") || jagrRuntime.contains(it)) {
null
} else if (it.isDirectory) {
it
} else {
zipTree(it)
}
}
from(runtimeDeps)
archiveFileName.set("AuD-2022-H07-${project.version}-libs.jar")
}
create("graderAll") {
group = "build"
dependsOn(graderJar, graderLibs)
}
withType<JavaCompile> {
options.encoding = "UTF-8"
sourceCompatibility = "17"
targetCompatibility = "17"
}
jar {
enabled = false
}
}