mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-25 06:11:04 +03:00
Rework buildSrc and remove usage of subprojects
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
parent
c593c83745
commit
3eb3f01646
27 changed files with 269 additions and 153 deletions
|
@ -1,14 +1,17 @@
|
||||||
|
import mihon.buildlogic.getBuildTime
|
||||||
|
import mihon.buildlogic.getCommitCount
|
||||||
|
import mihon.buildlogic.getGitSha
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("mihon.android.application")
|
||||||
|
id("mihon.android.application.compose")
|
||||||
id("com.mikepenz.aboutlibraries.plugin")
|
id("com.mikepenz.aboutlibraries.plugin")
|
||||||
kotlin("android")
|
kotlin("plugin.compose") // TODO(kotlin2): Remove
|
||||||
kotlin("plugin.serialization")
|
|
||||||
kotlin("plugin.compose")
|
|
||||||
id("com.github.zellius.shortcut-helper")
|
id("com.github.zellius.shortcut-helper")
|
||||||
|
kotlin("plugin.serialization")
|
||||||
}
|
}
|
||||||
|
|
||||||
shortcutHelper.setFilePath("./shortcuts.xml")
|
shortcutHelper.setFilePath("./shortcuts.xml")
|
||||||
|
@ -130,7 +133,6 @@ android {
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
compose = true
|
|
||||||
buildConfig = true
|
buildConfig = true
|
||||||
|
|
||||||
// Disable some unused things
|
// Disable some unused things
|
||||||
|
@ -143,10 +145,6 @@ android {
|
||||||
abortOnError = false
|
abortOnError = false
|
||||||
checkReleaseBuilds = false
|
checkReleaseBuilds = false
|
||||||
}
|
}
|
||||||
|
|
||||||
composeOptions {
|
|
||||||
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -161,7 +159,6 @@ dependencies {
|
||||||
implementation(projects.presentationWidget)
|
implementation(projects.presentationWidget)
|
||||||
|
|
||||||
// Compose
|
// Compose
|
||||||
implementation(platform(compose.bom))
|
|
||||||
implementation(compose.activity)
|
implementation(compose.activity)
|
||||||
implementation(compose.foundation)
|
implementation(compose.foundation)
|
||||||
implementation(compose.material3.core)
|
implementation(compose.material3.core)
|
||||||
|
@ -320,23 +317,6 @@ tasks {
|
||||||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (project.findProperty("tachiyomi.enableComposeCompilerMetrics") == "true") {
|
|
||||||
compilerOptions.freeCompilerArgs.addAll(
|
|
||||||
listOf(
|
|
||||||
"-P",
|
|
||||||
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
|
|
||||||
project.layout.buildDirectory.dir("compose_metrics").get().asFile.absolutePath,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
compilerOptions.freeCompilerArgs.addAll(
|
|
||||||
listOf(
|
|
||||||
"-P",
|
|
||||||
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
|
|
||||||
project.layout.buildDirectory.dir("compose_metrics").get().asFile.absolutePath,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import tachiyomi.core.common.i18n.stringResource
|
|
||||||
import tachiyomi.core.common.util.lang.withIOContext
|
import tachiyomi.core.common.util.lang.withIOContext
|
||||||
import tachiyomi.core.common.util.lang.withUIContext
|
import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
|
@ -56,9 +55,6 @@ import uy.kohesive.injekt.api.get
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.ZonedDateTime
|
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
object AboutScreen : Screen() {
|
object AboutScreen : Screen() {
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
import com.android.build.gradle.BaseExtension
|
|
||||||
import com.android.build.gradle.BasePlugin
|
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath(libs.android.shortcut.gradle)
|
classpath(libs.android.shortcut.gradle)
|
||||||
|
@ -18,43 +12,6 @@ plugins {
|
||||||
alias(kotlinx.plugins.compose.compiler) apply false
|
alias(kotlinx.plugins.compose.compiler) apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
|
||||||
tasks.withType<KotlinJvmCompile> {
|
|
||||||
compilerOptions.jvmTarget = JvmTarget.JVM_17
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Test> {
|
|
||||||
useJUnitPlatform()
|
|
||||||
testLogging {
|
|
||||||
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins.withType<BasePlugin> {
|
|
||||||
plugins.apply("detekt")
|
|
||||||
configure<BaseExtension> {
|
|
||||||
compileSdkVersion(AndroidConfig.compileSdk)
|
|
||||||
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.register<Delete>("clean") {
|
tasks.register<Delete>("clean") {
|
||||||
delete(rootProject.layout.buildDirectory)
|
delete(rootProject.layout.buildDirectory)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,11 @@ plugins {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
implementation(androidxLibs.gradle)
|
implementation(files(androidx.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
implementation(kotlinLibs.gradle)
|
implementation(files(compose.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
|
implementation(files(kotlinx.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
|
implementation(androidx.gradle)
|
||||||
|
implementation(kotlinx.gradle)
|
||||||
implementation(libs.detekt.gradlePlugin)
|
implementation(libs.detekt.gradlePlugin)
|
||||||
implementation(gradleApi())
|
implementation(gradleApi())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,13 @@ dependencyResolutionManagement {
|
||||||
create("libs") {
|
create("libs") {
|
||||||
from(files("../gradle/libs.versions.toml"))
|
from(files("../gradle/libs.versions.toml"))
|
||||||
}
|
}
|
||||||
create("androidxLibs") {
|
create("androidx") {
|
||||||
from(files("../gradle/androidx.versions.toml"))
|
from(files("../gradle/androidx.versions.toml"))
|
||||||
}
|
}
|
||||||
create("kotlinLibs") {
|
create("compose") {
|
||||||
|
from(files("../gradle/compose.versions.toml"))
|
||||||
|
}
|
||||||
|
create("kotlinx") {
|
||||||
from(files("../gradle/kotlinx.versions.toml"))
|
from(files("../gradle/kotlinx.versions.toml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
object AndroidConfig {
|
|
||||||
const val compileSdk = 34
|
|
||||||
const val minSdk = 26
|
|
||||||
const val targetSdk = 34
|
|
||||||
const val ndk = "26.1.10909125"
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.Task
|
|
||||||
import org.gradle.api.tasks.TaskProvider
|
|
||||||
import org.gradle.kotlin.dsl.TaskContainerScope
|
|
||||||
|
|
||||||
private val emptyResourcesElement = "<resources>\\s*</resources>|<resources/>".toRegex()
|
|
||||||
private val valuesPrefix = "values(-(b\\+)?)?".toRegex()
|
|
||||||
|
|
||||||
fun TaskContainerScope.registerLocalesConfigTask(project: Project): TaskProvider<Task> {
|
|
||||||
return with(project) {
|
|
||||||
register("generateLocalesConfig") {
|
|
||||||
val languages = fileTree("$projectDir/src/commonMain/moko-resources/")
|
|
||||||
.matching { include("**/strings.xml") }
|
|
||||||
.filterNot { it.readText().contains(emptyResourcesElement) }
|
|
||||||
.map {
|
|
||||||
it.parentFile.name
|
|
||||||
.replace("base", "en")
|
|
||||||
.replace("-r", "-")
|
|
||||||
.replace("+", "-")
|
|
||||||
.takeIf(String::isNotBlank) ?: "en"
|
|
||||||
}
|
|
||||||
.sorted()
|
|
||||||
.joinToString(separator = "\n") {
|
|
||||||
" <locale android:name=\"$it\"/>"
|
|
||||||
}
|
|
||||||
|
|
||||||
val content = """
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
$languages
|
|
||||||
</locale-config>
|
|
||||||
""".trimIndent()
|
|
||||||
|
|
||||||
val localeFile = file("$projectDir/src/androidMain/res/xml/locales_config.xml")
|
|
||||||
localeFile.parentFile.mkdirs()
|
|
||||||
localeFile.writeText(content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import mihon.buildlogic.AndroidConfig
|
||||||
|
import mihon.buildlogic.configureCompose
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.android.application")
|
||||||
|
kotlin("android")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
configureCompose(this)
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
import mihon.buildlogic.AndroidConfig
|
||||||
|
import mihon.buildlogic.configureAndroid
|
||||||
|
import mihon.buildlogic.configureTest
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("mihon.code.detekt")
|
||||||
|
id("com.android.application")
|
||||||
|
kotlin("android")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
defaultConfig {
|
||||||
|
targetSdk = AndroidConfig.TARGET_SDK
|
||||||
|
}
|
||||||
|
configureAndroid(this)
|
||||||
|
configureTest()
|
||||||
|
}
|
13
buildSrc/src/main/kotlin/mihon.benchmark.gradle.kts
Normal file
13
buildSrc/src/main/kotlin/mihon.benchmark.gradle.kts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import mihon.buildlogic.configureAndroid
|
||||||
|
import mihon.buildlogic.configureTest
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("mihon.code.detekt")
|
||||||
|
id("com.android.test")
|
||||||
|
kotlin("android")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
configureAndroid(this)
|
||||||
|
configureTest()
|
||||||
|
}
|
10
buildSrc/src/main/kotlin/mihon.library.compose.gradle.kts
Normal file
10
buildSrc/src/main/kotlin/mihon.library.compose.gradle.kts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import mihon.buildlogic.configureCompose
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("mihon.code.detekt")
|
||||||
|
id("com.android.library")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
configureCompose(this)
|
||||||
|
}
|
12
buildSrc/src/main/kotlin/mihon.library.gradle.kts
Normal file
12
buildSrc/src/main/kotlin/mihon.library.gradle.kts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import mihon.buildlogic.configureAndroid
|
||||||
|
import mihon.buildlogic.configureTest
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("mihon.code.detekt")
|
||||||
|
id("com.android.library")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
configureAndroid(this)
|
||||||
|
configureTest()
|
||||||
|
}
|
11
buildSrc/src/main/kotlin/mihon/buildlogic/AndroidConfig.kt
Normal file
11
buildSrc/src/main/kotlin/mihon/buildlogic/AndroidConfig.kt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package mihon.buildlogic
|
||||||
|
|
||||||
|
import org.gradle.api.JavaVersion as GradleJavaVersion
|
||||||
|
|
||||||
|
object AndroidConfig {
|
||||||
|
const val COMPILE_SDK = 34
|
||||||
|
const val TARGET_SDK = 34
|
||||||
|
const val MIN_SDK = 26
|
||||||
|
const val NDK = "26.1.10909125"
|
||||||
|
val JavaVersion = GradleJavaVersion.VERSION_17
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
package mihon.buildlogic
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
@ -23,9 +25,9 @@ fun Project.getBuildTime(): String {
|
||||||
return LocalDateTime.now(ZoneOffset.UTC).format(BUILD_TIME_FORMATTER)
|
return LocalDateTime.now(ZoneOffset.UTC).format(BUILD_TIME_FORMATTER)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.runCommand(command: String): String {
|
private fun Project.runCommand(command: String): String {
|
||||||
val byteOut = ByteArrayOutputStream()
|
val byteOut = ByteArrayOutputStream()
|
||||||
project.exec {
|
exec {
|
||||||
commandLine = command.split(" ")
|
commandLine = command.split(" ")
|
||||||
standardOutput = byteOut
|
standardOutput = byteOut
|
||||||
}
|
}
|
114
buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt
Normal file
114
buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
package mihon.buildlogic
|
||||||
|
|
||||||
|
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.dependencies
|
||||||
|
import org.gradle.kotlin.dsl.the
|
||||||
|
import org.gradle.kotlin.dsl.withType
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
val Project.androidx get() = the<LibrariesForAndroidx>()
|
||||||
|
val Project.compose get() = the<LibrariesForCompose>()
|
||||||
|
val Project.kotlinx get() = the<LibrariesForKotlinx>()
|
||||||
|
val Project.libs get() = the<LibrariesForLibs>()
|
||||||
|
|
||||||
|
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<*, *, *, *, *, *>) {
|
||||||
|
commonExtension.apply {
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
|
||||||
|
composeOptions {
|
||||||
|
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
"implementation"(platform(compose.bom))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += buildComposeMetricsParameters()
|
||||||
|
|
||||||
|
// Enable experimental compiler opts
|
||||||
|
// https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.9
|
||||||
|
// TODO(kotlin2): add back in -->
|
||||||
|
// freeCompilerArgs += listOf(
|
||||||
|
// "-P",
|
||||||
|
// "plugin:androidx.compose.compiler.plugins.kotlin:nonSkippingGroupOptimization=true",
|
||||||
|
// )
|
||||||
|
// <-- TODO(kotlin2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Project.buildComposeMetricsParameters(): List<String> {
|
||||||
|
val rootProjectDir = rootProject.layout.buildDirectory.asFile.get()
|
||||||
|
val relativePath = projectDir.relativeTo(rootDir)
|
||||||
|
|
||||||
|
val enableMetrics = project.providers.gradleProperty("enableComposeCompilerMetrics").orNull.toBoolean()
|
||||||
|
val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean()
|
||||||
|
|
||||||
|
return listOfNotNull(
|
||||||
|
("metricsDestination" to "compose-metrics").takeIf { enableMetrics },
|
||||||
|
("reportsDestination" to "compose-reports").takeIf { enableReports },
|
||||||
|
).flatMap { (flag, dirName) ->
|
||||||
|
val buildDirPath = rootProjectDir.resolve(dirName).resolve(relativePath).absolutePath
|
||||||
|
listOf(
|
||||||
|
"-P",
|
||||||
|
"plugin:androidx.compose.compiler.plugins.kotlin:$flag=$buildDirPath"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Project.configureTest() {
|
||||||
|
tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
testLogging {
|
||||||
|
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package mihon.buildlogic.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.Task
|
||||||
|
import org.gradle.api.tasks.TaskProvider
|
||||||
|
|
||||||
|
private val emptyResourcesElement = "<resources>\\s*</resources>|<resources/>".toRegex()
|
||||||
|
|
||||||
|
fun Project.getLocalesConfigTask(): TaskProvider<Task> {
|
||||||
|
return tasks.register("generateLocalesConfig") {
|
||||||
|
val locales = fileTree("$projectDir/src/commonMain/moko-resources/")
|
||||||
|
.matching { include("**/strings.xml") }
|
||||||
|
.filterNot { it.readText().contains(emptyResourcesElement) }
|
||||||
|
.map {
|
||||||
|
it.parentFile.name
|
||||||
|
.replace("base", "en")
|
||||||
|
.replace("-r", "-")
|
||||||
|
.replace("+", "-")
|
||||||
|
.takeIf(String::isNotBlank) ?: "en"
|
||||||
|
}
|
||||||
|
.sorted()
|
||||||
|
.joinToString("\n") { "| <locale android:name=\"$it\"/>" }
|
||||||
|
|
||||||
|
val content = """
|
||||||
|
|<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
$locales
|
||||||
|
|</locale-config>
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
|
file("$projectDir/src/androidMain/res/xml/locales_config.xml").apply {
|
||||||
|
parentFile.mkdirs()
|
||||||
|
writeText(content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("mihon.library")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("mihon.library")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("mihon.library")
|
||||||
|
id("app.cash.sqldelight")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
id("app.cash.sqldelight")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("mihon.library")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
import mihon.buildlogic.tasks.getLocalesConfigTask
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform")
|
id("mihon.library")
|
||||||
id("com.android.library")
|
|
||||||
id("dev.icerock.mobile.multiplatform-resources")
|
id("dev.icerock.mobile.multiplatform-resources")
|
||||||
|
kotlin("multiplatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
@ -37,12 +40,12 @@ multiplatformResources {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
val localesConfigTask = registerLocalesConfigTask(project)
|
val localesConfigTask = project.getLocalesConfigTask()
|
||||||
preBuild {
|
preBuild {
|
||||||
dependsOn(localesConfigTask)
|
dependsOn(localesConfigTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
withType<KotlinCompile> {
|
||||||
compilerOptions.freeCompilerArgs.addAll(
|
compilerOptions.freeCompilerArgs.addAll(
|
||||||
listOf(
|
listOf(
|
||||||
"-Xexpect-actual-classes",
|
"-Xexpect-actual-classes",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.test")
|
id("mihon.benchmark")
|
||||||
kotlin("android")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("mihon.library")
|
||||||
|
id("mihon.library.compose")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
kotlin("plugin.compose")
|
kotlin("plugin.compose") // TODO(kotlin2): remove
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
@ -12,6 +13,7 @@ android {
|
||||||
consumerProguardFiles("consumer-rules.pro")
|
consumerProguardFiles("consumer-rules.pro")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(kotlin2): Remove -->
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
}
|
}
|
||||||
|
@ -19,6 +21,7 @@ android {
|
||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
|
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
|
||||||
}
|
}
|
||||||
|
// <-- TODO(kotlin2)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -26,7 +29,7 @@ dependencies {
|
||||||
api(projects.i18n)
|
api(projects.i18n)
|
||||||
|
|
||||||
// Compose
|
// Compose
|
||||||
implementation(platform(compose.bom))
|
implementation(platform(compose.bom)) // TODO(kotlin2): remove
|
||||||
implementation(compose.activity)
|
implementation(compose.activity)
|
||||||
implementation(compose.foundation)
|
implementation(compose.foundation)
|
||||||
implementation(compose.material3.core)
|
implementation(compose.material3.core)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
id("mihon.library")
|
||||||
|
id("mihon.library.compose")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
kotlin("plugin.compose")
|
kotlin("plugin.compose") // TODO(kotlin2): remove
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
@ -11,14 +12,6 @@ android {
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles("consumer-rules.pro")
|
consumerProguardFiles("consumer-rules.pro")
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
|
||||||
compose = true
|
|
||||||
}
|
|
||||||
|
|
||||||
composeOptions {
|
|
||||||
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
|
id("mihon.library")
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
id("com.android.library")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
|
id("mihon.library")
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
id("com.android.library")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
Loading…
Reference in a new issue