Re: Use Gradle version catalog to simplify dependencies (#10953)
* Use Gradle version catalog to simplify dependencies * Changes based on review comments * Remove libs variables in buildScript - Not needed in this Gradle version
This commit is contained in:
parent
a83919a98a
commit
5145eec280
|
@ -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.
|
||||
|
||||
|
|
27
build.gradle
27
build.gradle
|
@ -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
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven(url = "https://plugins.gradle.org/m2/")
|
||||
}
|
||||
dependencies {
|
||||
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<Delete>("clean") {
|
||||
delete(rootProject.buildDir)
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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'
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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"]
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(Dependencies.kotlin.stdlib)
|
||||
compileOnly(Dependencies.okhttp)
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
compileOnly(libs.okhttp)
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
// dependencies
|
||||
apply("$rootDir/common-dependencies.gradle")
|
||||
dependencies {
|
||||
compileOnly(libs.bundles.common)
|
||||
}
|
||||
|
||||
tasks {
|
||||
val generateExtensions by registering {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
enableFeaturePreview("VERSION_CATALOGS")
|
||||
|
||||
include(":core")
|
||||
|
||||
include(":lib-ratelimit")
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue