build: update version props for F-Droid

This commit is contained in:
Akash Yadav
2023-12-31 16:07:08 +05:30
parent 2f9ea23a08
commit 7c962905e4
4 changed files with 27 additions and 36 deletions
+3
View File
@@ -1,3 +1,6 @@
# Properties file for F-Droid
fdroid.properties
# Crowdin
crowdin.properties
.idea/crowdin_settings.xml
@@ -86,10 +86,9 @@ fun Project.configureAndroidModule(
if (!isFDroidBuild) {
productFlavors {
val fdroidSuffix = if (isFDroidBuild) "-fdroid" else ""
flavorsAbis.forEach { (abi, verCodeIncrement) ->
val flavor = create(abi)
flavor.versionNameSuffix = "-${abi}${fdroidSuffix}"
flavor.versionNameSuffix = "-${abi}"
flavor.versionCode = 100 * projectVersionCode + verCodeIncrement
}
}
-3
View File
@@ -23,6 +23,3 @@ android.jetifier.ignorelist=common-30.2.2.jar
# TODO : Migrate
android.nonTransitiveRClass=false
# DO NOT REMOVE!!
# @@FDROID_PREBUILD_PROPS_INSERT@@
+23 -31
View File
@@ -22,8 +22,8 @@ set -eu
# 1 - version name
# 2 - version code
versionName="$1"
versionCode="$2"
versionName="$1" # Format: $major.$minor.$patch-$type-$abi e.g. 2.7.0-beta-arm64
versionCode="$2" # Format: $major$minor$patch e.g. 270
# Android defaultConfig
DEFCONFIG_REPLACE_BEGIN="FDROID_PREBUILD_DEFCONFIG_REPLACE_BEGIN"
@@ -36,12 +36,9 @@ SETTINGS_GRADLE_REPLACE_END="FDROID_PREBUILD_SETTINGS_REPLACE_END"
# Android productFlavors
FLAVORS_INSERT="FDROID_PREBUILD_FLAVORS_INSERT"
# Insert Gradle properties
PROPS_INSERT="FDROID_PREBUILD_PROPS_INSERT"
# File to update
build_gradle="build.gradle.kts"
gradle_props="../gradle.properties"
gradle_props="../fdroid.properties"
settings_gradle="../settings.gradle.kts"
flavorDef="productFlavors {\n"
@@ -49,39 +46,35 @@ flavorDef="productFlavors {\n"
i=1
for arch in arm64-v8a armeabi-v7a x86_64; do
flavorDef+="create(\"$arch\") { \n"
flavorDef+=" versionNameSuffix = \"$arch\" \n"
flavorDef+=" versionNameSuffix = \"-fdroid\" \n"
flavorDef+=" versionCode = 100 * $versionCode + $i \n"
flavorDef+="}\n"
i=$(( i + 1))
i=$((i + 1))
done
flavorDef+="}"
# Gradle properties
propsDef="ide.build.fdroid=true\n"
propsDef+="ide.build.fdroid.version=${versionName}\n"
propsDef+="ide.build.fdroid.vercode=${versionCode}\n"
# settings.gradle
settingsDef=$(cat <<- END
val properties = File(rootDir, "gradle.properties").let { props ->
settingsDef=$(
cat <<-END
val propsFile = File(rootDir, "fdroid.properties")
if (!propsFile.exists() || !propsFile.isFile) {
throw GradleException("fdroid.properties file does not exist or is not a file")
}
val properties = propsFile.let { props ->
java.util.Properties().also {
it.load(props.reader())
}
}
val isFDroidBuild = properties.getProperty("ide.build.fdroid", "true").toBoolean()
val isFDroidBuild = properties.getProperty("ide.build.fdroid", "true").toBoolean()
val fdroidVersionName = requireNotNull(properties.getProperty("ide.build.fdroid.version", null)) {
"'ide.build.fdroid' is 'true' but no 'ide.build.fdroid.version' is defined!"
}
val fdroidVersionName = requireNotNull(properties.getProperty("ide.build.fdroid.version", null)) {
"'ide.build.fdroid' is 'true' but no 'ide.build.fdroid.version' is defined!"
}
gradle.beforeProject {
if (project.path == ":") {
gradle.rootProject.version = "v" + fdroidVersionName
}
}
gradle.rootProject { project.setProperty("version", fdroidVersionName) }
END
)
@@ -108,10 +101,9 @@ awk -v begin="$SETTINGS_GRADLE_REPLACE_BEGIN" -v end="$SETTINGS_GRADLE_REPLACE_E
next;
}
!printing
' $settings_gradle > temp_settings.gradle && mv temp_settings.gradle $settings_gradle
' $settings_gradle >temp_settings.gradle && mv temp_settings.gradle $settings_gradle
# Insert Gradle properties
sed -i "/# @@$PROPS_INSERT@@/c\
$propsDef" $gradle_props
# Write Gradle properties
echo "ide.build.fdroid=true" >"$gradle_props"
echo "ide.build.fdroid.version=${versionName}" >>"$gradle_props"
echo "ide.build.fdroid.vercode=${versionCode}" >>"$gradle_props"