-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
136 lines (113 loc) · 2.81 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* ================================
* Main Configuration
* ================================
*/
plugins {
java
antlr
}
group = "neodym"
version = "1.0.0"
val targetGroup = "neodym tasks"
layout.buildDirectory = file("build")
val mainFolder = file("src/main")
val testFolder = file("src/test")
val genFolder = file("src/gen")
repositories {
mavenCentral()
}
dependencies {
// ANTLR4
antlr("org.antlr:antlr4:4.13.1")
// Lombok
"1.18.30".let { lombokVersion ->
preprocessor("org.projectlombok:lombok:$lombokVersion")
compileTime("org.projectlombok:lombok:$lombokVersion")
}
// JUnit
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
vendor.set(JvmVendorSpec.ORACLE)
}
}
sourceSets {
main {
java.srcDirs(mainFolder, genFolder)
resources.srcDirs(mainFolder, genFolder)
}
test {
java.srcDirs(testFolder)
resources.srcDirs(testFolder)
}
}
gradle.projectsEvaluated {
tasks.all {
if (group != targetGroup) {
group = "other"
}
}
}
/*
* ================================
* Tasks
* ================================
*/
tasks.processResources {
includeEmptyDirs = false
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude("**/*.java")
exclude("neodym/antlr/*")
include("neodym/antlr/*.java")
include("neodym/antlr/*.tokens")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.generateGrammarSource {
group = targetGroup
maxHeapSize = "128m"
source = fileTree(mainFolder) {
include("**/*.g4")
}
arguments.addAll("-Werror", "-long-messages", "-package", "neodym.antlr")
doLast {
genFolder.deleteRecursively()
file("build/generated-src/antlr/main").delete()
fileTree("build/generated-src/antlr") {
include("**/*.interp")
}.forEach { it.delete() }
file("build/generated-src/antlr").renameTo(genFolder)
}
}
tasks.clean {
doLast {
genFolder.deleteRecursively()
}
}
tasks.compileJava {
dependsOn(tasks.generateGrammarSource)
}
/*
* ================================
* Extension methods
* ================================
*/
fun DependencyHandlerScope.preprocessor(dependency: String) {
annotationProcessor(dependency)
testAnnotationProcessor(dependency)
}
fun DependencyHandlerScope.compileTime(dependency: String) {
compileOnly(dependency)
testImplementation(dependency)
}
fun <T> MutableCollection<in T>.addAll(vararg elements: T) { addAll(elements) }