build: Migration to version catalog

Signed-off-by: keta1 <k@ketal.icu>
This commit is contained in:
keta1
2022-12-29 22:19:17 +08:00
parent 8b1b68e3a9
commit 35d9c8a250
18 changed files with 180 additions and 169 deletions

View File

@@ -34,12 +34,13 @@ import java.security.KeyStore
import java.security.cert.X509Certificate
import java.util.UUID
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("io.github.qauxv.application")
id("com.google.devtools.ksp") version Version.ksp
kotlin("plugin.serialization") version Version.kotlin
id("com.jaredsburrows.license") version "0.9.0"
id("org.jetbrains.changelog") version "2.0.0"
id("build-logic.android.application")
alias(libs.plugins.changelog)
alias(libs.plugins.ksp)
alias(libs.plugins.license)
alias(libs.plugins.serialization)
}
val currentBuildUuid = UUID.randomUUID().toString()
@@ -156,8 +157,9 @@ android {
}
buildFeatures {
aidl = true
buildConfig = true
viewBinding = true
renderScript = false
}
lint {
checkDependencies = true
@@ -166,6 +168,7 @@ android {
sourceSets.configureEach {
kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
}
jvmToolchain(11)
}
applicationVariants.all {
val variantCapped = name.capitalize()
@@ -197,33 +200,29 @@ dependencies {
implementation(projects.libs.dexkit)
ksp(projects.libs.ksp)
// androidx
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.browser:browser:1.4.0")
val lifecycleVersion = "2.4.1"
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
compileOnly("de.robv.android.xposed:api:82")
implementation("org.lsposed.hiddenapibypass:hiddenapibypass:4.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("com.google.android.material:material:1.7.0")
implementation("com.google.android.flexbox:flexbox:3.0.0")
implementation("com.afollestad.material-dialogs:core:3.3.0")
implementation("com.afollestad.material-dialogs:input:3.3.0")
implementation("com.jaredrummler:colorpicker:1.1.0")
implementation("com.github.kyuubiran:EzXHelper:1.0.3")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.browser)
implementation(libs.lifecycle.livedata)
implementation(libs.lifecycle.common)
implementation(libs.lifecycle.runtime)
implementation(libs.xposed)
implementation(libs.hiddenapibypass)
implementation(libs.kotlinx.coroutines)
implementation(libs.material)
implementation(libs.flexbox)
implementation(libs.colorpicker)
implementation(libs.material.dialogs.core)
implementation(libs.material.dialogs.input)
implementation(libs.ezXHelper)
// festival title
implementation("com.github.jinatonic.confetti:confetti:1.1.2")
implementation("com.github.MatteoBattilana:WeatherView:3.0.0")
val appCenterSdkVersion = "5.0.0"
implementation("com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}")
implementation("com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
implementation("com.github.livefront.sealed-enum:runtime:0.5.0")
ksp("com.github.livefront.sealed-enum:ksp:0.5.0")
implementation(libs.confetti)
implementation(libs.weatherView)
implementation(libs.appcenter.analytics)
implementation(libs.appcenter.crashes)
implementation(libs.kotlinx.serialization.json)
implementation(libs.sealedEnum.runtime)
ksp(libs.sealedEnum.ksp)
}
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath

View File

@@ -32,12 +32,14 @@ repositories {
google()
gradlePluginPortal()
mavenCentral()
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
implementation("com.android.tools.build:gradle:7.3.1")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22")
implementation("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r")
implementation(libs.android.tools)
implementation(libs.kotlin.gradle)
implementation(libs.eclipse.jgit)
implementation(libs.age)
}
java {
@@ -50,20 +52,3 @@ tasks.withType<KotlinCompile> {
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"
}
}
}

View File

@@ -1,62 +0,0 @@
/*
* 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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
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)
buildToolsVersion = Version.buildToolsVersion
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)
}

View File

@@ -4,8 +4,6 @@ import java.io.File
import java.util.Properties
object Version {
const val kotlin = "1.7.22"
const val ksp = "1.7.22-1.0.8"
val java = JavaVersion.VERSION_11
const val compileSdkVersion = 33

View File

@@ -20,25 +20,15 @@
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
package plugin
plugins {
id("com.android.application")
id("build-logic.android.base")
}
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<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
}
extensions.configure<BaseAppModuleExtension> {
configureKotlinAndroid(this)
}
}
android {
defaultConfig {
targetSdk = Version.targetSdk
versionCode = Common.getBuildVersionCode(rootProject)
versionName = Version.versionName + Common.getGitHeadRefsSuffix(rootProject)
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
@file:Suppress("UnstableApiUsage")
import me.omico.age.dsl.configureAndroidCommon
plugins {
id("com.android.base")
kotlin("android")
}
configureAndroidCommon {
compileSdk = Version.compileSdkVersion
buildToolsVersion = Version.buildToolsVersion
ndkVersion = Version.getNdkVersion(project)
defaultConfig {
minSdk = Version.minSdk
resourceConfigurations += listOf("zh", "en")
}
compileOptions {
sourceCompatibility = Version.java
targetCompatibility = Version.java
}
/*kotlinOptions {
jvmTarget = Version.java.toString()
}*/
packagingOptions.jniLibs.useLegacyPackaging = false
}
/*fun CommonExtension.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
}*/

View File

@@ -19,26 +19,15 @@
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
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<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
}
plugins {
id("com.android.library")
id("build-logic.android.base")
}
extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
}
}
extensions.configure<LibraryExtension> {
defaultConfig {
targetSdk = Version.targetSdk
}
}

View File

@@ -20,12 +20,6 @@
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
package plugin
import org.gradle.api.Plugin
import org.gradle.api.Project
class VersionPlugin : Plugin<Project> {
override fun apply(target: Project) {
}
require(project == rootProject) {
"This script must be apply to the root project."
}

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -5,6 +5,11 @@ dependencyResolutionManagement {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
include(":convention")

View File

@@ -21,7 +21,7 @@
*/
plugins {
id("io.github.qauxv.version")
id("build-logic.root-project")
}
tasks.register<Delete>("clean").configure {

View File

@@ -23,3 +23,9 @@ org.gradle.caching=true
org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache-problems=warn
org.gradle.unsafe.configuration-cache.max-problems=114514
android.defaults.buildfeatures.buildconfig=false
android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.renderscript=false
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false

44
gradle/libs.versions.toml Normal file
View File

@@ -0,0 +1,44 @@
[versions]
agp = "7.3.1"
appCenter = "5.0.0"
compilesdk = "33"
kotlin = "1.8.0"
ksp = "1.8.0-1.0.8"
lifecycle = "2.4.1"
materialDialog = "3.3.0"
[libraries]
age = { module = "me.omico.age:age-dsl", version = "1.0.0-SNAPSHOT" }
appcenter-analytics = { module = "com.microsoft.appcenter:appcenter-analytics", version.ref = "appCenter" }
appcenter-crashes = { module = "com.microsoft.appcenter:appcenter-crashes", version.ref = "appCenter" }
android-tools = { module = "com.android.tools.build:gradle", version.ref = "agp" }
androidx-browser = { module = "androidx.browser:browser", version = "1.4.0" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version = "2.1.4" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.9.0" }
eclipse-jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version = "6.4.0.202211300538-r" }
hiddenapibypass = { module = "org.lsposed.hiddenapibypass:hiddenapibypass", version = "4.3" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version = "1.12.0"}
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4"}
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.4.1"}
ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp"}
lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle"}
lifecycle-common = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "lifecycle"}
lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle"}
material = { module = "com.google.android.material:material", version = "1.7.0"}
material-dialogs-core = { module = "com.afollestad.material-dialogs:core", version.ref = "materialDialog"}
material-dialogs-input = { module = "com.afollestad.material-dialogs:input", version.ref = "materialDialog"}
xposed = { module = "de.robv.android.xposed:api", version = "82"}
flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0"}
colorpicker = { module = "com.jaredrummler:colorpicker", version = "1.1.0"}
ezXHelper = { module = "com.github.kyuubiran:EzXHelper", version = "1.0.3"}
confetti = { module = "com.github.jinatonic.confetti:confetti", version = "1.1.2"}
weatherView = { module = "com.github.MatteoBattilana:WeatherView", version = "3.0.0"}
sealedEnum-runtime = { module = "com.github.livefront.sealed-enum:runtime", version = "0.5.0"}
sealedEnum-ksp = { module = "com.github.livefront.sealed-enum:ksp", version = "0.5.0"}
[plugins]
changelog = { id = "org.jetbrains.changelog", version = "2.0.0" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
license = { id = "com.jaredsburrows.license", version = "0.9.0" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

View File

@@ -23,7 +23,7 @@
@file:Suppress("UnstableApiUsage")
plugins {
id("io.github.qauxv.library")
id("build-logic.android.library")
}
android {

View File

@@ -5,9 +5,8 @@ plugins {
}
dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:${Version.ksp}")
// Note that this API is currently in preview and subject to API changes.
implementation("com.squareup:kotlinpoet-ksp:1.12.0")
implementation(libs.ksp)
implementation(libs.kotlinpoet.ksp)
}
tasks.withType<KotlinCompile> {

View File

@@ -1,5 +1,5 @@
plugins {
id("io.github.qauxv.library")
id("build-logic.android.library")
}
android {
@@ -7,6 +7,10 @@ android {
buildConfigField("String", "FLAVOR", "\"StaticCpp\"")
}
buildFeatures {
buildConfig = true
}
sourceSets {
val main by getting
main.apply {

View File

@@ -1,5 +1,5 @@
plugins {
id("io.github.qauxv.library")
id("build-logic.android.library")
}
android {

View File

@@ -9,6 +9,7 @@ pluginManagement {
gradlePluginPortal()
google()
mavenCentral()
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}
@@ -22,6 +23,10 @@ dependencyResolutionManagement {
}
}
plugins {
id("me.omico.age.settings") version "1.0.0-SNAPSHOT"
}
rootProject.name = "QAuxiliary"
include(
":app",