-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
73 lines (61 loc) · 1.8 KB
/
build.gradle
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
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.4.21'
// add ktlintcheck task
id 'org.jlleitschuh.gradle.ktlint' version '8.2.0'
// antlr plugin
id 'antlr'
id 'idea'
}
group 'org.example'
version '1.0-SNAPSHOT'
// antlr customization
// where antlr will create generated files
def generatedMain = "generated-src/antlr/main"
def generatedMainFile = file(generatedMain)
// this is necessary to allow antlr plugin finding the grammar file
sourceSets {
main {
antlr {
srcDirs = ["src/third_parties"]
}
}
}
compileKotlin {
// antlr - kotlin compilation must search for source even in generatedMainFile
source generatedMainFile, sourceSets.main.java, sourceSets.main.kotlin
dependsOn generateGrammarSource
}
// i tell intellij to add to sourcedirs even generatedMainFile
// this is needed to make working properly the autocompletion
idea {
module {
println 'Adding ' + generatedMainFile + ' to source dirs'
mkdir generatedMain
sourceDirs += generatedMainFile
println sourceDirs
}
}
// on clean i have to delete generated files
clean {
delete file(generatedMain)
mkdir generatedMain
}
generateGrammarSource {
arguments += ['-package', 'com.smeup.test.antlrtutorial.parser']
outputDirectory = file(generatedMain + "/com/smeup/test/antlrtutorial/parser")
}
////////////////////////////////////////////////////////////////////////////////////
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
// set antlr version to use
antlr "org.antlr:antlr4:$antlrVersion"
}
test {
useJUnitPlatform()
}