-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
71 lines (58 loc) · 1.5 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
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
ext.antlr = [
grammarpackage: "es.wobbl.toml.grammar",
antlrSource: 'src/main/antlr4',
destinationDir: "target/generated-sources/antlr4"
]
repositories {
mavenCentral()
}
configurations {
antlr4 {
description = "ANTLR4"
}
}
dependencies {
compile 'com.google.guava:guava:17.0'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.antlr:antlr4-runtime:4.2.2'
antlr4 'org.antlr:antlr4:4.2.2'
testCompile 'junit:junit:4.11' // A dependency for a test framework.
}
task antlrOutputDir << {
mkdir(antlr.destinationDir)
}
task generateGrammarSource(dependsOn: antlrOutputDir, type: JavaExec) {
description = 'Generates Java sources from ANTLR4 grammars.'
inputs.dir file(antlr.antlrSource)
outputs.dir file(antlr.destinationDir)
def grammars = fileTree(antlr.antlrSource).include('**/*.g4')
main = 'org.antlr.v4.Tool'
classpath = configurations.antlr4
def pkg = antlr.grammarpackage.replaceAll("\\.", "/")
args = ["-o", "${antlr.destinationDir}/${pkg}"/*, "-atn"*/, "-visitor", "-package", antlr.grammarpackage, grammars.files].flatten()
}
eclipse.classpath {
file {
withXml { xml ->
def node = xml.asNode()
node.appendNode("classpathentry", [kind: "src", path: antlr.destinationDir])
}
}
}
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
}
}
compileJava {
dependsOn generateGrammarSource
source antlr.destinationDir
}
clean {
delete antlr.destinationDir
}