-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathantlr.gradle
55 lines (48 loc) · 1.84 KB
/
antlr.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
/// ===== ANTLR 4 ===== ///
// BEGIN Fix for Gradle bug #2565
// "cannot find tokens"-bug with packaged grammar
// Found via. https://github.com/gradle/gradle/issues/2565#issuecomment-417916273
// From: https://github.com/apache/groovy/blob/master/subprojects/parser-antlr4/build.gradle#L34
final PARSER_PACKAGE_NAME = 'de.mlessmann.confort.antlr'
generateGrammarSource {
outputDirectory = new File('build/generated-src/antlr/main')
outputs.cacheIf { true }
arguments += ["-visitor", "-no-listener", "-package", PARSER_PACKAGE_NAME]
doLast {
def parserFilePattern = 'DeltaDescriptor*'
def outputPath = generateGrammarSource.outputDirectory.canonicalPath
def parserPackagePath = "${outputPath}/${PARSER_PACKAGE_NAME.replace('.', '/')}"
file(parserPackagePath).mkdirs()
copy {
from outputPath
into parserPackagePath
include parserFilePattern
}
delete fileTree(outputPath) {
include parserFilePattern
}
}
}
// Duplication for lang srcSet
final PARSER_PACKAGE_NAME_LNG = 'de.mlessmann.confort.antlr'
generateLangGrammarSource {
outputDirectory = new File('build/generated-src/antlr/lang')
outputs.cacheIf { true }
arguments += ["-visitor", "-no-listener", "-package", PARSER_PACKAGE_NAME_LNG]
doLast {
def parserFilePattern = '*'
def outputPath = generateLangGrammarSource.outputDirectory.canonicalPath
def parserPackagePath = "${outputPath}/${PARSER_PACKAGE_NAME_LNG.replace('.', '/')}"
file(parserPackagePath).mkdirs()
copy {
from outputPath
into parserPackagePath
include parserFilePattern
}
delete fileTree(outputPath) {
include parserFilePattern
}
}
}
// END Fix #2565
/// ===== Generic gradle settings ===== ///