LSPosed/dalvikdx/build.gradle

57 lines
1.4 KiB
Groovy

import org.gradle.internal.os.OperatingSystem
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
sourceCompatibility = "7"
targetCompatibility = "7"
task findDx {
if (OperatingSystem.current().isWindows()){
return true
}
doLast {
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine "which", "dx"
standardOutput os
}
rootProject.ext.dxPath = os.toString()
}
}
}
task makeDex(type: Exec) {
dependsOn jar
dependsOn findDx
def dexName = "classes.dex"
workingDir jar.destinationDir
if (OperatingSystem.current().isWindows()) {
executable "dx.bat"
args "--dex", "--output", dexName, "${jar.archiveName}"
} else {
executable "bash"
args rootProject.ext.dxPath.trim(), "--dex", "--output", dexName, "${jar.archiveName}"
}
}
task dex(type: Copy) {
dependsOn makeDex
from (jar.destinationDir) {
include "classes.dex"
rename "classes.dex", "eddalvikdx.dex"
}
destinationDir new File(projectDir, "dex")
}
task dexInJar(type: Jar) {
dependsOn makeDex
from "${jar.destinationDir}/classes.dex"
destinationDir jar.destinationDir
baseName "eddalvikdx"
onlyIf {
!jar.state.upToDate || !file(archiveName).exists()
}
}