mirror of
https://github.com/null2264/yokai.git
synced 2025-06-20 18:24:42 +00:00
refactor: Rework buildSrc
Co-authored-by: AntsyLich <59261191+antsylich@users.noreply.github.com>
This commit is contained in:
parent
b201e410a3
commit
c09c4045e2
19 changed files with 218 additions and 86 deletions
|
@ -7,9 +7,8 @@ import java.time.format.DateTimeFormatter
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
alias(androidx.plugins.application)
|
||||
alias(kotlinx.plugins.android)
|
||||
alias(kotlinx.plugins.compose.compiler)
|
||||
id("yokai.android.application")
|
||||
id("yokai.android.application.compose")
|
||||
alias(kotlinx.plugins.serialization)
|
||||
alias(kotlinx.plugins.parcelize)
|
||||
alias(libs.plugins.aboutlibraries)
|
||||
|
@ -122,7 +121,6 @@ android {
|
|||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
compose = true
|
||||
// If you're here because there's not BuildConfig, build the app first, it'll generate it for you
|
||||
buildConfig = true
|
||||
|
||||
|
@ -284,13 +282,12 @@ tasks {
|
|||
// "-opt-in=kotlin.Experimental",
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=coil3.annotation.ExperimentalCoilApi",
|
||||
"-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
|
||||
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
|
||||
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
|
||||
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
// "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi",
|
||||
"-opt-in=coil3.annotation.ExperimentalCoilApi",
|
||||
// "-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi",
|
||||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-opt-in=kotlinx.coroutines.FlowPreview",
|
||||
|
@ -298,19 +295,6 @@ tasks {
|
|||
"-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
|
||||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
)
|
||||
|
||||
if (project.findProperty("tachiyomi.enableComposeCompilerMetrics") == "true") {
|
||||
compilerOptions.freeCompilerArgs.addAll(
|
||||
"-P",
|
||||
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
|
||||
(project.layout.buildDirectory.asFile.orNull?.absolutePath ?: "/tmp/yokai") + "/compose_metrics",
|
||||
)
|
||||
compilerOptions.freeCompilerArgs.addAll(
|
||||
"-P",
|
||||
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
|
||||
(project.layout.buildDirectory.asFile.orNull?.absolutePath ?: "/tmp/yokai") + "/compose_metrics",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicating Hebrew string assets due to some locale code issues on different devices
|
||||
|
|
|
@ -8,12 +8,6 @@ import java.util.*
|
|||
plugins {
|
||||
alias(libs.plugins.kotlinter)
|
||||
alias(libs.plugins.gradle.versions)
|
||||
alias(androidx.plugins.application) apply false
|
||||
alias(androidx.plugins.library) apply false
|
||||
alias(kotlinx.plugins.android) apply false
|
||||
alias(kotlinx.plugins.compose.compiler) apply false
|
||||
alias(kotlinx.plugins.multiplatform) apply false
|
||||
alias(kotlinx.plugins.parcelize) apply false
|
||||
alias(kotlinx.plugins.serialization) apply false
|
||||
alias(libs.plugins.aboutlibraries) apply false
|
||||
alias(libs.plugins.firebase.crashlytics) apply false
|
||||
|
@ -22,46 +16,6 @@ plugins {
|
|||
alias(libs.plugins.sqldelight) apply false
|
||||
}
|
||||
|
||||
subprojects {
|
||||
tasks.withType<KotlinCompile> {
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.JVM_17
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withType<BasePlugin> {
|
||||
configure<BaseExtension> {
|
||||
compileSdkVersion(AndroidConfig.compileSdk)
|
||||
ndkVersion = AndroidConfig.ndk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
targetSdk = AndroidConfig.targetSdk
|
||||
ndk {
|
||||
version = AndroidConfig.ndk
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
add("coreLibraryDesugaring", libs.desugar)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("dependencyUpdates", com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class.java).configure {
|
||||
rejectVersionIf {
|
||||
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { candidate.version.uppercase(Locale.ROOT).contains(it) }
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(androidx.gradle)
|
||||
implementation(kotlinx.gradle)
|
||||
implementation(kotlinx.compose.compiler.gradle)
|
||||
implementation(gradleApi())
|
||||
|
||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
implementation(files(androidx.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
implementation(files(compose.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
implementation(files(kotlinx.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
}
|
||||
google()
|
||||
}
|
||||
|
|
|
@ -1 +1,18 @@
|
|||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
create("androidx") {
|
||||
from(files("../gradle/androidx.versions.toml"))
|
||||
}
|
||||
create("compose") {
|
||||
from(files("../gradle/compose.versions.toml"))
|
||||
}
|
||||
create("kotlinx") {
|
||||
from(files("../gradle/kotlinx.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "yokai-buildSrc"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import org.gradle.api.JavaVersion as GradleJavaVersion
|
||||
|
||||
object AndroidConfig {
|
||||
const val compileSdk = 35
|
||||
const val minSdk = 23
|
||||
const val targetSdk = 35
|
||||
const val ndk = "27.2.12479018"
|
||||
const val COMPILE_SDK = 35
|
||||
const val MIN_SDK = 23
|
||||
const val TARGET_SDK = 35
|
||||
const val NDK = "27.2.12479018"
|
||||
val JavaVersion = GradleJavaVersion.VERSION_17
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import yokai.build.configureCompose
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
configureCompose(this)
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import yokai.build.configureAndroid
|
||||
import yokai.build.configureTest
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
targetSdk = AndroidConfig.TARGET_SDK
|
||||
}
|
||||
configureAndroid(this)
|
||||
configureTest()
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import yokai.build.configureCompose
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
}
|
||||
|
||||
android {
|
||||
configureCompose(this)
|
||||
}
|
11
buildSrc/src/main/kotlin/yokai.android.library.gradle.kts
Normal file
11
buildSrc/src/main/kotlin/yokai.android.library.gradle.kts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import yokai.build.configureAndroid
|
||||
import yokai.build.configureTest
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
}
|
||||
|
||||
android {
|
||||
configureAndroid(this)
|
||||
configureTest()
|
||||
}
|
|
@ -1,6 +1,98 @@
|
|||
package yokai.build
|
||||
|
||||
import com.android.build.api.dsl.CommonExtension
|
||||
import org.gradle.accessors.dm.LibrariesForAndroidx
|
||||
import org.gradle.accessors.dm.LibrariesForCompose
|
||||
import org.gradle.accessors.dm.LibrariesForKotlinx
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import org.gradle.kotlin.dsl.the
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
|
||||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.io.File
|
||||
|
||||
val Project.androidx get() = the<LibrariesForAndroidx>()
|
||||
val Project.compose get() = the<LibrariesForCompose>()
|
||||
val Project.kotlinx get() = the<LibrariesForKotlinx>()
|
||||
val Project.libs get() = the<LibrariesForLibs>()
|
||||
|
||||
val Project.generatedBuildDir: File get() = project.layout.buildDirectory.asFile.get().resolve("generated/yokai")
|
||||
|
||||
internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *, *, *, *>) {
|
||||
commonExtension.apply {
|
||||
compileSdk = AndroidConfig.COMPILE_SDK
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.MIN_SDK
|
||||
ndk {
|
||||
version = AndroidConfig.NDK
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = AndroidConfig.JavaVersion
|
||||
targetCompatibility = AndroidConfig.JavaVersion
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
}
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
kotlinOptions {
|
||||
jvmTarget = AndroidConfig.JavaVersion.toString()
|
||||
// freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
|
||||
// freeCompilerArgs += "-Xcontext-receivers"
|
||||
// Treat all Kotlin warnings as errors (disabled by default)
|
||||
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
|
||||
// val warningsAsErrors: String? by project
|
||||
// allWarningsAsErrors = warningsAsErrors.toBoolean()
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
"coreLibraryDesugaring"(libs.desugar)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.configureCompose(commonExtension: CommonExtension<*, *, *, *, *, *>) {
|
||||
pluginManager.apply(kotlinx.plugins.compose.compiler.get().pluginId)
|
||||
|
||||
commonExtension.apply {
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"implementation"(platform(compose.bom))
|
||||
}
|
||||
}
|
||||
|
||||
extensions.configure<ComposeCompilerGradlePluginExtension> {
|
||||
featureFlags.set(setOf(ComposeFeatureFlag.OptimizeNonSkippingGroups))
|
||||
|
||||
val enableMetrics = project.providers.gradleProperty("enableComposeCompilerMetrics").orNull.toBoolean()
|
||||
val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean()
|
||||
|
||||
val rootBuildDir = rootProject.layout.buildDirectory.asFile.get()
|
||||
val relativePath = projectDir.relativeTo(rootDir)
|
||||
|
||||
if (enableMetrics) {
|
||||
rootBuildDir.resolve("compose-metrics").resolve(relativePath).let(metricsDestination::set)
|
||||
}
|
||||
|
||||
if (enableReports) {
|
||||
rootBuildDir.resolve("compose-reports").resolve(relativePath).let(reportsDestination::set)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.configureTest() {
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
alias(androidx.plugins.library)
|
||||
alias(kotlinx.plugins.multiplatform)
|
||||
id("yokai.android.library")
|
||||
kotlin("multiplatform")
|
||||
alias(kotlinx.plugins.serialization)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
plugins {
|
||||
alias(kotlinx.plugins.multiplatform)
|
||||
id("yokai.android.library")
|
||||
kotlin("multiplatform")
|
||||
alias(kotlinx.plugins.serialization)
|
||||
alias(androidx.plugins.library)
|
||||
alias(libs.plugins.sqldelight)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
plugins {
|
||||
alias(kotlinx.plugins.multiplatform)
|
||||
id("yokai.android.library")
|
||||
kotlin("multiplatform")
|
||||
alias(kotlinx.plugins.serialization)
|
||||
alias(androidx.plugins.library)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
|
|
@ -4,6 +4,8 @@ agp = "8.7.3"
|
|||
lifecycle = "2.8.7"
|
||||
|
||||
[libraries]
|
||||
gradle = { module = "com.android.tools.build:gradle", version.ref = "agp" }
|
||||
|
||||
activity = { module = "androidx.activity:activity-ktx", version.ref = "activity" }
|
||||
activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity" }
|
||||
annotation = { module = "androidx.annotation:annotation", version = "1.9.1" }
|
||||
|
|
|
@ -4,6 +4,9 @@ serialization = "1.7.3"
|
|||
xml_serialization = "0.90.3"
|
||||
|
||||
[libraries]
|
||||
gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
compose-compiler-gradle = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }
|
||||
|
||||
coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version = "1.10.1" }
|
||||
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android" }
|
||||
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" }
|
||||
|
@ -26,4 +29,4 @@ android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
|||
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
|
||||
parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize" }
|
||||
|
|
|
@ -2,8 +2,8 @@ import yokai.build.generatedBuildDir
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
alias(kotlinx.plugins.multiplatform)
|
||||
alias(androidx.plugins.library)
|
||||
id("yokai.android.library")
|
||||
kotlin("multiplatform")
|
||||
alias(libs.plugins.moko)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
plugins {
|
||||
alias(androidx.plugins.library)
|
||||
alias(kotlinx.plugins.android)
|
||||
id("yokai.android.library")
|
||||
id("yokai.android.library.compose")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -12,6 +13,22 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll(
|
||||
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
"-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi",
|
||||
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
|
||||
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
|
||||
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
|
||||
"-opt-in=kotlinx.coroutines.FlowPreview",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(libs.material)
|
||||
|
||||
implementation(compose.bundles.compose)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
alias(androidx.plugins.library)
|
||||
alias(kotlinx.plugins.android)
|
||||
alias(kotlinx.plugins.compose.compiler)
|
||||
id("yokai.android.library")
|
||||
id("yokai.android.library.compose")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
alias(androidx.plugins.library)
|
||||
alias(kotlinx.plugins.multiplatform)
|
||||
id("yokai.android.library")
|
||||
kotlin("multiplatform")
|
||||
alias(kotlinx.plugins.serialization)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue