mirror of
https://github.com/revanced/smali.git
synced 2025-05-02 23:54:38 +02:00
Use the jflex plugin for gradle
This commit is contained in:
parent
900ad6ea87
commit
0f6f00a325
@ -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'
|
||||
]
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user