Use the jflex plugin for gradle

Conflicts:
	brut.apktool.smali/smali/build.gradle
	brut.apktool.smali/smali/src/main/jflex/smaliLexer.flex
	build.gradle
	smali/src/main/jflex/smaliLexer.flex
	smali/src/main/jflex/smaliLexer.jflex
This commit is contained in:
Ben Gruver 2015-03-01 20:16:28 -08:00 committed by Connor Tumbleson
parent 0003d56389
commit 08dca73690
4 changed files with 19 additions and 22 deletions

View File

@ -82,6 +82,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'
]
}

View File

@ -28,32 +28,36 @@
* (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
jflex
}
buildscript {
repositories {
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,21 +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(' ')
}
compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource, generateJflexSource
compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource
compileTestJava.dependsOn generateTestAntlrSource
processResources.inputs.property('version', version)
@ -153,6 +143,11 @@ task fatJar (type: Jar) {
attributes("Main-Class": "org.jf.smali.main")
}
}
tasks.getByPath('build').dependsOn(fatJar)
generateJFlexSource {
outputDirectory = new File(outputDirectory, "org/jf/smali")
}
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) {
def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' +

View File

@ -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);