build: replace buildSrc with includeBuild

Signed-off-by: keta1 <k@ketal.icu>
This commit is contained in:
keta1
2022-08-20 23:35:48 +08:00
parent f309bded49
commit a2874a3089
17 changed files with 281 additions and 78 deletions

View File

@@ -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.SigningExtension
import com.android.tools.build.apkzlib.sign.SigningOptions import com.android.tools.build.apkzlib.sign.SigningOptions
import com.android.tools.build.apkzlib.zfile.ZFiles 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.AlignmentRules
import com.android.tools.build.apkzlib.zip.CompressionMethod
import com.android.tools.build.apkzlib.zip.ZFile import com.android.tools.build.apkzlib.zip.ZFile
import com.android.tools.build.apkzlib.zip.ZFileOptions import com.android.tools.build.apkzlib.zip.ZFileOptions
import java.io.FileInputStream import java.io.FileInputStream
@@ -34,6 +34,7 @@ import java.security.cert.X509Certificate
import java.util.UUID import java.util.UUID
plugins { plugins {
id("io.github.qauxv.application")
id("com.android.application") id("com.android.application")
id("org.jetbrains.kotlin.android") id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp") version "${Version.kotlin}-${Version.ksp}" id("com.google.devtools.ksp") version "${Version.kotlin}-${Version.ksp}"
@@ -52,12 +53,12 @@ if (ccacheExecutablePath != null) {
} }
android { android {
namespace = "io.github.qauxv"
defaultConfig { defaultConfig {
applicationId = "io.github.qauxv" applicationId = "io.github.qauxv"
buildConfigField("String", "BUILD_UUID", "\"$currentBuildUuid\"") buildConfigField("String", "BUILD_UUID", "\"$currentBuildUuid\"")
buildConfigField("long", "BUILD_TIMESTAMP", "${System.currentTimeMillis()}L") buildConfigField("long", "BUILD_TIMESTAMP", "${System.currentTimeMillis()}L")
resourceConfigurations += listOf("zh", "en")
externalNativeBuild { externalNativeBuild {
cmake { cmake {
@@ -84,8 +85,6 @@ android {
keyAlias = System.getenv("KEY_ALIAS") keyAlias = System.getenv("KEY_ALIAS")
keyPassword = System.getenv("KEY_PASSWORD") keyPassword = System.getenv("KEY_PASSWORD")
enableV2Signing = true enableV2Signing = true
enableV3Signing = true
enableV4Signing = true
} }
} }
} }
@@ -118,7 +117,6 @@ android {
androidResources { androidResources {
additionalParameters("--allow-reserved-package-id", "--package-id", "0x39") additionalParameters("--allow-reserved-package-id", "--package-id", "0x39")
} }
kotlinOptions.jvmTarget = Version.java.toString()
externalNativeBuild { externalNativeBuild {
cmake { cmake {
@@ -132,7 +130,6 @@ android {
lint { lint {
checkDependencies = true checkDependencies = true
} }
namespace = "io.github.qauxv"
} }
dependencies { dependencies {
@@ -272,7 +269,6 @@ tasks.register("checkGitSubmodule") {
} }
}.also { tasks.preBuild.dependsOn(it) } }.also { tasks.preBuild.dependsOn(it) }
val synthesizeDistReleaseApksCI by tasks.registering { val synthesizeDistReleaseApksCI by tasks.registering {
group = "build" group = "build"
// use :app:assembleRelease output apk as input // use :app:assembleRelease output apk as input

View File

@@ -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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
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<KotlinCompile> {
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"
}
}
}

View File

@@ -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
* <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)
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

@@ -8,6 +8,11 @@ object Version {
const val ksp = "1.0.6" const val ksp = "1.0.6"
val java = JavaVersion.VERSION_11 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 defaultNdkVersion = "25.0.8775105"
private const val defaultCMakeVersion = "3.22.1" private const val defaultCMakeVersion = "3.22.1"

View File

@@ -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
* <https://www.gnu.org/licenses/>
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/
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<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
}
extensions.configure<BaseAppModuleExtension> {
configureKotlinAndroid(this)
}
}
}
}

View File

@@ -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
* <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")
}
extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
}
}
}
}

View File

@@ -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
* <https://www.gnu.org/licenses/>
* <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) {
}
}

View File

@@ -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

Binary file not shown.

View File

@@ -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

View File

@@ -0,0 +1,10 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}
include(":convention")

View File

@@ -20,56 +20,14 @@
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>. * <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/ */
import com.android.build.gradle.BaseExtension
plugins { plugins {
id("io.github.qauxv.version")
id("com.android.application") version "7.2.2" apply false id("com.android.application") version "7.2.2" apply false
id("com.android.library") 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 id("org.jetbrains.kotlin.android") version "1.7.10" apply false
kotlin("plugin.serialization") version Version.kotlin apply false kotlin("plugin.serialization") version "1.7.10" apply false
} }
tasks.register<Delete>("clean").configure { tasks.register<Delete>("clean").configure {
delete(rootProject.buildDir) 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()
}
}

View File

@@ -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<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}

View File

@@ -1,4 +1,5 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'io.github.qauxv.library'
android { android {
defaultConfig { defaultConfig {

View File

@@ -4,6 +4,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
// enableFeaturePreview("STABLE_CONFIGURATION_CACHE") // enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
pluginManagement { pluginManagement {
includeBuild("build-logic")
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
google() google()