diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 55cd7183..b78d9032 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -24,8 +24,8 @@ import com.android.build.gradle.internal.tasks.factory.dependsOn import com.android.tools.build.apkzlib.sign.SigningExtension import com.android.tools.build.apkzlib.sign.SigningOptions import com.android.tools.build.apkzlib.zfile.ZFiles -import com.android.tools.build.apkzlib.zip.CompressionMethod import com.android.tools.build.apkzlib.zip.AlignmentRules +import com.android.tools.build.apkzlib.zip.CompressionMethod import com.android.tools.build.apkzlib.zip.ZFile import com.android.tools.build.apkzlib.zip.ZFileOptions import java.io.FileInputStream @@ -34,6 +34,7 @@ import java.security.cert.X509Certificate import java.util.UUID plugins { + id("io.github.qauxv.application") id("com.android.application") id("org.jetbrains.kotlin.android") id("com.google.devtools.ksp") version "${Version.kotlin}-${Version.ksp}" @@ -52,12 +53,12 @@ if (ccacheExecutablePath != null) { } android { + namespace = "io.github.qauxv" defaultConfig { applicationId = "io.github.qauxv" buildConfigField("String", "BUILD_UUID", "\"$currentBuildUuid\"") buildConfigField("long", "BUILD_TIMESTAMP", "${System.currentTimeMillis()}L") - resourceConfigurations += listOf("zh", "en") externalNativeBuild { cmake { @@ -84,8 +85,6 @@ android { keyAlias = System.getenv("KEY_ALIAS") keyPassword = System.getenv("KEY_PASSWORD") enableV2Signing = true - enableV3Signing = true - enableV4Signing = true } } } @@ -118,7 +117,6 @@ android { androidResources { additionalParameters("--allow-reserved-package-id", "--package-id", "0x39") } - kotlinOptions.jvmTarget = Version.java.toString() externalNativeBuild { cmake { @@ -132,7 +130,6 @@ android { lint { checkDependencies = true } - namespace = "io.github.qauxv" } dependencies { @@ -272,7 +269,6 @@ tasks.register("checkGitSubmodule") { } }.also { tasks.preBuild.dependsOn(it) } - val synthesizeDistReleaseApksCI by tasks.registering { group = "build" // use :app:assembleRelease output apk as input diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts new file mode 100644 index 00000000..6b8c7341 --- /dev/null +++ b/build-logic/convention/build.gradle.kts @@ -0,0 +1,69 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2022 qwq233@qwq2333.top + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software 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 + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + `kotlin-dsl` +} + +group = "io.github.qauxv.buildLogic" + +repositories { + google() + gradlePluginPortal() + mavenCentral() +} + +dependencies { + implementation("com.android.tools.build:gradle:7.2.2") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") + implementation("org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r") +} + +java { + targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_11 +} + +tasks.withType { + kotlinOptions { + jvmTarget = "11" + } +} + +gradlePlugin { + plugins { + register("versionPlugin") { + id = "io.github.qauxv.version" + implementationClass = "plugin.VersionPlugin" + } + register("androidApplication") { + id = "io.github.qauxv.application" + implementationClass = "plugin.ApplicationConventionPlugin" + } + register("androidLibrary") { + id = "io.github.qauxv.library" + implementationClass = "plugin.LibraryConventionPlugin" + } + } +} diff --git a/buildSrc/src/main/kotlin/Common.kt b/build-logic/convention/src/main/kotlin/Common.kt similarity index 100% rename from buildSrc/src/main/kotlin/Common.kt rename to build-logic/convention/src/main/kotlin/Common.kt diff --git a/build-logic/convention/src/main/kotlin/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/KotlinAndroid.kt new file mode 100644 index 00000000..5ff05f7c --- /dev/null +++ b/build-logic/convention/src/main/kotlin/KotlinAndroid.kt @@ -0,0 +1,61 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2022 qwq233@qwq2333.top + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software 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 + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +import com.android.build.gradle.BaseExtension +import org.gradle.api.Project +import org.gradle.api.plugins.ExtensionAware +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions + +/** + * Configure base Kotlin with Android options + */ +internal fun Project.configureKotlinAndroid( + commonExtension: BaseExtension +) { + commonExtension.apply { + compileSdkVersion(Version.compileSdkVersion) + ndkVersion = Version.getNdkVersion(project) + + defaultConfig { + minSdk = Version.minSdk + targetSdk = Version.targetSdk + versionCode = Common.getBuildVersionCode(rootProject) + versionName = Version.versionName + Common.getGitHeadRefsSuffix(rootProject) + resourceConfigurations += listOf("zh", "en") + } + + compileOptions { + sourceCompatibility = Version.java + targetCompatibility = Version.java + } + + kotlinOptions { + jvmTarget = Version.java.toString() + } + + packagingOptions.jniLibs.useLegacyPackaging = false + } +} + +private fun BaseExtension.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { + (this as ExtensionAware).extensions.configure("kotlinOptions", block) +} diff --git a/buildSrc/src/main/kotlin/ReplaceIcon.kt b/build-logic/convention/src/main/kotlin/ReplaceIcon.kt similarity index 100% rename from buildSrc/src/main/kotlin/ReplaceIcon.kt rename to build-logic/convention/src/main/kotlin/ReplaceIcon.kt diff --git a/buildSrc/src/main/kotlin/Version.kt b/build-logic/convention/src/main/kotlin/Version.kt similarity index 93% rename from buildSrc/src/main/kotlin/Version.kt rename to build-logic/convention/src/main/kotlin/Version.kt index a71e12c2..18852d1f 100644 --- a/buildSrc/src/main/kotlin/Version.kt +++ b/build-logic/convention/src/main/kotlin/Version.kt @@ -8,6 +8,11 @@ object Version { const val ksp = "1.0.6" val java = JavaVersion.VERSION_11 + const val compileSdkVersion = 32 + const val minSdk = 24 + const val targetSdk = 33 + const val versionName = "1.2.14" + private const val defaultNdkVersion = "25.0.8775105" private const val defaultCMakeVersion = "3.22.1" diff --git a/build-logic/convention/src/main/kotlin/plugin/ApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/plugin/ApplicationConventionPlugin.kt new file mode 100644 index 00000000..a8a8278e --- /dev/null +++ b/build-logic/convention/src/main/kotlin/plugin/ApplicationConventionPlugin.kt @@ -0,0 +1,44 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2022 qwq233@qwq2333.top + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software 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 + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package plugin + +import com.android.build.gradle.internal.dsl.BaseAppModuleExtension +import configureKotlinAndroid +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure + +class ApplicationConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.android.application") + apply("org.jetbrains.kotlin.android") + } + + extensions.configure { + configureKotlinAndroid(this) + } + } + } +} diff --git a/build-logic/convention/src/main/kotlin/plugin/LibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/plugin/LibraryConventionPlugin.kt new file mode 100644 index 00000000..7cb3d0cc --- /dev/null +++ b/build-logic/convention/src/main/kotlin/plugin/LibraryConventionPlugin.kt @@ -0,0 +1,44 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2022 qwq233@qwq2333.top + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software 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 + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package plugin + +import com.android.build.gradle.LibraryExtension +import configureKotlinAndroid +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure + +class LibraryConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.android.library") + apply("org.jetbrains.kotlin.android") + } + + extensions.configure { + configureKotlinAndroid(this) + } + } + } +} diff --git a/build-logic/convention/src/main/kotlin/plugin/VersionPlugin.kt b/build-logic/convention/src/main/kotlin/plugin/VersionPlugin.kt new file mode 100644 index 00000000..31788076 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/plugin/VersionPlugin.kt @@ -0,0 +1,31 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2022 qwq233@qwq2333.top + * https://github.com/cinit/QAuxiliary + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version and our eula as published + * by QAuxiliary contributors. + * + * This software 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 + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * . + */ + +package plugin + +import org.gradle.api.Plugin +import org.gradle.api.Project + +class VersionPlugin : Plugin { + override fun apply(target: Project) { + } +} diff --git a/build-logic/gradle.properties b/build-logic/gradle.properties new file mode 100644 index 00000000..1c9073eb --- /dev/null +++ b/build-logic/gradle.properties @@ -0,0 +1,4 @@ +# Gradle properties are not passed to included builds https://github.com/gradle/gradle/issues/2534 +org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configureondemand=true diff --git a/build-logic/gradle/wrapper/gradle-wrapper.jar b/build-logic/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/build-logic/gradle/wrapper/gradle-wrapper.jar differ diff --git a/build-logic/gradle/wrapper/gradle-wrapper.properties b/build-logic/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..ae04661e --- /dev/null +++ b/build-logic/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000..b6245bfe --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,10 @@ +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} + +include(":convention") diff --git a/build.gradle.kts b/build.gradle.kts index b5d16eb3..2748e9c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,56 +20,14 @@ * . */ -import com.android.build.gradle.BaseExtension - plugins { + id("io.github.qauxv.version") id("com.android.application") version "7.2.2" apply false id("com.android.library") version "7.2.2" apply false - id("org.jetbrains.kotlin.android") version Version.kotlin apply false - kotlin("plugin.serialization") version Version.kotlin apply false + id("org.jetbrains.kotlin.android") version "1.7.10" apply false + kotlin("plugin.serialization") version "1.7.10" apply false } tasks.register("clean").configure { delete(rootProject.buildDir) } - -val apiCode by extra(93) -val verCode = Common.getBuildVersionCode(rootProject) -// versionName = major.minor.bugfix.rev.commit -val verName = "1.2.14" + (Common.getGitHeadRefsSuffix(rootProject)) -val androidTargetSdkVersion by extra(33) -val androidMinSdkVersion by extra(24) -val androidCompileSdkVersion by extra(32) -val androidBuildToolsVersion by extra("32.0.0") -val androidCompileNdkVersion = Version.getNdkVersion(project) - -fun Project.configureBaseExtension() { - extensions.findByType(BaseExtension::class)?.run { - compileSdkVersion(androidCompileSdkVersion) - ndkVersion = androidCompileNdkVersion - buildToolsVersion = androidBuildToolsVersion - - defaultConfig { - minSdk = androidMinSdkVersion - targetSdk = androidTargetSdkVersion - versionCode = verCode - versionName = verName - } - - compileOptions { - sourceCompatibility = Version.java - targetCompatibility = Version.java - } - - packagingOptions.jniLibs.useLegacyPackaging = false - } -} - -subprojects { - plugins.withId("com.android.application") { - configureBaseExtension() - } - plugins.withId("com.android.library") { - configureBaseExtension() - } -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 18c42bcf..00000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - `kotlin-dsl` -} - -repositories { - google() - gradlePluginPortal() - mavenCentral() - - dependencies { - implementation("org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r") - } -} - -java { - targetCompatibility = JavaVersion.VERSION_11 - sourceCompatibility = JavaVersion.VERSION_11 -} - -tasks.withType { - kotlinOptions { - jvmTarget = "11" - } -} diff --git a/libs/mmkv/build.gradle b/libs/mmkv/build.gradle index e66afe26..09d284b5 100644 --- a/libs/mmkv/build.gradle +++ b/libs/mmkv/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'io.github.qauxv.library' android { defaultConfig { diff --git a/settings.gradle.kts b/settings.gradle.kts index ac669f8f..7ea4bb77 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,6 +4,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") // enableFeaturePreview("STABLE_CONFIGURATION_CACHE") pluginManagement { + includeBuild("build-logic") repositories { gradlePluginPortal() google()