@@ -13,21 +13,33 @@ dependencies {
1313 antlr4 ' org.antlr:antlr4:4.1'
1414}
1515
16+ ext. antlr4GeneratedSourceDir = new File (buildDir, ' generated-sources/antlr4' )
17+ 1618sourceSets {
1719 main {
1820 java {
19- srcDir new File (buildDir, ' generated-sources/antlr4 ' )
21+ srcDir antlr4GeneratedSourceDir
2022 }
2123 }
2224}
2325
24- task generateGrammarSource << {
25- javaexec {
26- classpath configurations. antlr4
27- main ' org.antlr.v4.Tool'
28- args ' -o' , new File (buildDir, ' generated-sources/antlr4/com/lemoulinstudio/sdiff/parser/java' ),
29- ' -package' , ' com.lemoulinstudio.sdiff.parser.java' ,
30- new File (projectDir, ' src/main/antlr4/Java.g4' )
26+ task generateGrammarSource {
27+ ext. grammarFile = new File (projectDir, ' src/main/antlr4/Java.g4' )
28+ ext. outputPackage = ' com.lemoulinstudio.sdiff.java.tree.lex'
29+ ext. outputDir = new File (antlr4GeneratedSourceDir, outputPackage. replace(' .' as char , File . pathSeparatorChar))
30+ 31+ inputs. file grammarFile
32+ inputs. property ' outputPackage' , outputPackage
33+ outputs. dir outputDir
34+ 35+ doLast {
36+ javaexec {
37+ classpath configurations. antlr4
38+ main ' org.antlr.v4.Tool'
39+ args ' -o' , outputDir,
40+ ' -package' , outputPackage,
41+ grammarFile
42+ }
3143 }
3244}
3345
0 commit comments