Skip to content

Commit

Permalink
Migrate to version catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Jun 22, 2024
1 parent 201bd8d commit 601ab2e
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 145 deletions.
15 changes: 9 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import com.kizitonwose.calendar.buildsrc.Plugins

plugins {
with(com.kizitonwose.calendar.buildsrc.Plugins) {
applyRootPlugins()
}
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.kotlinJvm) apply false
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.composeCompiler) apply false
alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.versionCheck)
}

allprojects {
apply(plugin = Plugins.kotlinter)
apply(plugin = rootProject.libs.plugins.kotlinter.get().pluginId)
}

tasks.register<Delete>("clean").configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package com.kizitonwose.calendar.buildsrc

import org.gradle.api.JavaVersion
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.PluginDependenciesSpecScope
import kotlin.math.max

object Config {
Expand All @@ -19,75 +18,3 @@ object Android {
const val targetSdk = 34
const val compileSdk = 34
}

object Plugins {
private const val agpVersion = "8.5.0"
const val androidApp = "com.android.application"
const val androidLibrary = "com.android.library"
const val kotlinJvm = "org.jetbrains.kotlin.jvm"
const val kotlinAndroid = "org.jetbrains.kotlin.android"
const val kotlinter = "org.jmailen.kotlinter"
const val mavenPublish = "com.vanniktech.maven.publish"
const val versionCheck = "com.github.ben-manes.versions"
const val composeCompiler = "org.jetbrains.kotlin.plugin.compose"

fun PluginDependenciesSpecScope.applyRootPlugins() {
id(androidApp).version(agpVersion).apply(false)
id(androidLibrary).version(agpVersion).apply(false)
id(kotlinAndroid).version(Kotlin.version).apply(false)
id(composeCompiler).version(Kotlin.version).apply(false)
id(kotlinter).version("4.3.0").apply(false)
id(mavenPublish).version("0.28.0").apply(false)
id(versionCheck).version("0.51.0").apply(true)
}
}

object Kotlin {
internal const val version = "2.0.0"
const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
}

object Libs {
object Core {
const val deSugar = "com.android.tools:desugar_jdk_libs:2.0.4"

object Test {
const val junit = "junit:junit:4.13.2"
}
}

object View {
const val legacySupport = "androidx.legacy:legacy-support-v4:1.0.0"
const val appCompat = "androidx.appcompat:appcompat:1.6.1"
const val coreKtx = "androidx.core:core-ktx:1.13.1"
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.4"
const val cardView = "androidx.cardview:cardview:1.0.0"
const val recyclerView = "androidx.recyclerview:recyclerview:1.3.2"
const val material = "com.google.android.material:material:1.12.0"

object Test {
private const val espressoVersion = "3.5.1"
const val espressoCore = "androidx.test.espresso:espresso-core:$espressoVersion"
const val espressoContrib = "androidx.test.espresso:espresso-contrib:$espressoVersion"
const val runner = "androidx.test:runner:1.5.2"
const val rules = "androidx.test:rules:1.5.0"
const val extJunit = "androidx.test.ext:junit:1.1.5"
}
}

object Compose {
private const val composeVersion = "1.7.0-beta03"
const val ui = "androidx.compose.ui:ui:$composeVersion"
const val foundation = "androidx.compose.foundation:foundation:$composeVersion"
const val tooling = "androidx.compose.ui:ui-tooling:$composeVersion"
const val runtime = "androidx.compose.runtime:runtime:$composeVersion"
const val material = "androidx.compose.material:material:$composeVersion"
const val activity = "androidx.activity:activity-compose:1.9.0"
const val navigation = "androidx.navigation:navigation-compose:2.7.7"

object Test {
const val uiJunit = "androidx.compose.ui:ui-test-junit4:$composeVersion"
const val uiManifest = "androidx.compose.ui:ui-test-manifest:$composeVersion"
}
}
}
24 changes: 11 additions & 13 deletions compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@

import com.kizitonwose.calendar.buildsrc.Android
import com.kizitonwose.calendar.buildsrc.Config
import com.kizitonwose.calendar.buildsrc.Kotlin
import com.kizitonwose.calendar.buildsrc.Libs

plugins {
with(com.kizitonwose.calendar.buildsrc.Plugins) {
id(androidLibrary)
id(kotlinAndroid)
id(composeCompiler)
id(mavenPublish)
}
alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.mavenPublish)
}

android {
Expand All @@ -36,11 +33,12 @@ android {
dependencies {
api(project(":core"))
implementation(project(":data"))
implementation(Kotlin.stdLib)
implementation(libs.kotlin.stdlib)

implementation(Libs.Compose.ui)
implementation(Libs.Compose.tooling)
implementation(Libs.Compose.foundation)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.foundation)
implementation(libs.compose.runtime)

testImplementation(Libs.Core.Test.junit)
testImplementation(libs.test.junit)
}
9 changes: 3 additions & 6 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import com.kizitonwose.calendar.buildsrc.Config
import com.kizitonwose.calendar.buildsrc.Libs

plugins {
with(com.kizitonwose.calendar.buildsrc.Plugins) {
id(kotlinJvm)
id(mavenPublish)
}
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.mavenPublish)
}

java {
Expand All @@ -21,5 +18,5 @@ kotlin {
}

dependencies {
implementation(Libs.Compose.runtime) // Only needed for @Immutable annotation.
implementation(libs.compose.runtime) // Only needed for @Immutable annotation.
}
13 changes: 5 additions & 8 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

import com.kizitonwose.calendar.buildsrc.Config
import com.kizitonwose.calendar.buildsrc.Kotlin
import com.kizitonwose.calendar.buildsrc.Libs

plugins {
with(com.kizitonwose.calendar.buildsrc.Plugins) {
id(kotlinJvm)
id(mavenPublish)
}
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.mavenPublish)
}

java {
Expand All @@ -23,7 +20,7 @@ kotlin {

dependencies {
implementation(project(":core"))
implementation(Kotlin.stdLib)
implementation(libs.kotlin.stdlib)

testImplementation(Libs.Core.Test.junit)
testImplementation(libs.test.junit)
}
44 changes: 44 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[versions]
agp = "8.5.0"
kotlin = "2.0.0"
compose = "1.7.0-beta03"
espresso = "3.5.1"

[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
desugar = { module = "com.android.tools:desugar_jdk_libs", version = "2.0.4" }

androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.13.1" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version = "2.1.4" }
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.3.2" }
androidx-cardview = { module = "androidx.cardview:cardview", version = "1.0.0" }
material-view = { module = "com.google.android.material:material", version = "1.12.0" }

androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
androidx-test-espresso-contrib = { module = "androidx.test.espresso:espresso-contrib", version.ref = "espresso" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.5.2" }
androidx-test-rules = { module = "androidx.test:rules", version = "1.5.0" }
androidx-test-junit = { module = "androidx.test.ext:junit", version = "1.1.5" }
test-junit = { module = "junit:junit", version = "4.13.2" }

compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" }
compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
compose-activity = { module = "androidx.activity:activity-compose", version = "1.9.0" }
compose-navigation = { module = "androidx.navigation:navigation-compose", version = "2.7.7" }

compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinter = { id = "org.jmailen.kotlinter", version = "4.3.0" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.28.0" }
versionCheck = { id = "com.github.ben-manes.versions", version = "0.51.0" }
54 changes: 25 additions & 29 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

import com.kizitonwose.calendar.buildsrc.Android
import com.kizitonwose.calendar.buildsrc.Config
import com.kizitonwose.calendar.buildsrc.Kotlin
import com.kizitonwose.calendar.buildsrc.Libs

plugins {
with(com.kizitonwose.calendar.buildsrc.Plugins) {
id(androidApp)
id(kotlinAndroid)
id(composeCompiler)
}
alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.composeCompiler)
}

android {
Expand Down Expand Up @@ -50,31 +46,31 @@ android {
dependencies {
implementation(project(":view"))
implementation(project(":compose"))
coreLibraryDesugaring(Libs.Core.deSugar)
implementation(Kotlin.stdLib)
coreLibraryDesugaring(libs.desugar)
implementation(libs.kotlin.stdlib)

implementation(Libs.View.legacySupport)
implementation(Libs.View.appCompat)
implementation(Libs.View.coreKtx)
implementation(Libs.View.constraintLayout)
implementation(Libs.View.cardView)
implementation(Libs.View.material)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.cardview)
implementation(libs.material.view)

implementation(Libs.Compose.ui)
implementation(Libs.Compose.tooling)
implementation(Libs.Compose.foundation)
implementation(Libs.Compose.material)
implementation(Libs.Compose.activity)
implementation(Libs.Compose.navigation)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.foundation)
implementation(libs.compose.runtime)
implementation(libs.compose.material)
implementation(libs.compose.activity)
implementation(libs.compose.navigation)

testImplementation(Libs.Core.Test.junit)
testImplementation(libs.test.junit)

androidTestImplementation(Libs.View.Test.espressoCore)
androidTestImplementation(Libs.View.Test.espressoContrib) // RecyclerView actions.
androidTestImplementation(Libs.View.Test.runner)
androidTestImplementation(Libs.View.Test.rules)
androidTestImplementation(Libs.View.Test.extJunit)
androidTestImplementation(libs.androidx.test.espresso.core)
androidTestImplementation(libs.androidx.test.espresso.contrib) // RecyclerView actions.
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.androidx.test.rules)
androidTestImplementation(libs.androidx.test.junit)

androidTestImplementation(Libs.Compose.Test.uiJunit)
debugImplementation(Libs.Compose.Test.uiManifest) // Compose test runner activity
androidTestImplementation(libs.compose.ui.test.junit4)
debugImplementation(libs.compose.ui.test.manifest) // Compose test runner activity
}
16 changes: 6 additions & 10 deletions view/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import com.kizitonwose.calendar.buildsrc.Android
import com.kizitonwose.calendar.buildsrc.Config
import com.kizitonwose.calendar.buildsrc.Kotlin
import com.kizitonwose.calendar.buildsrc.Libs

plugins {
with(com.kizitonwose.calendar.buildsrc.Plugins) {
id(androidLibrary)
id(kotlinAndroid)
id(mavenPublish)
}
alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.mavenPublish)
}

android {
Expand All @@ -32,9 +28,9 @@ android {
dependencies {
api(project(":core"))
implementation(project(":data"))
implementation(Kotlin.stdLib)
implementation(Libs.View.coreKtx)
implementation(libs.kotlin.stdlib)
implementation(libs.androidx.core.ktx)

// Expose RecyclerView which is CalendarView"s superclass.
api(Libs.View.recyclerView)
api(libs.androidx.recyclerview)
}

0 comments on commit 601ab2e

Please sign in to comment.