build.gradle revision 480c79aeeaf53d196965481e9cabc2d270f0d497
1configurations { 2 antlr3 3 jflex 4} 5 6ext.antlrSource = 'src/main/antlr3' 7ext.antlrOutput = file(new File(buildDir, '/generated-sources/antlr3')) 8 9ext.jflexSource = "src/main/jflex" 10ext.jflexOutput = file(new File(buildDir, '/generated-sources/jflex')) 11 12ext.testAntlrSource = 'src/test/antlr3' 13ext.testAntlrOutput = file(new File(buildDir, '/generated-test-sources/antlr3')) 14 15sourceSets.main.java.srcDir antlrOutput 16sourceSets.main.java.srcDir jflexOutput 17 18sourceSets.test.java.srcDir testAntlrOutput 19 20dependencies { 21 compile project(':util') 22 compile project(':dexlib') 23 compile 'org.antlr:antlr-runtime:3.2' 24 compile 'commons-cli:commons-cli:1.2' 25 26 testCompile 'junit:junit:4.6' 27 28 antlr3 'org.antlr:antlr:3.2' 29 jflex 'de.jflex:jflex:1.4.3' 30} 31 32task generateAntlrSource { 33 inputs.dir file(antlrSource) 34 outputs.dir file(antlrOutput) 35 doLast { 36 mkdir(antlrOutput) 37 38 def grammars = fileTree(antlrSource).include('**/*.g') 39 40 ant.java(classname: 'org.antlr.Tool', classpath: configurations.antlr3.asPath, fork: true) { 41 arg(line: '-fo ' + antlrOutput + '/org/jf/smali') 42 arg(line: grammars.files.join(" ")) 43 } 44 } 45} 46 47task generateTestAntlrSource { 48 inputs.dir file(testAntlrSource) 49 outputs.dir file(testAntlrOutput) 50 doLast { 51 mkdir(testAntlrOutput) 52 53 def grammars = fileTree(testAntlrSource).include('**/*.g') 54 55 ant.java(classname: 'org.antlr.Tool', classpath: configurations.antlr3.asPath, fork: true) { 56 arg(line: '-fo ' + testAntlrOutput + '/org/jf/smali') 57 arg(line: grammars.files.join(" ")) 58 } 59 } 60} 61 62task generateJflexSource { 63 inputs.dir file(jflexSource) 64 outputs.dir file(jflexOutput) 65 doLast { 66 mkdir(jflexOutput) 67 68 def grammars = fileTree(jflexSource).include('**/*.flex') 69 70 ant.java(classname: 'JFlex.Main', classpath: configurations.jflex.asPath, fork: true) { 71 arg(line: '-d ' + jflexOutput + '/org/jf/smali') 72 arg(line: grammars.files.join(" ")) 73 } 74 } 75} 76 77compileJava.dependsOn generateAntlrSource, generateJflexSource 78compileTestJava.dependsOn generateTestAntlrSource 79