Add build files for lib-multisrc migration (#1228)

This commit is contained in:
stevenyomi 2024-02-13 14:16:14 +00:00 committed by GitHub
parent da863e3c3f
commit 062d442a52
6 changed files with 108 additions and 3 deletions

View File

@ -3,5 +3,14 @@ plugins {
} }
repositories { repositories {
gradlePluginPortal()
mavenCentral() mavenCentral()
google()
}
dependencies {
implementation(libs.gradle.agp)
implementation(libs.gradle.kotlin)
implementation(libs.gradle.serialization)
implementation(libs.gradle.kotlinter)
} }

View File

@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

View File

@ -0,0 +1,6 @@
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.extra
var ExtensionAware.baseVersionCode: Int
get() = extra.get("baseVersionCode") as Int
set(value) = extra.set("baseVersionCode", value)

View File

@ -0,0 +1,62 @@
plugins {
id("com.android.library")
kotlin("android")
id("kotlinx-serialization")
id("org.jmailen.kotlinter")
}
android {
compileSdk = AndroidConfig.compileSdk
defaultConfig {
minSdk = AndroidConfig.minSdk
}
namespace = "eu.kanade.tachiyomi.multisrc.${project.name}"
sourceSets {
named("main") {
manifest.srcFile("AndroidManifest.xml")
java.setSrcDirs(listOf("src"))
res.setSrcDirs(listOf("res"))
assets.setSrcDirs(listOf("assets"))
}
}
buildFeatures {
resValues = false
shaders = false
}
kotlinOptions {
freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
}
}
kotlinter {
experimentalRules = true
disabledRules = arrayOf(
"experimental:argument-list-wrapping", // Doesn't play well with Android Studio
"experimental:comment-wrapping",
)
}
repositories {
mavenCentral()
}
// TODO: use versionCatalogs.named("libs") in Gradle 8.5
val libs = project.extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
compileOnly(libs.findBundle("common").get())
}
tasks {
preBuild {
dependsOn(lintKotlin)
}
lintKotlin {
dependsOn(formatKotlin)
}
}

View File

@ -8,6 +8,8 @@ assert !ext.has("libVersion")
assert extName.chars().max().asInt < 0x180 : "Extension name should be romanized" assert extName.chars().max().asInt < 0x180 : "Extension name should be romanized"
Project theme = ext.has("themePkg") ? project(":lib-multisrc:$themePkg") : null
android { android {
compileSdk AndroidConfig.compileSdk compileSdk AndroidConfig.compileSdk
@ -25,7 +27,7 @@ android {
minSdk AndroidConfig.minSdk minSdk AndroidConfig.minSdk
targetSdk AndroidConfig.targetSdk targetSdk AndroidConfig.targetSdk
applicationIdSuffix project.parent.name + "." + project.name applicationIdSuffix project.parent.name + "." + project.name
versionCode extVersionCode versionCode theme == null ? extVersionCode : theme.baseVersionCode + overrideVersionCode
versionName "1.4.$versionCode" versionName "1.4.$versionCode"
base { base {
archivesName = "tachiyomi-$applicationIdSuffix-v$versionName" archivesName = "tachiyomi-$applicationIdSuffix-v$versionName"
@ -34,8 +36,18 @@ android {
manifestPlaceholders = [ manifestPlaceholders = [
appName : "Tachiyomi: $extName", appName : "Tachiyomi: $extName",
extClass: extClass, extClass: extClass,
nsfw: project.ext.find("isNsfw") ? 1 : 0, nsfw : project.ext.find("isNsfw") ? 1 : 0,
] ]
String baseUrl = project.ext.find("baseUrl") ?: ""
if (theme != null && !baseUrl.isEmpty()) {
def split = baseUrl.split("://")
assert split.length == 2
def path = split[1].split("/")
manifestPlaceholders += [
SOURCEHOST : path[0],
SOURCESCHEME: split[0],
]
}
} }
signingConfigs { signingConfigs {
@ -88,6 +100,7 @@ repositories {
} }
dependencies { dependencies {
if (theme != null) implementation(theme) // Overrides core launcher icons
implementation(project(":core")) implementation(project(":core"))
compileOnly(libs.bundles.common) compileOnly(libs.bundles.common)
} }

View File

@ -3,6 +3,9 @@ include(":core")
// Load all modules under /lib // Load all modules under /lib
File(rootDir, "lib").eachDir { include("lib:${it.name}") } File(rootDir, "lib").eachDir { include("lib:${it.name}") }
// Load all modules under /lib-multisrc
File(rootDir, "lib-multisrc").eachDir { include("lib-multisrc:${it.name}") }
if (System.getenv("CI") == null || System.getenv("CI_MODULE_GEN") == "true") { if (System.getenv("CI") == null || System.getenv("CI_MODULE_GEN") == "true") {
// Local development (full project build) // Local development (full project build)
@ -88,5 +91,10 @@ fun File.getChunk(chunk: Int, chunkSize: Int): List<File>? {
} }
fun File.eachDir(block: (File) -> Unit) { fun File.eachDir(block: (File) -> Unit) {
listFiles()?.filter { it.isDirectory }?.forEach { block(it) } val files = listFiles() ?: return
for (file in files) {
if (file.isDirectory && file.name != ".gradle" && file.name != "build") {
block(file)
}
}
} }