abouttreesummaryrefslogcommitdiff
path: root/build.gradle
diff options
context:
space:
mode:
authordeftkHD2023-11-25 20:11:12 +0100
committerGitHub2023-11-25 20:11:12 +0100
commit684d5c7b70536d7a36d80da659821a2e60d81841 (patch)
tree6074b30e89160377481a45d456407b9bcc1b9da9 /build.gradle
parent851d22da6e764cf10fc07aacead14f32fba33195 (diff)
downloadunexpected-keyboard-684d5c7b70536d7a36d80da659821a2e60d81841.tar.gz
unexpected-keyboard-684d5c7b70536d7a36d80da659821a2e60d81841.zip
Use Gradle (#452)
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle147
1 files changed, 147 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..57beb80
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,147 @@
+plugins {
+ id 'com.android.application' version '8.1.1'
+}
+
+android {
+ namespace 'juloo.keyboard2'
+ compileSdk 33
+
+ defaultConfig {
+ applicationId "juloo.keyboard2"
+ minSdk 4
+ targetSdkVersion 33
+ versionCode 36
+ versionName "1.24.0"
+ }
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['srcs']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+ }
+
+ signingConfigs {
+ // Debug builds will always be signed. If no environment variables are set, a default
+ // keystore will be initialized by the task initDebugKeystore and used. This keystore
+ // can be uploaded to GitHub secrets by following instructions in CONTRIBUTING.md
+ // in order to always receive correctly signed debug APKs from the CI.
+ debug {
+ storeFile(System.env.DEBUG_KEYSTORE ? file(System.env.DEBUG_KEYSTORE) : file("debug.keystore"))
+ storePassword(System.env.DEBUG_KEYSTORE_PASSWORD ? "$System.env.DEBUG_KEYSTORE_PASSWORD" : "debug0")
+ keyAlias(System.env.DEBUG_KEY_ALIAS ? "$System.env.DEBUG_KEY_ALIAS" : "debug")
+ keyPassword(System.env.DEBUG_KEY_PASSWORD ? "$System.env.DEBUG_KEY_PASSWORD" : "debug0")
+ }
+ // Release builds will only be signed with a dedicated key if specified. This key has to be
+ // created manually.
+ release {
+ if (System.env.RELEASE_KEYSTORE) {
+ storeFile file(System.env.RELEASE_KEYSTORE)
+ storePassword "$System.env.RELEASE_KEYSTORE_PASSWORD"
+ keyAlias "$System.env.RELEASE_KEY_ALIAS"
+ keyPassword "$System.env.RELEASE_KEY_PASSWORD"
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled true
+ shrinkResources true
+ debuggable false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
+ resValue "string", "app_name", "@string/app_name_release"
+ if (System.env.RELEASE_KEYSTORE) {
+ signingConfig signingConfigs.release
+ }
+ }
+ debug {
+ minifyEnabled false
+ shrinkResources false
+ debuggable true
+ applicationIdSuffix ".debug"
+ resValue "string", "app_name", "@string/app_name_debug"
+ resValue "bool", "debug_logs", "true"
+ signingConfig signingConfigs.debug
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+}
+
+dependencies {
+
+}
+
+tasks.register('buildKeyboardFont') {
+ println "\nBuilding assets/special_font.ttf"
+ mkdir "$buildDir"
+ exec {
+ workingDir "$projectDir/srcs/special_font"
+ def svgFiles = workingDir.listFiles().findAll {
+ it.isFile() && it.name.endsWith(".svg")
+ }
+ commandLine("fontforge", "-lang=ff", "-script", "build.pe", "$buildDir/special_font.ttf", *svgFiles)
+ }
+ copy {
+ from "$buildDir/special_font.ttf"
+ into "assets"
+ }
+}
+
+tasks.withType(Test).configureEach {
+ dependsOn 'genLayoutsList'
+ dependsOn 'checkKeyboardLayouts'
+ dependsOn 'syncTranslations'
+}
+
+tasks.register('genLayoutsList') {
+ println "\nGenerating res/values/layouts.xml"
+ exec {
+ workingDir = projectDir
+ commandLine "python", "gen_layouts.py"
+ }
+}
+
+tasks.register('checkKeyboardLayouts') {
+ println "\nChecking layouts"
+ new ByteArrayOutputStream().withStream { bos ->
+ exec {
+ def layouts = new File(projectDir, "res/xml").listFiles().findAll {
+ it.isFile() && it.name.endsWith(".xml")
+ }
+ workingDir = projectDir
+ commandLine("python", "check_layout.py", *layouts)
+ standardOutput = bos
+ }
+
+ new File(projectDir, "check_layout.output").write(bos.toString())
+ }
+}
+
+tasks.register('syncTranslations') {
+ println "\nUpdating translations"
+ exec {
+ workingDir = projectDir
+ commandLine "python", "sync_translations.py"
+ }
+}
+
+tasks.named("preBuild") {
+ dependsOn += "initDebugKeystore"
+}
+
+tasks.register('initDebugKeystore') {
+ if (!file("debug.keystore").exists()) {
+ println "Initializing default debug keystore"
+ exec {
+ // A shell script might be needed if this line requires input from the user
+ commandLine "keytool", "-genkeypair", "-dname", "cn=d, ou=e, o=b, c=ug", "-alias", "debug", "-keypass", "debug0", "-keystore", "debug.keystore", "-keyalg", "rsa", "-storepass", "debug0", "-validity", "10000"
+ }
+ }
+}