diff --git a/build.gradle.kts b/build.gradle.kts index 3574324b..39482b65 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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("clean").configure { diff --git a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt index 73575d3b..af701d2f 100644 --- a/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt +++ b/buildSrc/src/main/java/com/kizitonwose/calendar/buildsrc/Dependencies.kt @@ -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 { @@ -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" - } - } -} diff --git a/compose/build.gradle.kts b/compose/build.gradle.kts index cd7b22db..29967417 100644 --- a/compose/build.gradle.kts +++ b/compose/build.gradle.kts @@ -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 { @@ -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) } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index daf1333c..5be90b00 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -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 { @@ -21,5 +18,5 @@ kotlin { } dependencies { - implementation(Libs.Compose.runtime) // Only needed for @Immutable annotation. + implementation(libs.compose.runtime) // Only needed for @Immutable annotation. } diff --git a/data/build.gradle.kts b/data/build.gradle.kts index ad18c0cb..e612955e 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -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 { @@ -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) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..302f2cfb --- /dev/null +++ b/gradle/libs.versions.toml @@ -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" } diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 7c9804b3..c2f2c8e2 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -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 { @@ -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 } diff --git a/view/build.gradle.kts b/view/build.gradle.kts index 67d51511..79012081 100644 --- a/view/build.gradle.kts +++ b/view/build.gradle.kts @@ -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 { @@ -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) }