From 13df122fc49cffc0c6eabeb49b66baf4ebef89f3 Mon Sep 17 00:00:00 2001 From: Moritz Weber Date: Thu, 29 Dec 2022 20:42:59 +0100 Subject: [PATCH] build for signing --- .gitignore | 4 +- src/android/app/build-fdroid.gradle | 84 +++++++++++++++++++++++++++++ src/android/app/build.gradle | 22 ++++++-- 3 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 src/android/app/build-fdroid.gradle diff --git a/.gitignore b/.gitignore index a4c19f0..cc4b277 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,6 @@ lib/generated_plugin_registrant.dart coverage/lcov.info -assets/screenshots/src \ No newline at end of file +assets/screenshots/src +signing/github.jks +src/android/key.properties diff --git a/src/android/app/build-fdroid.gradle b/src/android/app/build-fdroid.gradle new file mode 100644 index 0000000..c8a4d76 --- /dev/null +++ b/src/android/app/build-fdroid.gradle @@ -0,0 +1,84 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 32 + ndkVersion flutter.ndkVersion + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + lintOptions { + disable 'InvalidPackage' + checkReleaseBuilds false + } + + defaultConfig { + minSdkVersion 19 + targetSdkVersion 32 + multiDexEnabled true + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + flavorDimensions "app" + productFlavors { + prod { + applicationId = "rocks.mucke" + } + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} + +ext.abiCodes = ["x86_64": 1, "armeabi-v7a": 2, "arm64-v8a": 3] +import com.android.build.OutputFile +android.applicationVariants.all { variant -> + variant.outputs.each { output -> + def abiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) + if (abiVersionCode != null) { + output.versionCodeOverride = project.android.defaultConfig.versionCode * 10 + abiVersionCode + } + } +} diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle index 6d20e16..0ce5c33 100644 --- a/src/android/app/build.gradle +++ b/src/android/app/build.gradle @@ -6,6 +6,12 @@ if (localPropertiesFile.exists()) { } } +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") @@ -52,16 +58,26 @@ android { dev { applicationId = "rocks.mucke.dev" } + github { + applicationId = "rocks.mucke.github" + } prod { applicationId = "rocks.mucke" } } + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword keystoreProperties['storePassword'] + } + } + buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig signingConfigs.release } } }