tachiyomi-extensions-inspector/inspector/build.gradle.kts
2023-09-14 22:24:21 -04:00

137 lines
3.9 KiB
Plaintext

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jmailen.gradle.kotlinter.tasks.FormatTask
import org.jmailen.gradle.kotlinter.tasks.LintTask
import java.io.BufferedReader
plugins {
application
kotlin("jvm")
kotlin("plugin.serialization")
id("org.jmailen.kotlinter")
id("com.github.johnrengelman.shadow")
id("com.github.gmazzo.buildconfig")
}
dependencies {
// okhttp
val okhttpVersion = "5.0.0-alpha.11" // version is locked by Tachiyomi extensions
implementation("com.squareup.okhttp3:okhttp:$okhttpVersion")
implementation("com.squareup.okhttp3:logging-interceptor:$okhttpVersion")
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttpVersion")
implementation("com.squareup.okio:okio:3.3.0")
// dependencies of Tachiyomi extensions, some are duplicate, keeping it here for reference
implementation("com.github.inorichi.injekt:injekt-core:65b0440")
implementation("com.squareup.okhttp3:okhttp:$okhttpVersion")
implementation("io.reactivex:rxjava:1.3.8")
implementation("org.jsoup:jsoup:1.15.3")
implementation("app.cash.quickjs:quickjs-jvm:0.9.2")
// AndroidCompat
implementation(project(":AndroidCompat"))
implementation(project(":AndroidCompat:Config"))
// uncomment to test extensions directly
// implementation(fileTree("lib/"))
}
val MainClass = "inspector.MainKt"
application {
mainClass.set(MainClass)
}
sourceSets {
main {
resources {
srcDir("src/main/resources")
}
}
}
// should be bumped with each stable release
val inspectorVersion = "v1.4.3"
// counts commit count on master
val inspectorRevision = runCatching {
System.getenv("ProductRevision") ?: Runtime
.getRuntime()
.exec("git rev-list HEAD --count")
.let { process ->
process.waitFor()
val output = process.inputStream.use {
it.bufferedReader().use(BufferedReader::readText)
}
process.destroy()
"r" + output.trim()
}
}.getOrDefault("r0")
val String.wrapped get() = """"$this""""
buildConfig {
className("BuildConfig")
packageName("inspector")
useKotlinOutput()
buildConfigField("String", "NAME", rootProject.name.wrapped)
buildConfigField("String", "VERSION", inspectorVersion.wrapped)
buildConfigField("String", "REVISION", inspectorRevision.wrapped)
}
tasks {
shadowJar {
manifest {
attributes(
mapOf(
"Main-Class" to MainClass,
"Implementation-Title" to rootProject.name,
"Implementation-Vendor" to "The Tachiyomi Open Source Project",
"Specification-Version" to inspectorVersion,
"Implementation-Version" to inspectorRevision
)
)
}
archiveBaseName.set(rootProject.name)
archiveVersion.set(inspectorVersion)
archiveClassifier.set(inspectorRevision)
}
withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi",
"-Xopt-in=kotlin.io.path.ExperimentalPathApi",
)
}
}
test {
useJUnit()
}
withType<ShadowJar> {
destinationDirectory.set(File("$rootDir/server/build"))
dependsOn("formatKotlin", "lintKotlin")
}
named("run") {
dependsOn("formatKotlin", "lintKotlin")
}
withType<LintTask> {
source(files("src/kotlin"))
}
withType<FormatTask> {
source(files("src/kotlin"))
}
withType<ProcessResources> {
duplicatesStrategy = DuplicatesStrategy.WARN
}
}