mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-02 15:17:56 +01:00
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:
parent
0003d56389
commit
08dca73690
@ -82,6 +82,7 @@ subprojects {
|
|||||||
stringtemplate: 'org.antlr:stringtemplate:3.2.1',
|
stringtemplate: 'org.antlr:stringtemplate:3.2.1',
|
||||||
commons_cli: 'commons-cli:commons-cli:1.2',
|
commons_cli: 'commons-cli:commons-cli:1.2',
|
||||||
jflex: 'de.jflex:jflex:1.4.3',
|
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'
|
proguard_gradle: 'net.sf.proguard:proguard-gradle:5.1'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -28,32 +28,36 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
apply plugin: 'jflex'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
antlr3
|
antlr3
|
||||||
jflex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
classpath depends.jflex_plugin
|
||||||
classpath depends.proguard_gradle
|
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.antlrSource = 'src/main/antlr3'
|
||||||
ext.antlrOutput = file("${buildDir}/generated-sources/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.testAntlrSource = 'src/test/antlr3'
|
||||||
ext.testAntlrOutput = file("${buildDir}/generated-test-sources/antlr3")
|
ext.testAntlrOutput = file("${buildDir}/generated-test-sources/antlr3")
|
||||||
|
|
||||||
sourceSets.main.java.srcDir antlrOutput
|
sourceSets.main.java.srcDir antlrOutput
|
||||||
sourceSets.main.java.srcDir jflexOutput
|
|
||||||
|
|
||||||
sourceSets.test.java.srcDir testAntlrOutput
|
sourceSets.test.java.srcDir testAntlrOutput
|
||||||
|
|
||||||
@ -124,21 +128,7 @@ task generateTestAntlrSource(type: JavaExec) {
|
|||||||
args grammars.files.join(' ')
|
args grammars.files.join(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
task generateJflexSource(type: JavaExec) {
|
compileJava.dependsOn generateParserAntlrSource, generateTreeWalkerAntlrSource
|
||||||
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
|
|
||||||
compileTestJava.dependsOn generateTestAntlrSource
|
compileTestJava.dependsOn generateTestAntlrSource
|
||||||
|
|
||||||
processResources.inputs.property('version', version)
|
processResources.inputs.property('version', version)
|
||||||
@ -153,6 +143,11 @@ task fatJar (type: Jar) {
|
|||||||
attributes("Main-Class": "org.jf.smali.main")
|
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) {
|
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: fatJar) {
|
||||||
def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' +
|
def outFile = fatJar.destinationDir.getPath() + '/' + fatJar.baseName + '-' +
|
||||||
|
@ -40,6 +40,7 @@ import org.junit.Test;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ public class LexerTest {
|
|||||||
if (smaliStream == null) {
|
if (smaliStream == null) {
|
||||||
Assert.fail("Could not load " + smaliFile);
|
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.setSourceFile(new File(test + ".smali"));
|
||||||
lexer.setSuppressErrors(true);
|
lexer.setSuppressErrors(true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user