mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
build: update build configuration for F-Droid publication
This commit is contained in:
+13
-5
@@ -15,23 +15,31 @@ apply {
|
|||||||
plugin(AndroidIDEAssetsPlugin::class.java)
|
plugin(AndroidIDEAssetsPlugin::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The comments starting with @@FDROID_PREBUILD_ are used to insert various configurations
|
||||||
|
// when building with F-Droid buildserver
|
||||||
|
// These comments must not be removed
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = BuildConfig.packageName
|
namespace = BuildConfig.packageName
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// The following comments are used to insert the applicationId, versionName and versionCode
|
// @@FDROID_PREBUILD_DEFCONFIG_REPLACE_BEGIN@@
|
||||||
// when building with F-Droid
|
|
||||||
// @@FDROID_PREBUILD_REPLACE_BEGIN@@
|
|
||||||
applicationId = BuildConfig.packageName
|
applicationId = BuildConfig.packageName
|
||||||
// @@FDROID_PREBUILD_REPLACE_END@@
|
// @@FDROID_PREBUILD_DEFCONFIG_REPLACE_END@@
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @@FDROID_PREBUILD_FLAVORS_INSERT@@
|
||||||
|
|
||||||
androidResources {
|
androidResources {
|
||||||
generateLocaleConfig = true
|
generateLocaleConfig = true
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes { release { isShrinkResources = true } }
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isShrinkResources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
packaging {
|
packaging {
|
||||||
resources.excludes.addAll(
|
resources.excludes.addAll(
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ object ProjectConfig {
|
|||||||
|
|
||||||
private var shouldPrintVersionName = true
|
private var shouldPrintVersionName = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this build is being executed in the F-Droid build server.
|
||||||
|
*/
|
||||||
|
val Project.isFDroidBuild: Boolean
|
||||||
|
get() = hasProperty(PROP_IDE_BUILD_FDROID) && property(PROP_IDE_BUILD_FDROID) == "true"
|
||||||
|
|
||||||
val Project.simpleVersionName: String
|
val Project.simpleVersionName: String
|
||||||
get() {
|
get() {
|
||||||
|
|
||||||
|
|||||||
+25
-11
@@ -19,6 +19,7 @@ package com.itsaky.androidide.plugins.conf
|
|||||||
|
|
||||||
import BuildConfig
|
import BuildConfig
|
||||||
import com.android.build.gradle.BaseExtension
|
import com.android.build.gradle.BaseExtension
|
||||||
|
import isFDroidBuild
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.Dependency
|
import org.gradle.api.artifacts.Dependency
|
||||||
import projectVersionCode
|
import projectVersionCode
|
||||||
@@ -26,12 +27,14 @@ import projectVersionCode
|
|||||||
/**
|
/**
|
||||||
* ABIs for which the product flavors will be created.
|
* ABIs for which the product flavors will be created.
|
||||||
* The keys in this map are the names of the product flavors whereas,
|
* The keys in this map are the names of the product flavors whereas,
|
||||||
* the value for each flavor is a number that will be appended to the base version code of the IDE
|
* the value for each flavor is a number that will be incremented to the base version code of the IDE
|
||||||
* and set as the version code of that flavor.
|
* and set as the version code of that flavor.
|
||||||
*
|
*
|
||||||
* For example, if the base version code of the IDE is 270 (for v2.7.0), then for arm64-v8a
|
* For example, if the base version code of the IDE is 270 (for v2.7.0), then for arm64-v8a
|
||||||
* flavor, the version code will be `"270" + "1"` i.e. `"2701".toInt()
|
* flavor, the version code will be `100 * 270 + 1` i.e. `2701`
|
||||||
*/
|
*/
|
||||||
|
// IMPORTANT: When changing the configuration here, make sure to update the following file:
|
||||||
|
// - <root>/scripts/setup_fdroid_build.sh
|
||||||
private val flavorsAbis = mapOf("arm64-v8a" to 1, "armeabi-v7a" to 2, "x86_64" to 3)
|
private val flavorsAbis = mapOf("arm64-v8a" to 1, "armeabi-v7a" to 2, "x86_64" to 3)
|
||||||
private val disableCoreLibDesugaringForModules = arrayOf(":logsender", ":logger")
|
private val disableCoreLibDesugaringForModules = arrayOf(":logsender", ":logger")
|
||||||
|
|
||||||
@@ -68,16 +71,27 @@ fun Project.configureAndroidModule(
|
|||||||
if (":app" == project.path) {
|
if (":app" == project.path) {
|
||||||
flavorDimensions("default")
|
flavorDimensions("default")
|
||||||
|
|
||||||
productFlavors {
|
flavorsAbis.forEach { (abi, _) ->
|
||||||
flavorsAbis.forEach { (abi, verCodeSuffix) ->
|
// the common defaultConfig, not the flavor-specific
|
||||||
val flavor = create(abi)
|
defaultConfig.buildConfigField("String",
|
||||||
flavor.versionNameSuffix = "-$abi"
|
"FLAVOR_${abi.replace('-', '_').uppercase()}",
|
||||||
flavor.versionCode = "${projectVersionCode}${verCodeSuffix}".toInt()
|
"\"${abi}\"")
|
||||||
|
}
|
||||||
|
|
||||||
// the common defaultConfig, not the flavor-specific
|
// Do not configure flavorDimensions here when building with F-Droid
|
||||||
defaultConfig.buildConfigField("String",
|
// flavor dimensions for F-Droid builds are configured in <root>/scripts/setup_fdroid_build.sh
|
||||||
"FLAVOR_${abi.replace('-', '_').uppercase()}",
|
//
|
||||||
"\"${abi}\"")
|
// IMPORTANT: When changing the configuration here, make sure to update the following file:
|
||||||
|
// - <root>/scripts/setup_fdroid_build.sh
|
||||||
|
if (!isFDroidBuild) {
|
||||||
|
|
||||||
|
productFlavors {
|
||||||
|
val fdroidSuffix = if (isFDroidBuild) "-fdroid" else ""
|
||||||
|
flavorsAbis.forEach { (abi, verCodeIncrement) ->
|
||||||
|
val flavor = create(abi)
|
||||||
|
flavor.versionNameSuffix = "-${abi}${fdroidSuffix}"
|
||||||
|
flavor.versionCode = 100 * projectVersionCode + verCodeIncrement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ object SigningKeyUtils {
|
|||||||
logger.info("Downloading signing key...")
|
logger.info("Downloading signing key...")
|
||||||
val result = exec {
|
val result = exec {
|
||||||
workingDir(rootProject.projectDir)
|
workingDir(rootProject.projectDir)
|
||||||
commandLine("bash", "./.tools/download_key.sh", signingKey.absolutePath, url, user, pass)
|
commandLine("bash", "./scripts/download_key.sh", signingKey.absolutePath, url, user, pass)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertNormalExitValue()
|
result.assertNormalExitValue()
|
||||||
|
|||||||
@@ -32,5 +32,7 @@ const val KEY_BIN = "IDE_SIGNING_KEY_BIN"
|
|||||||
*/
|
*/
|
||||||
const val AGP_VERSION_MINIMUM = "7.2.0"
|
const val AGP_VERSION_MINIMUM = "7.2.0"
|
||||||
|
|
||||||
|
const val PROP_IDE_BUILD_FDROID = "ide.build.fdroid"
|
||||||
|
|
||||||
val Project.signingKey: Provider<RegularFile>
|
val Project.signingKey: Provider<RegularFile>
|
||||||
get() = rootProject.layout.buildDirectory.file("signing/signing-key.jks")
|
get() = rootProject.layout.buildDirectory.file("signing/signing-key.jks")
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This file is part of AndroidIDE.
|
||||||
|
#
|
||||||
|
# AndroidIDE is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# AndroidIDE is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Arguments are positional
|
||||||
|
# 1 - version name
|
||||||
|
# 2 - version code
|
||||||
|
|
||||||
|
versionName="$1"
|
||||||
|
versionCode="$2"
|
||||||
|
|
||||||
|
# Android defaultConfig
|
||||||
|
DEFCONFIG_REPLACE_BEGIN="FDROID_PREBUILD_DEFCONFIG_REPLACE_BEGIN"
|
||||||
|
DEFCONFIG_REPLACE_END="FDROID_PREBUILD_DEFCONFIG_REPLACE_END"
|
||||||
|
|
||||||
|
# Android productFlavors
|
||||||
|
FLAVORS_INSERT="FDROID_PREBUILD_FLAVORS_INSERT"
|
||||||
|
|
||||||
|
# File to update
|
||||||
|
target_file="build.gradle.kts"
|
||||||
|
|
||||||
|
flavorDef="productFlavors {\n"
|
||||||
|
|
||||||
|
i=1
|
||||||
|
for arch in arm64-v8a armeabi-v7a x86_64; do
|
||||||
|
flavorDef+="create(\"$arch\") { \n"
|
||||||
|
flavorDef+=" versionNameSuffix = \"$arch-fdroid\" \n"
|
||||||
|
flavorDef+=" versionCode = 100 * $versionCode + $i \n"
|
||||||
|
flavorDef+="}\n"
|
||||||
|
i=$(( i + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
flavorDef+="}"
|
||||||
|
|
||||||
|
# Replace properties in defaultConfig with constants
|
||||||
|
sed -i "/\/\/ @@$DEFCONFIG_REPLACE_BEGIN@@/,/\/\/ @@$DEFCONFIG_REPLACE_END@@/c\
|
||||||
|
applicationId = \"com.itsaky.androidide\" \
|
||||||
|
versionName = \"$versionName\" \
|
||||||
|
versionCode = \"$versionCode\"" $target_file
|
||||||
|
|
||||||
|
# Add product flavors
|
||||||
|
sed -i "/\/\/ @@$FLAVORS_INSERT@@/c\
|
||||||
|
$flavorDef" $target_file
|
||||||
@@ -33,7 +33,6 @@ dependencyResolutionManagement {
|
|||||||
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
|
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
|
||||||
maven { url = uri("https://jitpack.io") }
|
maven { url = uri("https://jitpack.io") }
|
||||||
maven { url = uri("https://repo.gradle.org/gradle/libs-releases/") }
|
maven { url = uri("https://repo.gradle.org/gradle/libs-releases/") }
|
||||||
maven { url = uri("https://repo.eclipse.org/content/repositories/lemminx-snapshots/") }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user