Refactor build scripts

This commit is contained in:
saoq
2022-11-25 08:56:52 +03:00
parent 724fafc3fd
commit d87a59bcb0
2 changed files with 39 additions and 37 deletions
+39 -2
View File
@@ -1,6 +1,8 @@
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'com.android.application'
@@ -8,8 +10,7 @@ plugins {
}
versionFile {
File moduleDir = projectDir
file = new File(moduleDir.getAbsolutePath() + "/src/main/assets/version.properties")
file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile()
}
task exportDex {
@@ -94,3 +95,39 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
}
task cleanVersionFile {
projectDir.toPath().resolve("src/main/assets/version.properties").toFile().delete()
}
task buildVTL(type: Exec) {
dependsOn 'assembleRelease'
dependsOn 'exportDex'
workingDir(projectDir.toPath().resolve("../scripts").normalize().toString())
if (Os.isFamily("unix") || Os.isFamily("mac")) {
commandLine './build.sh'
} else {
throw RuntimeException("Not supported")
// FIXME not tested
commandLine 'cmd', '/C', 'start', 'build.bat'
}
}
task buildAndInstallVTL(type: Exec) {
dependsOn('buildVTL')
workingDir(projectDir.toPath().resolve("../smali").normalize().toString())
ignoreExitValue true
if (Os.isFamily("unix") || Os.isFamily("mac")) {
commandLine 'bash', '-c', 'adb install VTLite.apk'
} else {
throw RuntimeException("Not supported")
// FIXME not tested
commandLine 'adb', 'install', 'VTLite.apk'
}
}
exportDex.dependsOn('assembleRelease')
clean.dependsOn('cleanVersionFile')
versionFile.dependsOn('cleanVersionFile')
preBuild.dependsOn('versionFile')
-35
View File
@@ -5,31 +5,7 @@ NC='\033[0m'
BOLD='\033[1m'
UNDERLINE='\033[4m'
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
echo -e "${BOLD}${UNDERLINE}Сборка dex..${NC}\n"
cd ../
rm ../smali/assets/version.properties
rm ../lite/app/src/main/assets/version.properties
./gradlew versionFile
./gradlew assembleRelease
if [ $? -eq 0 ]; then
echo -e "${GREEN}Успех!${NC}\n"
else
echo -e "${RED}Провал.${NC}\n"
exit 1
fi
echo -e "${BOLD}${UNDERLINE}Экспорт dex..${NC}"
./gradlew exportDex
if [ $? -eq 0 ]; then
echo -e "${GREEN}Успех!${NC}\n"
else
echo -e "${RED}Провал.${NC}\n"
exit 1
fi
echo -e "${BOLD}${UNDERLINE}Перенос dex6 в папку с исходным кодом..${NC}"
mv app/classes6.dex smali/
@@ -80,14 +56,3 @@ echo -e "${BOLD}VTosters Lite успешно собран! APK находитс
cd ../smali
rm classes6.dex
rm classes7.dex
echo -n "Желаете установить VTosters через adb? (y/n) "
read -n 1 prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
then
echo -e "\n"
adb install VTLite.apk
else
exit 0
fi