|
| 1 | +project.ext { |
| 2 | + testAppDir = 'test-app' |
| 3 | + testAppTmpDir = 'test-app-tmp' |
| 4 | + |
| 5 | + buildFile = "${testAppTmpDir}/build.gradle" |
| 6 | + apkFile = "${testAppTmpDir}/build/outputs/apk/test-app-tmp-debug.apk" |
| 7 | + outSrcDir = "${testAppTmpDir}/src/main/java" |
| 8 | + outResDir = "${testAppTmpDir}/src/main" |
| 9 | + checkTask = 'connectedCheck' |
| 10 | +} |
| 11 | + |
| 12 | +dependencies { |
| 13 | + compile(project(":jadx-cli")) |
| 14 | +} |
| 15 | + |
| 16 | +sonarRunner { |
| 17 | + skipProject = true |
| 18 | +} |
| 19 | + |
| 20 | +task deleteTmp(type:Delete) { |
| 21 | + delete testAppTmpDir |
| 22 | +} |
| 23 | + |
| 24 | +task copyApp(type:Copy, dependsOn: deleteTmp) { |
| 25 | + from testAppDir |
| 26 | + into testAppTmpDir |
| 27 | +} |
| 28 | + |
| 29 | +task buildApp(type:Exec, dependsOn: copyApp) { |
| 30 | + workingDir testAppTmpDir |
| 31 | + commandLine "./gradlew clean build ${checkTask}".split(' ') |
| 32 | +} |
| 33 | + |
| 34 | +task removeSource(type:Delete, dependsOn: buildApp) { |
| 35 | + delete "${outResDir}/**" |
| 36 | +} |
| 37 | + |
| 38 | +task runJadxSrc(type: JavaExec, dependsOn: removeSource) { |
| 39 | + classpath = sourceSets.main.output + configurations.compile |
| 40 | + main = project(':jadx-cli').mainClassName |
| 41 | + args = ['-d', outSrcDir, '-r', apkFile, '-v'] |
| 42 | +} |
| 43 | + |
| 44 | +task runJadxResources(type: JavaExec, dependsOn: runJadxSrc) { |
| 45 | + classpath = sourceSets.main.output + configurations.compile |
| 46 | + main = project(':jadx-cli').mainClassName |
| 47 | + args = ['-d', outResDir, '-s', apkFile, '-v'] |
| 48 | +} |
| 49 | + |
| 50 | +task decompile(type:Delete, dependsOn: runJadxResources) { |
| 51 | + delete "${outSrcDir}/com/github/skylot/jadx/testapp/BuildConfig.java" |
| 52 | + delete "${outSrcDir}/com/github/skylot/jadx/testapp/R.java" |
| 53 | +} |
| 54 | + |
| 55 | +task runChecks(type:Exec, dependsOn: decompile) { |
| 56 | + workingDir testAppTmpDir |
| 57 | + commandLine "./gradlew clean build ${checkTask}".split(' ') |
| 58 | +} |
| 59 | + |
| 60 | +task testAppCheck(dependsOn: runChecks) { |
| 61 | + doFirst { |
| 62 | + def buildFile = file(buildFile) |
| 63 | + if (!buildFile.exists() || !buildFile.isFile()) { |
| 64 | + throw new StopExecutionException("Test app not found") |
| 65 | + } |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +clean.dependsOn deleteTmp |
0 commit comments