mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
build: update F-Droid config
This commit is contained in:
@@ -77,3 +77,9 @@ services:
|
|||||||
REPOSITORY_OWNER: "AndroidIDEOfficial"
|
REPOSITORY_OWNER: "AndroidIDEOfficial"
|
||||||
REPOSITORY_NAME: "AndroidIDE"
|
REPOSITORY_NAME: "AndroidIDE"
|
||||||
AUTHENTICATION_TOKEN: "{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}"
|
AUTHENTICATION_TOKEN: "{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}"
|
||||||
|
|
||||||
|
git:
|
||||||
|
remotes:
|
||||||
|
origin:
|
||||||
|
user: '{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}'
|
||||||
|
password: ''
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import org.gradle.api.Project
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Akash Yadav
|
||||||
|
*/
|
||||||
|
object FDroidConfig {
|
||||||
|
|
||||||
|
var hasRead: Boolean = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
var isFDroidBuild: Boolean = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
var fDroidVersionName: String? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
var fDroidVersionCode: Int? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
const val PROP_FDROID_BUILD = "ide.build.fdroid"
|
||||||
|
const val PROP_FDROID_BUILD_VERSION = "ide.build.fdroid.version"
|
||||||
|
const val PROP_FDROID_BUILD_VERCODE = "ide.build.fdroid.vercode"
|
||||||
|
|
||||||
|
fun load(project: Project) {
|
||||||
|
val propsFile = File(project.rootDir, "fdroid.properties")
|
||||||
|
if (!propsFile.exists() || !propsFile.isFile) {
|
||||||
|
hasRead = true
|
||||||
|
isFDroidBuild = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val properties = propsFile.let { props ->
|
||||||
|
java.util.Properties().also {
|
||||||
|
it.load(props.reader())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasRead = true
|
||||||
|
isFDroidBuild = properties.getProperty(PROP_FDROID_BUILD, null).toBoolean()
|
||||||
|
|
||||||
|
fDroidVersionName = properties.getProperty(PROP_FDROID_BUILD_VERSION, null)
|
||||||
|
fDroidVersionCode = properties.getProperty(PROP_FDROID_BUILD_VERCODE, null)?.toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,7 +38,12 @@ private var shouldPrintVersionName = true
|
|||||||
* Whether this build is being executed in the F-Droid build server.
|
* Whether this build is being executed in the F-Droid build server.
|
||||||
*/
|
*/
|
||||||
val Project.isFDroidBuild: Boolean
|
val Project.isFDroidBuild: Boolean
|
||||||
get() = hasProperty(PROP_IDE_BUILD_FDROID) && property(PROP_IDE_BUILD_FDROID) == "true"
|
get() {
|
||||||
|
if (!FDroidConfig.hasRead) {
|
||||||
|
FDroidConfig.load(this)
|
||||||
|
}
|
||||||
|
return FDroidConfig.isFDroidBuild
|
||||||
|
}
|
||||||
|
|
||||||
val Project.simpleVersionName: String
|
val Project.simpleVersionName: String
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
+2
-9
@@ -78,21 +78,14 @@ fun Project.configureAndroidModule(
|
|||||||
"\"${abi}\"")
|
"\"${abi}\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not configure flavorDimensions here when building with F-Droid
|
|
||||||
// flavor dimensions for F-Droid builds are configured in <root>/scripts/setup_fdroid_build.sh
|
|
||||||
//
|
|
||||||
// IMPORTANT: When changing the configuration here, make sure to update the following file:
|
|
||||||
// - <root>/scripts/setup_fdroid_build.sh
|
|
||||||
if (!isFDroidBuild) {
|
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
|
val fdroidSuffix = if (isFDroidBuild) "-fdroid" else ""
|
||||||
flavorsAbis.forEach { (abi, verCodeIncrement) ->
|
flavorsAbis.forEach { (abi, verCodeIncrement) ->
|
||||||
val flavor = create(abi)
|
val flavor = create(abi)
|
||||||
flavor.versionNameSuffix = "-${abi}"
|
flavor.versionNameSuffix = "-${abi}${fdroidSuffix}"
|
||||||
flavor.versionCode = 100 * projectVersionCode + verCodeIncrement
|
flavor.versionCode = 100 * projectVersionCode + verCodeIncrement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
ndk {
|
ndk {
|
||||||
|
|||||||
+7
-4
@@ -18,12 +18,11 @@
|
|||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import com.itsaky.androidide.plugins.AndroidIDEPlugin
|
import com.itsaky.androidide.plugins.AndroidIDEPlugin
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
import com.itsaky.androidide.plugins.conf.configureAndroidModule
|
import com.itsaky.androidide.plugins.conf.configureAndroidModule
|
||||||
import com.itsaky.androidide.plugins.conf.configureJavaModule
|
import com.itsaky.androidide.plugins.conf.configureJavaModule
|
||||||
import com.itsaky.androidide.plugins.conf.configureMavenPublish
|
import com.itsaky.androidide.plugins.conf.configureMavenPublish
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
@Suppress("DSL_SCOPE_VIOLATION")
|
|
||||||
plugins {
|
plugins {
|
||||||
id("build-logic.root-project")
|
id("build-logic.root-project")
|
||||||
alias(libs.plugins.android.application) apply false
|
alias(libs.plugins.android.application) apply false
|
||||||
@@ -49,8 +48,12 @@ subprojects {
|
|||||||
project.group = BuildConfig.packageName
|
project.group = BuildConfig.packageName
|
||||||
project.version = rootProject.version
|
project.version = rootProject.version
|
||||||
|
|
||||||
plugins.withId("com.android.application") { configureAndroidModule(libs.androidx.lib.desugaring.get()) }
|
plugins.withId("com.android.application") {
|
||||||
plugins.withId("com.android.library") { configureAndroidModule(libs.androidx.lib.desugaring.get()) }
|
configureAndroidModule(libs.androidx.lib.desugaring.get())
|
||||||
|
}
|
||||||
|
plugins.withId("com.android.library") {
|
||||||
|
configureAndroidModule(libs.androidx.lib.desugaring.get())
|
||||||
|
}
|
||||||
plugins.withId("java-library") { configureJavaModule() }
|
plugins.withId("java-library") { configureJavaModule() }
|
||||||
plugins.withId("com.vanniktech.maven.publish.base") { configureMavenPublish() }
|
plugins.withId("com.vanniktech.maven.publish.base") { configureMavenPublish() }
|
||||||
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
#!/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" # 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"
|
|
||||||
DEFCONFIG_REPLACE_END="FDROID_PREBUILD_DEFCONFIG_REPLACE_END"
|
|
||||||
|
|
||||||
# settings.gradle
|
|
||||||
SETTINGS_GRADLE_REPLACE_BEGIN="FDROID_PREBUILD_SETTINGS_REPLACE_BEGIN"
|
|
||||||
SETTINGS_GRADLE_REPLACE_END="FDROID_PREBUILD_SETTINGS_REPLACE_END"
|
|
||||||
|
|
||||||
# Android productFlavors
|
|
||||||
FLAVORS_INSERT="FDROID_PREBUILD_FLAVORS_INSERT"
|
|
||||||
|
|
||||||
# File to update
|
|
||||||
build_gradle="build.gradle.kts"
|
|
||||||
gradle_props="../fdroid.properties"
|
|
||||||
settings_gradle="../settings.gradle.kts"
|
|
||||||
|
|
||||||
flavorDef="productFlavors {\n"
|
|
||||||
|
|
||||||
i=1
|
|
||||||
for arch in arm64-v8a armeabi-v7a x86_64; do
|
|
||||||
flavorDef+="create(\"$arch\") { \n"
|
|
||||||
flavorDef+=" versionNameSuffix = \"-fdroid\" \n"
|
|
||||||
flavorDef+=" versionCode = 100 * $versionCode + $i \n"
|
|
||||||
flavorDef+="}\n"
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
flavorDef+="}"
|
|
||||||
|
|
||||||
# settings.gradle
|
|
||||||
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 fdroidVersionName = requireNotNull(properties.getProperty("ide.build.fdroid.version", null)) {
|
|
||||||
"'ide.build.fdroid' is 'true' but no 'ide.build.fdroid.version' is defined!"
|
|
||||||
}
|
|
||||||
|
|
||||||
gradle.rootProject { project.setProperty("version", fdroidVersionName) }
|
|
||||||
END
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
# Replace properties in defaultConfig with constants
|
|
||||||
sed -i "/\/\/ @@$DEFCONFIG_REPLACE_BEGIN@@/,/\/\/ @@$DEFCONFIG_REPLACE_END@@/c\
|
|
||||||
applicationId = \"com.itsaky.androidide\" \n \
|
|
||||||
versionName = \"$versionName\" \n \
|
|
||||||
versionCode = $versionCode \n" $build_gradle
|
|
||||||
|
|
||||||
# Add product flavors
|
|
||||||
sed -i "/\/\/ @@$FLAVORS_INSERT@@/c\
|
|
||||||
$flavorDef" $build_gradle
|
|
||||||
|
|
||||||
# Remove the Nyx plugin from settings.gradle
|
|
||||||
awk -v begin="$SETTINGS_GRADLE_REPLACE_BEGIN" -v end="$SETTINGS_GRADLE_REPLACE_END" -v replacement="$settingsDef" '
|
|
||||||
$0 ~ ("// @@" begin "@@") {
|
|
||||||
printing = 1;
|
|
||||||
print replacement;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
printing && $0 ~ ("// @@" end "@@") {
|
|
||||||
printing = 0;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
!printing
|
|
||||||
' $settings_gradle >temp_settings.gradle && mv temp_settings.gradle $settings_gradle
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
+54
-13
@@ -11,23 +11,24 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO NOT REMOVE THESE COMMENTS!
|
buildscript {
|
||||||
// @@FDROID_PREBUILD_SETTINGS_REPLACE_BEGIN@@
|
repositories {
|
||||||
plugins {
|
mavenCentral()
|
||||||
id("com.mooltiverse.oss.nyx") version "2.5.1"
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("com.mooltiverse.oss.nyx:gradle:2.5.1")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO NOT REPLACE WITH IMPORT!!
|
FDroidConfig.load(rootDir)
|
||||||
extensions.configure<com.mooltiverse.oss.nyx.gradle.NyxExtension> {
|
|
||||||
git {
|
if (FDroidConfig.hasRead && FDroidConfig.isFDroidBuild) {
|
||||||
remotes.register("origin") {
|
gradle.rootProject { project.setProperty("version", FDroidConfig.fDroidVersionName!!) }
|
||||||
user.set("{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}")
|
} else {
|
||||||
password.set("")
|
apply {
|
||||||
|
plugin("com.mooltiverse.oss.nyx")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
configurationFile.set(".nyx.yml")
|
|
||||||
}
|
|
||||||
// @@FDROID_PREBUILD_SETTINGS_REPLACE_END@@
|
|
||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
@@ -108,3 +109,43 @@ include(
|
|||||||
":testing:tooling",
|
":testing:tooling",
|
||||||
":testing:unit",
|
":testing:unit",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
object FDroidConfig {
|
||||||
|
|
||||||
|
var hasRead: Boolean = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
var isFDroidBuild: Boolean = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
var fDroidVersionName: String? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
var fDroidVersionCode: Int? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
const val PROP_FDROID_BUILD = "ide.build.fdroid"
|
||||||
|
const val PROP_FDROID_BUILD_VERSION = "ide.build.fdroid.version"
|
||||||
|
const val PROP_FDROID_BUILD_VERCODE = "ide.build.fdroid.vercode"
|
||||||
|
|
||||||
|
fun load(rootDir: File) {
|
||||||
|
val propsFile = File(rootDir, "fdroid.properties")
|
||||||
|
if (!propsFile.exists() || !propsFile.isFile) {
|
||||||
|
hasRead = true
|
||||||
|
isFDroidBuild = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val properties = propsFile.let { props ->
|
||||||
|
java.util.Properties().also {
|
||||||
|
it.load(props.reader())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasRead = true
|
||||||
|
isFDroidBuild = properties.getProperty(PROP_FDROID_BUILD, null).toBoolean()
|
||||||
|
|
||||||
|
fDroidVersionName = properties.getProperty(PROP_FDROID_BUILD_VERSION, null)
|
||||||
|
fDroidVersionCode = properties.getProperty(PROP_FDROID_BUILD_VERCODE, null)?.toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user