Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 7c96290

Browse files
committed
build: update version props for F-Droid
1 parent 2f9ea23 commit 7c96290

File tree

4 files changed

+27
-36
lines changed

4 files changed

+27
-36
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Properties file for F-Droid
2+
fdroid.properties
3+
14
# Crowdin
25
crowdin.properties
36
.idea/crowdin_settings.xml

build-logic/ide/src/main/java/com/itsaky/androidide/plugins/conf/AndroidModuleConf.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@ fun Project.configureAndroidModule(
8686
if (!isFDroidBuild) {
8787

8888
productFlavors {
89-
val fdroidSuffix = if (isFDroidBuild) "-fdroid" else ""
9089
flavorsAbis.forEach { (abi, verCodeIncrement) ->
9190
val flavor = create(abi)
92-
flavor.versionNameSuffix = "-${abi}${fdroidSuffix}"
91+
flavor.versionNameSuffix = "-${abi}"
9392
flavor.versionCode = 100 * projectVersionCode + verCodeIncrement
9493
}
9594
}

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,3 @@ android.jetifier.ignorelist=common-30.2.2.jar
2323

2424
# TODO : Migrate
2525
android.nonTransitiveRClass=false
26-
27-
# DO NOT REMOVE!!
28-
# @@FDROID_PREBUILD_PROPS_INSERT@@

scripts/setup_fdroid_build.sh

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ set -eu
2222
# 1 - version name
2323
# 2 - version code
2424

25-
versionName="$1"
26-
versionCode="$2"
25+
versionName="$1" # Format: $major.$minor.$patch-$type-$abi e.g. 2.7.0-beta-arm64
26+
versionCode="$2" # Format: $major$minor$patch e.g. 270
2727

2828
# Android defaultConfig
2929
DEFCONFIG_REPLACE_BEGIN="FDROID_PREBUILD_DEFCONFIG_REPLACE_BEGIN"
@@ -36,52 +36,45 @@ SETTINGS_GRADLE_REPLACE_END="FDROID_PREBUILD_SETTINGS_REPLACE_END"
3636
# Android productFlavors
3737
FLAVORS_INSERT="FDROID_PREBUILD_FLAVORS_INSERT"
3838

39-
# Insert Gradle properties
40-
PROPS_INSERT="FDROID_PREBUILD_PROPS_INSERT"
41-
4239
# File to update
4340
build_gradle="build.gradle.kts"
44-
gradle_props="../gradle.properties"
41+
gradle_props="../fdroid.properties"
4542
settings_gradle="../settings.gradle.kts"
4643

4744
flavorDef="productFlavors {\n"
4845

4946
i=1
5047
for arch in arm64-v8a armeabi-v7a x86_64; do
5148
flavorDef+="create(\"$arch\") { \n"
52-
flavorDef+=" versionNameSuffix = \"$arch\" \n"
49+
flavorDef+=" versionNameSuffix = \"-fdroid\" \n"
5350
flavorDef+=" versionCode = 100 * $versionCode + $i \n"
5451
flavorDef+="}\n"
55-
i=$(( i + 1))
52+
i=$((i + 1))
5653
done
5754

5855
flavorDef+="}"
5956

60-
# Gradle properties
61-
propsDef="ide.build.fdroid=true\n"
62-
propsDef+="ide.build.fdroid.version=${versionName}\n"
63-
propsDef+="ide.build.fdroid.vercode=${versionCode}\n"
64-
65-
6657
# settings.gradle
67-
settingsDef=$(cat <<- END
68-
val properties = File(rootDir, "gradle.properties").let { props ->
58+
settingsDef=$(
59+
cat <<-END
60+
val propsFile = File(rootDir, "fdroid.properties")
61+
if (!propsFile.exists() || !propsFile.isFile) {
62+
throw GradleException("fdroid.properties file does not exist or is not a file")
63+
}
64+
65+
val properties = propsFile.let { props ->
6966
java.util.Properties().also {
7067
it.load(props.reader())
7168
}
7269
}
7370
74-
val isFDroidBuild = properties.getProperty("ide.build.fdroid", "true").toBoolean()
71+
val isFDroidBuild = properties.getProperty("ide.build.fdroid", "true").toBoolean()
7572
76-
val fdroidVersionName = requireNotNull(properties.getProperty("ide.build.fdroid.version", null)) {
77-
"'ide.build.fdroid' is 'true' but no 'ide.build.fdroid.version' is defined!"
78-
}
73+
val fdroidVersionName = requireNotNull(properties.getProperty("ide.build.fdroid.version", null)) {
74+
"'ide.build.fdroid' is 'true' but no 'ide.build.fdroid.version' is defined!"
75+
}
7976
80-
gradle.beforeProject {
81-
if (project.path == ":") {
82-
gradle.rootProject.version = "v" + fdroidVersionName
83-
}
84-
}
77+
gradle.rootProject { project.setProperty("version", fdroidVersionName) }
8578
END
8679
8780
)
@@ -108,10 +101,9 @@ awk -v begin="$SETTINGS_GRADLE_REPLACE_BEGIN" -v end="$SETTINGS_GRADLE_REPLACE_E
108101
next;
109102
}
110103
!printing
111-
' $settings_gradle > temp_settings.gradle && mv temp_settings.gradle $settings_gradle
112-
113-
104+
' $settings_gradle >temp_settings.gradle && mv temp_settings.gradle $settings_gradle
114105

115-
# Insert Gradle properties
116-
sed -i "/# @@$PROPS_INSERT@@/c\
117-
$propsDef" $gradle_props
106+
# Write Gradle properties
107+
echo "ide.build.fdroid=true" >"$gradle_props"
108+
echo "ide.build.fdroid.version=${versionName}" >>"$gradle_props"
109+
echo "ide.build.fdroid.vercode=${versionCode}" >>"$gradle_props"

0 commit comments

Comments
 (0)