Use the antlr plugin for gradle

Conflicts:
	brut.apktool.smali/smali/build.gradle
	brut.apktool.smali/smali/src/main/antlr3/smaliParser.g
	brut.apktool.smali/smali/src/main/antlr3/smaliTreeWalker.g
	brut.apktool.smali/smali/src/test/antlr3/org/jf/smali/expectedTokensTestGrammar.g
	smali/src/main/antlr/smaliParser.g
	smali/src/main/antlr/smaliTreeWalker.g
	smali/src/main/antlr3/smaliParser.g
	smali/src/main/antlr3/smaliTreeWalker.g
	smali/src/test/antlr/org/jf/smali/expectedTokensTestGrammar.g
	smali/src/test/antlr3/org/jf/smali/expectedTokensTestGrammar.g
This commit is contained in:
Ben Gruver 2015-03-01 20:31:10 -08:00 committed by Connor Tumbleson
parent 08dca73690
commit 13b4c65ca1
4 changed files with 15 additions and 57 deletions

View File

@ -28,11 +28,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
apply plugin: 'jflex'
configurations {
antlr3
}
apply plugin: 'antlr'
apply plugin: 'jflex'
buildscript {
repositories {
@ -46,21 +44,15 @@ buildscript {
}
configurations {
// Remove the full antlr library that's added by the antlr plugin. We manually
// add the smaller antlr_runtime library instead
compile.exclude group: 'org.antlr', module: 'antlr'
// The jflex lexer doesn't have any runtime dependencies, so remove the dependency
// that gets added by the jflex plugin
compile.exclude group: 'de.jflex', module: 'jflex'
}
ext.antlrSource = 'src/main/antlr3'
ext.antlrOutput = file("${buildDir}/generated-sources/antlr3")
ext.testAntlrSource = 'src/test/antlr3'
ext.testAntlrOutput = file("${buildDir}/generated-test-sources/antlr3")
sourceSets.main.java.srcDir antlrOutput
sourceSets.test.java.srcDir testAntlrOutput
idea {
module {
excludeDirs -= buildDir
@ -85,52 +77,10 @@ dependencies {
testCompile depends.junit
antlr3 depends.antlr
antlr depends.antlr
jflex depends.jflex
}
task generateParserAntlrSource(type: JavaExec) {
inputs.dir file(antlrSource)
outputs.dir file(antlrOutput)
mkdir(antlrOutput)
def grammars = fileTree(antlrSource).include('**/smaliParser.g')
classpath = configurations.antlr3
main = 'org.antlr.Tool'
args '-fo', relativePath("${antlrOutput}/org/jf/smali")
args grammars.files
}
task generateTreeWalkerAntlrSource(type: JavaExec) {
inputs.dir file(antlrSource)
outputs.dir file(antlrOutput)
mkdir(antlrOutput)
def grammars = fileTree(antlrSource).include('**/smaliTreeWalker.g')
classpath = configurations.antlr3
main = 'org.antlr.Tool'
args '-fo', relativePath("${antlrOutput}/org/jf/smali")
args grammars.files
}
task generateTestAntlrSource(type: JavaExec) {
inputs.dir file(testAntlrSource)
outputs.dir file(testAntlrOutput)
mkdir(testAntlrOutput)
def grammars = fileTree(testAntlrSource).include('**/*.g')
classpath = configurations.antlr3
main = 'org.antlr.Tool'
args '-fo', relativePath("${testAntlrOutput}/org/jf/smali")
args grammars.files.join(' ')
}
compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource
compileTestJava.dependsOn generateTestAntlrSource
processResources.inputs.property('version', version)
processResources.expand('version': version)
@ -145,6 +95,14 @@ task fatJar (type: Jar) {
}
tasks.getByPath('build').dependsOn(fatJar)
generateTestGrammarSource {
outputDirectory = new File(outputDirectory, "org/jf/smali")
}
generateGrammarSource {
outputDirectory = new File(outputDirectory, "org/jf/smali")
}
generateJFlexSource {
outputDirectory = new File(outputDirectory, "org/jf/smali")
}