mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Start preparing for multiplatform support
This commit is contained in:
277
build.gradle.kts
277
build.gradle.kts
@@ -1,21 +1,10 @@
|
||||
import Config.migrationCode
|
||||
import Config.serverCode
|
||||
import Config.tachideskVersion
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.jetbrains.compose.compose
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jmailen.gradle.kotlinter.tasks.FormatTask
|
||||
import org.jmailen.gradle.kotlinter.tasks.LintTask
|
||||
import proguard.gradle.ProGuardTask
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.6.10"
|
||||
kotlin("kapt") version "1.6.10"
|
||||
kotlin("plugin.serialization") version "1.6.10"
|
||||
id("org.jetbrains.compose") version "1.0.1"
|
||||
id("com.github.gmazzo.buildconfig") version "3.0.3"
|
||||
id("org.jmailen.kotlinter") version "3.8.0"
|
||||
kotlin("multiplatform") version "1.6.10" apply false
|
||||
kotlin("kapt") version "1.6.10" apply false
|
||||
kotlin("plugin.serialization") version "1.6.10" apply false
|
||||
id("org.jetbrains.compose") version "1.0.1" apply false
|
||||
id("com.github.gmazzo.buildconfig") version "3.0.3" apply false
|
||||
id("org.jmailen.kotlinter") version "3.8.0" apply false
|
||||
id("com.github.ben-manes.versions") version "0.41.0"
|
||||
}
|
||||
|
||||
@@ -30,253 +19,13 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
group = "ca.gosyer"
|
||||
version = "1.2.1"
|
||||
allprojects {
|
||||
group = "ca.gosyer"
|
||||
version = "1.2.1"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// UI (Compose)
|
||||
implementation(compose.desktop.currentOs)
|
||||
implementation(compose.uiTooling)
|
||||
implementation(compose.materialIconsExtended)
|
||||
implementation(compose("org.jetbrains.compose.ui:ui-util"))
|
||||
implementation("ca.gosyer:compose-router:0.24.2-jetbrains-2")
|
||||
implementation("ca.gosyer:accompanist-pager:0.18.1")
|
||||
implementation("ca.gosyer:accompanist-flowlayout:0.18.1")
|
||||
implementation("com.alialbaali.kamel:kamel-image:0.3.0")
|
||||
|
||||
// UI (Swing)
|
||||
implementation("com.github.weisj:darklaf-core:2.7.3")
|
||||
|
||||
// Threading
|
||||
val coroutinesVersion = "1.6.0"
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:$coroutinesVersion")
|
||||
|
||||
// Json
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
|
||||
|
||||
// Xml
|
||||
val xmlutilVersion = "0.83.0"
|
||||
implementation("io.github.pdvrieze.xmlutil:core-jvm:$xmlutilVersion")
|
||||
implementation("io.github.pdvrieze.xmlutil:serialization-jvm:$xmlutilVersion")
|
||||
|
||||
// Dependency Injection
|
||||
val toothpickVersion = "3.1.0"
|
||||
implementation("com.github.stephanenicolas.toothpick:ktp:$toothpickVersion")
|
||||
kapt("com.github.stephanenicolas.toothpick:toothpick-compiler:$toothpickVersion")
|
||||
|
||||
// Http client
|
||||
val ktorVersion = "1.6.7"
|
||||
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-logging:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-auth:$ktorVersion")
|
||||
|
||||
// Logging
|
||||
val slf4jVersion = "1.7.32"
|
||||
implementation("org.slf4j:slf4j-api:$slf4jVersion")
|
||||
implementation("org.slf4j:jul-to-slf4j:$slf4jVersion")
|
||||
val log4jVersion = "2.17.1"
|
||||
implementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
||||
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
|
||||
implementation("org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion")
|
||||
implementation("io.github.microutils:kotlin-logging-jvm:2.1.21")
|
||||
|
||||
// User storage
|
||||
implementation("net.harawata:appdirs:1.2.1")
|
||||
|
||||
// Preferences
|
||||
val multiplatformSettingsVersion = "0.8.1"
|
||||
implementation("com.russhwolf:multiplatform-settings-jvm:$multiplatformSettingsVersion")
|
||||
implementation("com.russhwolf:multiplatform-settings-serialization-jvm:$multiplatformSettingsVersion")
|
||||
implementation("com.russhwolf:multiplatform-settings-coroutines-jvm:$multiplatformSettingsVersion")
|
||||
|
||||
// Utility
|
||||
implementation("io.github.kerubistan.kroki:kroki-coroutines:1.22")
|
||||
|
||||
// Testing
|
||||
testImplementation(kotlin("test-junit"))
|
||||
testImplementation(compose("org.jetbrains.compose.ui:ui-test-junit4"))
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = Config.jvmTarget
|
||||
targetCompatibility = Config.jvmTarget
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<KotlinCompile> {
|
||||
dependsOn(formatKotlinMain)
|
||||
kotlinOptions {
|
||||
jvmTarget = Config.jvmTarget.toString()
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xopt-in=kotlin.RequiresOptIn",
|
||||
"-Xopt-in=kotlin.time.ExperimentalTime",
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
"-Xopt-in=com.russhwolf.settings.ExperimentalSettingsApi",
|
||||
"-Xopt-in=com.russhwolf.settings.ExperimentalSettingsImplementation",
|
||||
"-Xopt-in=com.google.accompanist.pager.ExperimentalPagerApi",
|
||||
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
||||
"-Xopt-in=androidx.compose.material.ExperimentalMaterialApi",
|
||||
"-Xopt-in=androidx.compose.ui.ExperimentalComposeUiApi"
|
||||
)
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
|
||||
withType<Jar> {
|
||||
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
|
||||
}
|
||||
|
||||
withType<LintTask> {
|
||||
source(files("src"))
|
||||
exclude("ca/gosyer/build")
|
||||
}
|
||||
|
||||
withType<FormatTask> {
|
||||
source(files("src"))
|
||||
exclude("ca/gosyer/build")
|
||||
}
|
||||
|
||||
registerTachideskTasks(project)
|
||||
|
||||
task("generateResourceConstants") {
|
||||
val buildResources = buildConfig.forClass(project.group.toString()+ ".build", "BuildResources")
|
||||
|
||||
doFirst {
|
||||
val langs = listOf("en") + sourceSets["main"].resources
|
||||
.filter { it.name == "strings.xml" }
|
||||
.drop(1)
|
||||
.map { it.absolutePath.substringAfter("values-").substringBefore(File.separatorChar) }
|
||||
buildResources.buildConfigField("Array<String>", "LANGUAGES", langs.joinToString(prefix = "arrayOf(", postfix = ")") { it.wrap() })
|
||||
}
|
||||
|
||||
generateBuildConfig {
|
||||
dependsOn(this@task)
|
||||
}
|
||||
}
|
||||
withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
|
||||
rejectVersionIf {
|
||||
isNonStable(candidate.version) && !isNonStable(currentVersion)
|
||||
}
|
||||
}
|
||||
register<ProGuardTask>("optimizeUberJar") {
|
||||
group = "compose desktop"
|
||||
val packageUberJarForCurrentOS = getByName("packageUberJarForCurrentOS")
|
||||
dependsOn(packageUberJarForCurrentOS)
|
||||
val uberJars = packageUberJarForCurrentOS.outputs.files
|
||||
injars(uberJars)
|
||||
outjars(
|
||||
uberJars.map { file ->
|
||||
File(file.parentFile, "min/" + file.name)
|
||||
}
|
||||
)
|
||||
val javaHome = System.getProperty("java.home")
|
||||
if (JavaVersion.current().isJava9Compatible) {
|
||||
libraryjars("$javaHome/jmods")
|
||||
} else {
|
||||
libraryjars("$javaHome/lib/rt.jar")
|
||||
libraryjars("$javaHome/lib/jce.jar")
|
||||
}
|
||||
configuration("proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
|
||||
fun isNonStable(version: String): Boolean {
|
||||
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
|
||||
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
|
||||
val isStable = stableKeyword || regex.matches(version)
|
||||
return isStable.not()
|
||||
}
|
||||
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
mainClass = "ca.gosyer.ui.main.MainKt"
|
||||
nativeDistributions {
|
||||
targetFormats(
|
||||
// Windows
|
||||
TargetFormat.Msi,
|
||||
TargetFormat.Exe,
|
||||
// Linux
|
||||
TargetFormat.Deb,
|
||||
TargetFormat.Rpm,
|
||||
// MacOS
|
||||
TargetFormat.Dmg
|
||||
)
|
||||
modules(
|
||||
"java.compiler",
|
||||
"java.instrument",
|
||||
"java.management",
|
||||
"java.naming",
|
||||
"java.prefs",
|
||||
"java.rmi",
|
||||
"java.scripting",
|
||||
"java.sql",
|
||||
"jdk.crypto.ec",
|
||||
"jdk.unsupported"
|
||||
)
|
||||
|
||||
packageName = "Tachidesk-JUI"
|
||||
description = "Tachidesk-JUI is a Jvm client for a Tachidesk Server"
|
||||
copyright = "Mozilla Public License v2.0"
|
||||
vendor = "Suwayomi"
|
||||
windows {
|
||||
dirChooser = true
|
||||
upgradeUuid = "B2ED947E-81E4-4258-8388-2B1EDF5E0A30"
|
||||
shortcut = true
|
||||
menu = true
|
||||
iconFile.set(project.file("resources/icon.ico"))
|
||||
menuGroup = "Suwayomi"
|
||||
}
|
||||
macOS {
|
||||
bundleID = "ca.gosyer.tachideskjui"
|
||||
packageName = rootProject.name
|
||||
iconFile.set(project.file("resources/icon.icns"))
|
||||
}
|
||||
linux {
|
||||
iconFile.set(project.file("resources/icon.png"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.wrap() = """"$this""""
|
||||
buildConfig {
|
||||
className("BuildConfig")
|
||||
packageName(project.group.toString() + ".build")
|
||||
useKotlinOutput { internalVisibility = true }
|
||||
|
||||
buildConfigField("String", "NAME", project.name.wrap())
|
||||
buildConfigField("String", "VERSION", project.version.toString().wrap())
|
||||
buildConfigField("int", "MIGRATION_CODE", migrationCode.toString())
|
||||
buildConfigField("boolean", "DEBUG", project.hasProperty("debugApp").toString())
|
||||
buildConfigField("boolean", "IS_PREVIEW", project.hasProperty("preview").toString())
|
||||
buildConfigField("int", "PREVIEW_BUILD", project.properties["preview"]?.toString()?.trim('"') ?: 0.toString())
|
||||
|
||||
// Tachidesk
|
||||
buildConfigField("String", "TACHIDESK_SP_VERSION", tachideskVersion.wrap())
|
||||
buildConfigField("int", "SERVER_CODE", serverCode.toString())
|
||||
}
|
||||
|
||||
kotlinter {
|
||||
experimentalRules = true
|
||||
disabledRules = arrayOf("experimental:argument-list-wrapping", "experimental:trailing-comma")
|
||||
}
|
||||
|
||||
kapt {
|
||||
includeCompileClasspath = false
|
||||
}
|
||||
Reference in New Issue
Block a user