diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c5441955..ef2d64f5b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,7 +108,7 @@ Extensions rely on [extensions-lib](https://github.com/tachiyomiorg/extensions-l ```gradle dependencies { - implementation project(':lib-ratelimit') + implementation(project(':lib-ratelimit')) } ``` @@ -118,7 +118,7 @@ dependencies { ```gradle dependencies { - implementation project(':lib-dataimage') + implementation(project(':lib-dataimage')) } ``` @@ -130,12 +130,12 @@ For example, an extension that needs coroutines, it could add the following: ```gradle dependencies { - compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2' - compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' + compileOnly(libs.bundles.coroutines) } ``` -(Note that several dependencies are already exposed to all extensions via `common-dependencies.gradle`.) +> Note that several dependencies are already exposed to all extensions via Gradle version catalog. +> To view which are available view `libs.versions.toml` under the `gradle` folder Notice that we're using `compileOnly` instead of `implementation`, since the app already contains it. You could use `implementation` instead for a new dependency, or you prefer not to rely on whatever the main app has at the expense of app size. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 3ee68695b..000000000 --- a/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -buildscript { - ext.kotlin_version = '1.4.32' - ext.coroutines_version = '1.4.3' - repositories { - mavenCentral() - google() - maven { url 'https://plugins.gradle.org/m2/' } - } - dependencies { - classpath 'com.android.tools.build:gradle:4.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath 'org.jmailen.gradle:kotlinter-gradle:3.4.0' - } -} - -allprojects { - repositories { - mavenCentral() - google() - maven { url 'https://jitpack.io' } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..221231a1a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,27 @@ +buildscript { + repositories { + mavenCentral() + google() + maven(url = "https://plugins.gradle.org/m2/") + } + dependencies { + val libs = project.extensions.getByType() + .named("libs") as org.gradle.accessors.dm.LibrariesForLibs + classpath(libs.gradle.agp) + classpath(libs.gradle.kotlin) + classpath(libs.gradle.serialization) + classpath(libs.gradle.kotlinter) + } +} + +allprojects { + repositories { + mavenCentral() + google() + maven(url = "https://jitpack.io") + } +} + +tasks.register("clean") { + delete(rootProject.buildDir) +} diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt deleted file mode 100644 index 5a209d904..000000000 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ /dev/null @@ -1,9 +0,0 @@ -object Dependencies { - object kotlin { - const val version = "1.4.32" - const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" - } - - const val jsoup = "org.jsoup:jsoup:1.13.1" - const val okhttp = "com.squareup.okhttp3:okhttp:4.9.1" -} diff --git a/common-dependencies.gradle b/common-dependencies.gradle deleted file mode 100644 index 4c65ceb7e..000000000 --- a/common-dependencies.gradle +++ /dev/null @@ -1,15 +0,0 @@ -// used both in common.gradle and themesources library -dependencies { - // Lib 1.2, but using specific commit so we don't need to bump up the version - compileOnly "com.github.tachiyomiorg:extensions-lib:58b2d3a" - - // These are provided by the app itself - compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - - compileOnly 'com.github.inorichi.injekt:injekt-core:65b0440' - compileOnly 'com.squareup.okhttp3:okhttp:4.9.1' - compileOnly 'io.reactivex:rxjava:1.3.8' - compileOnly 'org.jsoup:jsoup:1.13.1' - compileOnly 'org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.2.0' - compileOnly 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.0' -} diff --git a/common.gradle b/common.gradle index 87d95583a..fa4222513 100644 --- a/common.gradle +++ b/common.gradle @@ -88,9 +88,9 @@ repositories { } dependencies { - implementation project(":core") + implementation(project(":core")) + compileOnly(libs.bundles.common) } -apply from: "$rootDir/common-dependencies.gradle" preBuild.dependsOn(lintKotlin) lintKotlin.dependsOn(formatKotlin) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..a0318d1b9 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,29 @@ +[versions] +kotlin_version = "1.4.32" +coroutines_version = "1.4.3" + +[libraries] +gradle-agp = { module = "com.android.tools.build:gradle", version = "4.2.1" } +gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin_version" } +gradle-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin_version" } +gradle-kotlinter = { module = "org.jmailen.gradle:kotlinter-gradle", version = "3.4.0" } + +tachiyomi-lib = { module = "com.github.tachiyomiorg:extensions-lib", version = "58b2d3a" } + +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin_version" } +kotlin-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version = "1.2.0" } +kotlin-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.2.0" } + +coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines_version" } +coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines_version" } + +injekt-core = { module = "com.github.inorichi.injekt:injekt-core", version = "65b0440" } +jsoup = { module = "org.jsoup:jsoup", version = "1.13.1" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.9.1" } +rxandroid = { module = "io.reactivex:rxandroid", version = "1.2.1" } +rxjava = { module = "io.reactivex:rxjava", version = "1.3.8" } + +[bundles] +common = ["tachiyomi-lib", "jsoup", "okhttp", "kotlin-stdlib", "injekt-core", "rxjava", "kotlin-protobuf", "kotlin-json"] +coroutines = ["coroutines-core", "coroutines-android"] +reactivex = ["rxandroid"] diff --git a/lib/dataimage/build.gradle.kts b/lib/dataimage/build.gradle.kts index 003c09ec1..ccad53c68 100644 --- a/lib/dataimage/build.gradle.kts +++ b/lib/dataimage/build.gradle.kts @@ -17,7 +17,7 @@ repositories { } dependencies { - compileOnly(Dependencies.kotlin.stdlib) - compileOnly(Dependencies.okhttp) - compileOnly(Dependencies.jsoup) + compileOnly(libs.kotlin.stdlib) + compileOnly(libs.okhttp) + compileOnly(libs.jsoup) } diff --git a/lib/ratelimit/build.gradle.kts b/lib/ratelimit/build.gradle.kts index ce110d9d3..38826a541 100644 --- a/lib/ratelimit/build.gradle.kts +++ b/lib/ratelimit/build.gradle.kts @@ -17,6 +17,6 @@ repositories { } dependencies { - compileOnly(Dependencies.kotlin.stdlib) - compileOnly(Dependencies.okhttp) + compileOnly(libs.kotlin.stdlib) + compileOnly(libs.okhttp) } diff --git a/multisrc/build.gradle.kts b/multisrc/build.gradle.kts index 5038992bc..c76a58361 100644 --- a/multisrc/build.gradle.kts +++ b/multisrc/build.gradle.kts @@ -20,18 +20,19 @@ repositories { mavenCentral() } -// dependencies -apply("$rootDir/common-dependencies.gradle") +dependencies { + compileOnly(libs.bundles.common) +} tasks { val generateExtensions by registering { doLast { val isWindows = System.getProperty("os.name").toString().toLowerCase().contains("win") var classPath = (configurations.debugCompileOnly.get().asFileTree.toList() + - listOf( + listOf( configurations.androidApis.get().asFileTree.first().absolutePath, // android.jar path "$projectDir/build/intermediates/aar_main_jar/debug/classes.jar" // jar made from this module - )) + )) .joinToString(if (isWindows) ";" else ":") var javaPath = "${System.getProperty("java.home")}/bin/java" diff --git a/settings.gradle.kts b/settings.gradle.kts index 459698180..6ba62be57 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,5 @@ +enableFeaturePreview("VERSION_CATALOGS") + include(":core") include(":lib-ratelimit") diff --git a/src/all/komga/build.gradle b/src/all/komga/build.gradle index 7f38648b2..35d79ac97 100644 --- a/src/all/komga/build.gradle +++ b/src/all/komga/build.gradle @@ -10,8 +10,7 @@ ext { } dependencies { - compileOnly 'io.reactivex:rxandroid:1.2.1' - compileOnly 'io.reactivex:rxjava:1.3.8' + compileOnly libs.bundles.reactivex } apply from: "$rootDir/common.gradle" diff --git a/src/zh/manhuagui/build.gradle b/src/zh/manhuagui/build.gradle index 24ab41db1..7f125ed9f 100644 --- a/src/zh/manhuagui/build.gradle +++ b/src/zh/manhuagui/build.gradle @@ -10,8 +10,7 @@ ext { } dependencies { - compileOnly "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" - compileOnly "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" + compileOnly libs.bundles.coroutines implementation project(':lib-ratelimit') }