From 419aaf7e5b33dabc765196dcf51c400b596875d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylwester=20Zieli=C5=84ski?= Date: Wed, 8 Sep 2021 11:52:48 +0200 Subject: [PATCH] Add VERRSION_CATALOGS feature to gradle --- app/build.gradle | 24 +++++++++++------------- build.gradle | 7 ------- settings.gradle | 43 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 78f9dbe0..7380ed50 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,17 +49,15 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.google.android.material:material:1.4.0' - implementation "androidx.compose.ui:ui:$compose_version" - implementation "androidx.compose.material:material:$compose_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' - implementation 'androidx.activity:activity-compose:1.3.1' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" + implementation libs.bundles.compose + implementation libs.androidx.core + implementation libs.material + implementation libs.lifecycle + implementation libs.compose.activity + + testImplementation libs.test.junit + androidTestImplementation libs.android.test.junit + androidTestImplementation libs.android.test.espresso + androidTestImplementation libs.android.test.compose.ui + debugImplementation libs.android.test.compose.tooling } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 74d6d54f..d5c53f4f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,13 +17,6 @@ buildscript { } } -allprojects { - repositories { - google() - mavenCentral() - } -} - apply plugin: "io.spring.dependency-management" task clean(type: Delete) { diff --git a/settings.gradle b/settings.gradle index e4bc7554..27744455 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,11 +1,38 @@ -//dependencyResolutionManagement { -// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) -// repositories { -// google() -// mavenCentral() -// jcenter() // Warning: this repository is going to shut down soon -// } -//} +enableFeaturePreview("VERSION_CATALOGS") + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + jcenter() // Warning: this repository is going to shut down soon + } + + versionCatalogs { + libs { + version('compose', '1.0.2') + + alias('androidx-core').to('androidx.core:core-ktx:1.6.0') + alias('material').to('com.google.android.material:material:1.4.0') + alias('lifecycle').to('androidx.lifecycle:lifecycle-runtime-ktx:2.3.1') + alias('compose-activity').to('androidx.activity:activity-compose:1.3.1') + + alias('compose-ui').to('androidx.compose.ui', 'ui').versionRef('compose') + alias('compose-material').to('androidx.compose.material', 'material').versionRef('compose') + alias('compose-tooling-preview').to('androidx.compose.ui', 'ui-tooling-preview').versionRef('compose') + + bundle('compose', ['compose-ui', 'compose-material', 'compose-tooling-preview']) + + //-- Test ------------------------------------------------------------------------------ + alias('test-junit').to('junit:junit:4.13.2') + alias('android-test-junit').to('androidx.test.ext:junit:1.1.3') + alias('android-test-espresso').to('androidx.test.espresso:espresso-core:3.4.0') + alias('android-test-compose-ui').to('androidx.compose.ui', 'ui-test-junit4').versionRef('compose') + alias('android-test-compose-tooling').to('androidx.compose.ui', 'ui-tooling').versionRef('compose') + } + } +} + rootProject.name = "Test" include ':app'