-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
51 lines (41 loc) · 1.17 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
apply plugin:"java"
apply plugin:'application'
repositories {
mavenCentral()
}
mainClassName = "mantra.Tool"
dependencies {
compile 'org.antlr:antlr4:4.2'
compile 'org.antlr:ST4:4.0.7'
}
task generateParser(type: AntlrTask) {
pkg = "mantra"
generatedJavaFiles = [file(destinationDir+"MantraParser.java"), file(destinationDir+"MantraLexer.java"),
file(destinationDir+"MantraBaseListener.java"), file(destinationDir+"MantraListener.java")]
grammarSource = file('src/grammar/mantra/Mantra.g4')
toolClasspath = configurations.compile
}
class AntlrTask extends DefaultTask {
def destinationDir = "src/gen/"
@OutputFiles
def generatedJavaFiles
@InputFile
def grammarSource
def toolClasspath
def antlrTool = 'org.antlr.v4.Tool'
def pkg
@TaskAction
def runAntlr() {
project.javaexec {
main = antlrTool
classpath = toolClasspath
workingDir = destinationDir
args = ["-o", pkg, "-package", pkg, "-listener", grammarSource]
}
}
}
compileJava {
dependsOn generateParser
source = [fileTree(generateParser.destinationDir).include('**/*.java'), fileTree('src/java').include('**/*.java')]
}
task wrapper(type:Wrapper)