diff options
author | Ben Gruver <jesusfreke@jesusfreke.com> | 2015-03-01 20:16:28 -0800 |
---|---|---|
committer | Ben Gruver <jesusfreke@jesusfreke.com> | 2015-03-01 20:30:09 -0800 |
commit | 0f6f00a325cce70c1a396e3a97eb9be5aa1736f9 (patch) | |
tree | ca243974d7e830bd0887882c75955f90d9f68a61 | |
parent | 900ad6ea878635827ae97792ef2c9f760a81c121 (diff) | |
download | smali-0f6f00a325cce70c1a396e3a97eb9be5aa1736f9.tar.gz |
Use the jflex plugin for gradle
-rw-r--r-- | build.gradle | 1 | ||||
-rw-r--r-- | smali/build.gradle | 35 | ||||
-rw-r--r-- | smali/src/main/jflex/smaliLexer.jflex (renamed from smali/src/main/jflex/smaliLexer.flex) | 0 | ||||
-rw-r--r-- | smali/src/test/java/LexerTest.java | 3 |
4 files changed, 17 insertions, 22 deletions
diff --git a/build.gradle b/build.gradle index 7e03b5fc..109d13aa 100644 --- a/build.gradle +++ b/build.gradle @@ -90,6 +90,7 @@ subprojects { stringtemplate: 'org.antlr:stringtemplate:3.2.1', commons_cli: 'commons-cli:commons-cli:1.2', jflex: 'de.jflex:jflex:1.4.3', + jflex_plugin: 'co.tomlee.gradle.plugins:gradle-jflex-plugin:0.0.1', proguard_gradle: 'net.sf.proguard:proguard-gradle:5.1' ] } diff --git a/smali/build.gradle b/smali/build.gradle index 5f09e0ff..92fb1db4 100644 --- a/smali/build.gradle +++ b/smali/build.gradle @@ -29,9 +29,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +apply plugin: 'jflex' + configurations { antlr3 - jflex } buildscript { @@ -39,21 +40,24 @@ buildscript { mavenCentral() } dependencies { + classpath depends.jflex_plugin classpath depends.proguard_gradle } } +configurations { + // 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.jflexSource = "src/main/jflex" -ext.jflexOutput = file("${buildDir}/generated-sources/jflex") - ext.testAntlrSource = 'src/test/antlr3' ext.testAntlrOutput = file("${buildDir}/generated-test-sources/antlr3") sourceSets.main.java.srcDir antlrOutput -sourceSets.main.java.srcDir jflexOutput sourceSets.test.java.srcDir testAntlrOutput @@ -124,22 +128,7 @@ task generateTestAntlrSource(type: JavaExec) { args grammars.files.join(' ') } -task generateJflexSource(type: JavaExec) { - inputs.dir file(jflexSource) - outputs.dir file(jflexOutput) - - mkdir(jflexOutput) - def grammars = fileTree(jflexSource).include('**/*.flex') - - classpath = configurations.jflex - main = 'JFlex.Main' - args '-q' - args '-d', relativePath("${jflexOutput}/org/jf/smali") - args grammars.files.join(' ') - environment LC_ALL: "en_US" -} - -compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource, generateJflexSource +compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource compileTestJava.dependsOn generateTestAntlrSource processResources.inputs.property('version', version) @@ -167,6 +156,10 @@ task fatJar(type: Jar, dependsOn: jar) { } tasks.getByPath('build').dependsOn(fatJar) +generateJFlexSource { + outputDirectory = new File(outputDirectory, "org/jf/smali") +} + uploadArchives { repositories.mavenDeployer { pom.project { diff --git a/smali/src/main/jflex/smaliLexer.flex b/smali/src/main/jflex/smaliLexer.jflex index df571e66..df571e66 100644 --- a/smali/src/main/jflex/smaliLexer.flex +++ b/smali/src/main/jflex/smaliLexer.jflex diff --git a/smali/src/test/java/LexerTest.java b/smali/src/test/java/LexerTest.java index c1b70435..d156015a 100644 --- a/smali/src/test/java/LexerTest.java +++ b/smali/src/test/java/LexerTest.java @@ -40,6 +40,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.HashMap; import java.util.List; @@ -158,7 +159,7 @@ public class LexerTest { if (smaliStream == null) { Assert.fail("Could not load " + smaliFile); } - smaliFlexLexer lexer = new smaliFlexLexer(smaliStream); + smaliFlexLexer lexer = new smaliFlexLexer(new InputStreamReader(smaliStream)); lexer.setSourceFile(new File(test + ".smali")); lexer.setSuppressErrors(true); |