-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
45 lines (39 loc) · 1.24 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
apply plugin: 'java'
repositories {
mavenCentral()
}
configurations {
antlr4
}
dependencies {
antlr4 'org.antlr:antlr4:4.0'
compile 'org.antlr:antlr4-runtime:4.0'
}
task generateGrammarSources(type: JavaExec) {
ext.grammarFiles = fileTree('src/main/antlr4').include('**/*.g4')
ext.outputPath = "${project.buildDir}/generated-src/antlr4/main"
inputs.files grammarFiles
outputs.dir outputPath
classpath configurations.antlr4
main = 'org.antlr.v4.Tool'
args('-o')
args("${project.buildDir}/generated-src/antlr4/main")
args('-visitor')
args(grammarFiles.files.join(' '))
}
task grun(type: JavaExec, dependsOn: compileJava) {
classpath configurations.antlr4
classpath sourceSets.main.output
main = 'org.antlr.v4.runtime.misc.TestRig'
args(project.grunGrammar)
args(project.grunRule)
if (project.hasProperty('grunArgs')) {
args(project.grunArgs)
}
args(project.grunFile)
doFirst {
project.logger.info("Running grun with grammar ${project.grunGrammar} and rule ${project.grunRule} with args ${project.hasProperty('grunArgs') ? project.grunArgs : ""} on input file ${project.grunFile}")
}
}
sourceSets.main.java.srcDir generateGrammarSources.outputPath
compileJava.dependsOn generateGrammarSources