From 5f4c7454eeab71587ded5fd0f136af3a1d371046 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Mon, 3 May 2021 13:49:09 -0400 Subject: [PATCH] Update everything (#68) * Update everything, cleanup build.gradle.kts's * Make requested changes --- .../Config/{build.gradle => build.gradle.kts} | 0 AndroidCompat/build.gradle.kts | 1 - build.gradle.kts | 28 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- server/build.gradle.kts | 220 +++++++++--------- .../impl/backup/legacy/LegacyBackupImport.kt | 6 +- .../backup/legacy/LegacyBackupValidator.kt | 2 +- .../armor/tachidesk/server/util/SystemTray.kt | 27 +-- 8 files changed, 143 insertions(+), 143 deletions(-) rename AndroidCompat/Config/{build.gradle => build.gradle.kts} (100%) diff --git a/AndroidCompat/Config/build.gradle b/AndroidCompat/Config/build.gradle.kts similarity index 100% rename from AndroidCompat/Config/build.gradle rename to AndroidCompat/Config/build.gradle.kts diff --git a/AndroidCompat/build.gradle.kts b/AndroidCompat/build.gradle.kts index d9bfa3d..20acf2f 100644 --- a/AndroidCompat/build.gradle.kts +++ b/AndroidCompat/build.gradle.kts @@ -6,7 +6,6 @@ plugins { repositories { mavenCentral() - jcenter() maven { url = uri("https://jitpack.io") } diff --git a/build.gradle.kts b/build.gradle.kts index 3a1bc60..055277f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,7 @@ -import org.jetbrains.kotlin.config.KotlinCompilerVersion +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("org.jetbrains.kotlin.jvm") version "1.4.21" apply false // Also in buildSrc Config.kt - id("java") + kotlin("jvm") version "1.4.32" } allprojects { @@ -11,7 +10,6 @@ allprojects { version = "1.0" repositories { - jcenter() mavenCentral() maven("https://maven.google.com/") maven("https://jitpack.io") @@ -28,7 +26,6 @@ val projects = listOf( ) configure(projects) { - apply(plugin = "java") apply(plugin = "org.jetbrains.kotlin.jvm") java { @@ -36,33 +33,32 @@ configure(projects) { targetCompatibility = JavaVersion.VERSION_1_8 } - tasks.withType { + tasks.withType { kotlinOptions { - jvmTarget = "1.8" + jvmTarget = JavaVersion.VERSION_1_8.toString() } } dependencies { // Kotlin - implementation(kotlin("stdlib", KotlinCompilerVersion.VERSION)) - implementation(kotlin("stdlib", KotlinCompilerVersion.VERSION)) - implementation(kotlin("reflect", version = "1.4.21")) - testImplementation(kotlin("test", version = "1.4.21")) + implementation(kotlin("stdlib")) + implementation(kotlin("reflect")) + testImplementation(kotlin("test")) // coroutines - val coroutinesVersion = "1.4.2" + val coroutinesVersion = "1.4.3" implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") // Dependency Injection - implementation("org.kodein.di:kodein-di-conf-jvm:7.1.0") + implementation("org.kodein.di:kodein-di-conf-jvm:7.5.0") // Logging implementation("org.slf4j:slf4j-api:1.7.30") implementation("ch.qos.logback:logback-classic:1.2.3") - implementation("io.github.microutils:kotlin-logging:2.0.3") + implementation("io.github.microutils:kotlin-logging:2.0.6") // RxJava implementation("io.reactivex:rxjava:1.3.8") @@ -73,11 +69,11 @@ configure(projects) { // dependency of :AndroidCompat:Config - implementation("com.typesafe:config:1.4.0") + implementation("com.typesafe:config:1.4.1") implementation("io.github.config4k:config4k:0.4.2") // to get application content root - implementation("net.harawata:appdirs:1.2.0") + implementation("net.harawata:appdirs:1.2.1") // dex2jar: https://github.com/DexPatcher/dex2jar/releases/tag/v2.1-20190905-lanchon implementation("com.github.DexPatcher.dex2jar:dex-tools:v2.1-20190905-lanchon") diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f3fdbc..3c4101c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 67ecfb8..43e05d1 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -1,12 +1,14 @@ 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 { -// id("org.jetbrains.kotlin.jvm") version "1.4.21" application - id("com.github.johnrengelman.shadow") version "6.1.0" - id("org.jmailen.kotlinter") version "3.3.0" - id("edu.sc.seis.launch4j") version "2.4.9" + id("com.github.johnrengelman.shadow") version "7.0.0" + id("org.jmailen.kotlinter") version "3.4.3" + id("edu.sc.seis.launch4j") version "2.5.0" id("de.fuerstenau.buildconfig") version "1.1.8" } @@ -14,7 +16,6 @@ val TachideskVersion = "v0.3.0" repositories { mavenCentral() - jcenter() maven { url = uri("https://jitpack.io") } @@ -22,7 +23,7 @@ repositories { dependencies { // implementation(platform("org.jetbrains.kotlin:kotlin-bom")) - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation(kotlin("stdlib-jdk8")) // Source models and interfaces from Tachiyomi 1.x // using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi @@ -34,10 +35,10 @@ dependencies { 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:2.9.0") + implementation("com.squareup.okio:okio:2.10.0") - // retrofit + // Retrofit val retrofitVersion = "2.9.0" implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0") @@ -45,13 +46,10 @@ dependencies { implementation("com.squareup.retrofit2:adapter-rxjava:$retrofitVersion") - // reactivex + // Reactivex implementation("io.reactivex:rxjava:1.3.8") -// implementation("io.reactivex:rxandroid:1.2.1") -// implementation("com.jakewharton.rxrelay:rxrelay:1.2.0") -// implementation("com.github.pwittchen:reactivenetwork:0.13.0") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.0") implementation("com.google.code.gson:gson:2.8.6") implementation("com.github.salomonbrys.kotson:kotson:2.5.0") @@ -60,18 +58,19 @@ dependencies { // api - implementation("io.javalin:javalin:3.12.0") - implementation("com.fasterxml.jackson.core:jackson-databind:2.10.3") + implementation("io.javalin:javalin:3.13.6") + implementation("com.fasterxml.jackson.core:jackson-databind:2.12.3") // Exposed ORM - val exposedVersion = "0.28.1" + val exposedVersion = "0.31.1" implementation("org.jetbrains.exposed:exposed-core:$exposedVersion") implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion") implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion") - implementation("com.h2database:h2:1.4.199") + implementation("com.h2database:h2:1.4.200") // tray icon - implementation("com.dorkbox:SystemTray:3.17") + implementation("com.dorkbox:SystemTray:4.1") + implementation("com.dorkbox:Utilities:1.9") // AndroidCompat @@ -85,12 +84,9 @@ dependencies { testImplementation(kotlin("test-junit5")) } -val name = "ir.armor.tachidesk.Main" +val MainClass = "ir.armor.tachidesk.Main" application { - mainClass.set(name) - - // Required by ShadowJar. - mainClassName = name + mainClass.set(MainClass) } sourceSets { @@ -114,24 +110,47 @@ val TachideskRevision = Runtime } +buildConfig { + appName = rootProject.name + clsName = "BuildConfig" + packageName = "ir.armor.tachidesk.server" + version = TachideskVersion + + + buildConfigField("String", "name", rootProject.name) + buildConfigField("String", "version", TachideskVersion) + buildConfigField("String", "revision", TachideskRevision) + buildConfigField("boolean", "debug", project.hasProperty("debugApp").toString()) +} + +launch4j { //used for windows + mainClassName = MainClass + bundledJrePath = "jre" + bundledJre64Bit = true + jreMinVersion = "8" + outputDir = "${rootProject.name}-$TachideskVersion-$TachideskRevision-win32" + icon = "${projectDir}/src/main/resources/icon/faviconlogo.ico" + jar = "${projectDir}/build/${rootProject.name}-$TachideskVersion-$TachideskRevision.jar" +} + tasks { jar { manifest { attributes( mapOf( - "Main-Class" to "com.example.MainKt", //will make your jar (produced by jar task) runnable - "ImplementationTitle" to project.name, - "Implementation-Version" to project.version) + "Main-Class" to MainClass, //will make your jar (produced by jar task) runnable + "Implementation-Title" to rootProject.name, + "Implementation-Version" to "$TachideskVersion-$TachideskRevision") ) } } shadowJar { manifest.inheritFrom(jar.get().manifest) //will make your shadowJar (produced by jar task) runnable - archiveBaseName.set("Tachidesk") + archiveBaseName.set(rootProject.name) archiveVersion.set(TachideskVersion) archiveClassifier.set(TachideskRevision) } - withType { + withType { kotlinOptions { freeCompilerArgs = listOf( "-Xopt-in=kotlin.RequiresOptIn", @@ -143,85 +162,74 @@ tasks { test { useJUnit() } -} -launch4j { //used for windows - mainClassName = name - bundledJrePath = "jre" - bundledJre64Bit = true - jreMinVersion = "8" - outputDir = "Tachidesk-$TachideskVersion-$TachideskRevision-win32" - icon = "${projectDir}/src/main/resources/icon/faviconlogo.ico" - jar = "${projectDir}/build/Tachidesk-$TachideskVersion-$TachideskRevision.jar" -} - -tasks.register("windowsPackage") { - from(fileTree("$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32")) - destinationDirectory.set(File("$buildDir")) - archiveFileName.set("Tachidesk-$TachideskVersion-$TachideskRevision-win32.zip") - dependsOn("windowsPackageWorkaround2") -} - -tasks.register("windowsPackageWorkaround2") { - delete( - "$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32/jre", - "$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32/lib", - "$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32/server.exe", - "$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32/Tachidesk-$TachideskVersion-$TachideskRevision-win32/Tachidesk-$TachideskVersion-$TachideskRevision-win32" - ) - dependsOn("windowsPackageWorkaround") -} - -tasks.register("windowsPackageWorkaround") { - from("$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32") - into("$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32/Tachidesk-$TachideskVersion-$TachideskRevision-win32") - dependsOn("deleteUnwantedJreDir") -} - -tasks.register("deleteUnwantedJreDir") { - delete( - "$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32/jdk8u282-b08-jre" - ) - dependsOn("addJreToDistributable") -} - -tasks.register("addJreToDistributable") { - from(zipTree("$buildDir/OpenJDK8U-jre_x86-32_windows_hotspot_8u282b08.zip")) - into("$buildDir/Tachidesk-$TachideskVersion-$TachideskRevision-win32") - eachFile { - path = path.replace(".*-jre".toRegex(),"jre") + register("windowsPackage") { + from(fileTree("$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32")) + destinationDirectory.set(File("$buildDir")) + archiveFileName.set("${rootProject.name}-$TachideskVersion-$TachideskRevision-win32.zip") + dependsOn("windowsPackageWorkaround2") + } + + register("windowsPackageWorkaround2") { + delete( + "$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32/jre", + "$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32/lib", + "$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32/server.exe", + "$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32/Tachidesk-$TachideskVersion-$TachideskRevision-win32/Tachidesk-$TachideskVersion-$TachideskRevision-win32" + ) + dependsOn("windowsPackageWorkaround") + } + + register("windowsPackageWorkaround") { + from("$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32") + into("$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32") + dependsOn("deleteUnwantedJreDir") + } + + register("deleteUnwantedJreDir") { + delete( + "$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32/jdk8u282-b08-jre" + ) + dependsOn("addJreToDistributable") + } + + register("addJreToDistributable") { + from(zipTree("$buildDir/OpenJDK8U-jre_x86-32_windows_hotspot_8u282b08.zip")) + into("$buildDir/${rootProject.name}-$TachideskVersion-$TachideskRevision-win32") + eachFile { + path = path.replace(".*-jre".toRegex(),"jre") + } + dependsOn("downloadJre") + dependsOn("createExe") + } + + register("downloadJre") { + src("https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jre_x86-32_windows_hotspot_8u282b08.zip") + dest(buildDir) + overwrite(false) + onlyIfModified(true) + } + + withType { + destinationDirectory.set(File("$rootDir/server/build")) + dependsOn("formatKotlin", "lintKotlin") + } + + named("run") { + dependsOn("formatKotlin", "lintKotlin") + } + + named("processResources") { + duplicatesStrategy = DuplicatesStrategy.WARN + mustRunAfter(":webUI:copyBuild") + } + + withType { + source(files("src")) + } + + withType { + source(files("src")) } - dependsOn("downloadJre") - dependsOn("createExe") } -tasks.register("downloadJre") { - src("https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jre_x86-32_windows_hotspot_8u282b08.zip") - dest(buildDir) - overwrite(false) - onlyIfModified(true) -} - -tasks.withType { - destinationDirectory.set(File("$rootDir/server/build")) - dependsOn("formatKotlin", "lintKotlin") -} - -tasks.named("run") { - dependsOn("formatKotlin", "lintKotlin") -} - -tasks.named("processResources") { - mustRunAfter(":webUI:copyBuild") -} - -buildConfig { - version = TachideskVersion - buildConfigField("String", "version", TachideskVersion) - buildConfigField("String", "revision", TachideskRevision) - - clsName = "BuildConfig" - packageName = "ir.armor.tachidesk.server" - - buildConfigField("boolean", "DEBUG", project.hasProperty("debugApp").toString()) -} diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupImport.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupImport.kt index b17a2c3..588c6ad 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupImport.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupImport.kt @@ -9,8 +9,8 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.SManga import ir.armor.tachidesk.impl.Category.createCategory import ir.armor.tachidesk.impl.Category.getCategoryList -import ir.armor.tachidesk.impl.backup.legacy.LegacyBackupRestoreValidator.ValidationResult -import ir.armor.tachidesk.impl.backup.legacy.LegacyBackupRestoreValidator.validate +import ir.armor.tachidesk.impl.backup.legacy.LegacyBackupValidator.ValidationResult +import ir.armor.tachidesk.impl.backup.legacy.LegacyBackupValidator.validate import ir.armor.tachidesk.impl.backup.legacy.models.Backup import ir.armor.tachidesk.impl.backup.legacy.models.DHistory import ir.armor.tachidesk.impl.backup.models.CategoryImpl @@ -54,7 +54,7 @@ object LegacyBackupImport : LegacyBackupBase() { json.get(Backup.CATEGORIES)?.let { restoreCategories(it) } // Store source mapping for error messages - sourceMapping = LegacyBackupRestoreValidator.getSourceMapping(json) + sourceMapping = LegacyBackupValidator.getSourceMapping(json) // Restore individual manga mangasJson.forEach { diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupValidator.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupValidator.kt index e6c61ea..1a97262 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupValidator.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/backup/legacy/LegacyBackupValidator.kt @@ -13,7 +13,7 @@ import ir.armor.tachidesk.model.database.SourceTable import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.transactions.transaction -object LegacyBackupRestoreValidator { +object LegacyBackupValidator { data class ValidationResult(val missingSources: List, val missingTrackers: List) /** diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/util/SystemTray.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/util/SystemTray.kt index e8ced2e..0cdd907 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/util/SystemTray.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/util/SystemTray.kt @@ -13,9 +13,9 @@ import dorkbox.systemTray.SystemTray.TrayType import dorkbox.util.CacheUtil import dorkbox.util.Desktop import ir.armor.tachidesk.Main +import ir.armor.tachidesk.server.BuildConfig import ir.armor.tachidesk.server.serverConfig -import java.awt.event.ActionListener -import java.io.IOException +import kotlin.system.exitProcess fun openInBrowser() { try { @@ -32,22 +32,17 @@ fun systemTray(): SystemTray? { if (System.getProperty("os.name").startsWith("Windows")) SystemTray.FORCE_TRAY_TYPE = TrayType.Swing - CacheUtil.clear() + CacheUtil.clear(BuildConfig.name) - val systemTray = SystemTray.get() ?: return null + val systemTray = SystemTray.get(BuildConfig.name) ?: return null val mainMenu = systemTray.menu mainMenu.add( MenuItem( - "Open Tachidesk", - ActionListener { - try { - Desktop.browseURL("http://127.0.0.1:4567") - } catch (e: IOException) { - e.printStackTrace() - } - } - ) + "Open Tachidesk" + ) { + openInBrowser() + } ) val icon = Main::class.java.getResource("/icon/faviconlogo.png") @@ -56,13 +51,15 @@ fun systemTray(): SystemTray? { systemTray.setImage(icon) // systemTray.status = "No Mail" - systemTray.getMenu().add( + mainMenu.add( MenuItem("Quit") { systemTray.shutdown() - System.exit(0) + exitProcess(0) } ) + systemTray.installShutdownHook() + return systemTray } catch (e: Exception) { e.printStackTrace()