tachiyomi-extensions-inspector/server/build.gradle.kts
2022-04-02 10:48:12 -04:00

146 lines
4.2 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 = "4.9.3" // 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.0.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.14.3")
implementation("app.cash.quickjs:quickjs-jvm:0.9.2")
// Source models and interfaces from Tachiyomi 1.x
// using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi
// implementation("tachiyomi.sourceapi:source-api:1.1")
// AndroidCompat
implementation(project(":AndroidCompat"))
implementation(project(":AndroidCompat:Config"))
// uncomment to test extensions directly
// implementation(fileTree("lib/"))
// Testing
testImplementation(kotlin("test-junit5"))
}
val MainClass = "suwayomi.tachidesk.MainKt"
application {
mainClass.set(MainClass)
}
sourceSets {
main {
resources {
srcDir("src/main/resources")
}
}
}
// should be bumped with each stable release
val inspectorVersion = "v0.6.0"
// 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("suwayomi.server")
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
}
}