android: use gradle to build data archive

this fixes #1161 separates the android application build system from automake
and simplifies building an application on windows.
This commit is contained in:
Alexander Epaneshnikov
2022-04-15 19:07:16 +03:00
parent 95678616f7
commit 042ac06b9e
2 changed files with 45 additions and 14 deletions
+44
View File
@@ -7,7 +7,11 @@ buildscript {
classpath 'com.android.tools.build:gradle:7.1.2'
}
}
plugins {
id 'org.gradle.crypto.checksum' version '1.4.0'
}
import org.gradle.crypto.checksum.Checksum
apply plugin: 'com.android.application'
repositories {
@@ -15,11 +19,51 @@ repositories {
mavenCentral()
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'org.hamcrest:hamcrest-all:1.3'
}
tasks.register('checkData') {
doFirst {
assert file("../espeak-ng-data/en_dict").exists()
assert file("../espeak-ng-data/intonations").exists()
assert file("../espeak-ng-data/phondata").exists()
assert file("../espeak-ng-data/phondata-manifest").exists()
assert file("../espeak-ng-data/phonindex").exists()
assert file("../espeak-ng-data/phontab").exists()
}
}
tasks.register('createDataArchive', Zip) {
dependsOn tasks.checkData
preserveFileTimestamps = false
reproducibleFileOrder = true
archiveFileName = "espeakdata.zip"
destinationDirectory = file("res/raw")
from("../espeak-ng-data/") {
into "espeak-ng-data"
}
}
tasks.register('createDataHash', Checksum) {
dependsOn tasks.createDataArchive
checksumAlgorithm.set(Checksum.Algorithm.SHA256)
inputFiles.setFrom(file("./res/raw/espeakdata.zip"))
outputDirectory.set(layout.buildDirectory.dir('intermediates/datahash'))
}
tasks.register('createDataVersion', Copy) {
dependsOn tasks.createDataHash
from layout.buildDirectory.file('intermediates/datahash/espeakdata.zip.sha256')
rename { return 'espeakdata_version' }
into file("./res/raw")
}
preBuild.dependsOn createDataVersion
android {
compileSdkVersion 26