Fix compile error on *nix systems

This commit is contained in:
kotori0 2020-06-13 21:26:58 +08:00 committed by Jim Wu
parent 30f8b6390d
commit a9dee2a529
2 changed files with 27 additions and 8 deletions

View File

@ -8,17 +8,34 @@ dependencies {
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 dexInJar(type: Jar) {
dependsOn jar
dependsOn findDx
doFirst {
exec {
workingDir jar.destinationDir
if (OperatingSystem.current().isWindows())
if (OperatingSystem.current().isWindows()){
executable "dx.bat"
else
executable "dx"
args "--dex", "--output", "classes.dex", "${jar.archiveName}"
args "--dex", "--output", "classes.dex", "${jar.archiveName}"
} else {
executable "bash"
args rootProject.ext.dxPath.trim(), "--dex", "--output", "classes.dex", "${jar.archiveName}"
}
}
}
from "${jar.destinationDir}/classes.dex"

View File

@ -19,11 +19,13 @@ task dexInJar(type: Jar) {
doFirst {
exec {
workingDir jar.destinationDir
if (OperatingSystem.current().isWindows())
if (OperatingSystem.current().isWindows()){
executable "dx.bat"
else
executable "dx"
args "--dex", "--output", "classes.dex", "${jar.archiveName}"
args "--dex", "--output", "classes.dex", "${jar.archiveName}"
} else {
executable "bash"
args rootProject.ext.dxPath.trim(), "--dex", "--output", "classes.dex", "${jar.archiveName}"
}
}
}
from "${jar.destinationDir}/classes.dex"