summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorconorsmith <conor.smith42@gmail.com>2023-09-03 16:40:59 +0200
committerArne Schwabe <arne@rfc2549.org>2023-10-11 12:36:19 +0200
commit5719f6dc6bc35096af5922d410c2175463fea974 (patch)
tree731bdfca4789a712c4d048f7631982da6b70da47
parent29e3cc3727732fe9cbe32b1e7991b77d90290fbb (diff)
Use gradle catalog to align project dependencies across modules/gradle files
-rw-r--r--build.gradle.kts26
-rw-r--r--gradle/libs.versions.toml40
-rw-r--r--main/build.gradle.kts48
-rw-r--r--remoteExample/build.gradle5
-rw-r--r--settings.gradle.kts16
-rw-r--r--tlsexternalcertprovider/build.gradle4
6 files changed, 84 insertions, 55 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index b6c58bb8..435eb00f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,25 +3,7 @@
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
*/
-
-buildscript {
- var kotlin_version: String by extra
-
- kotlin_version = "1.9.0"
- repositories {
- google()
- mavenCentral()
- }
- dependencies {
- classpath("com.android.tools.build:gradle:8.1.1")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
- }
-}
-
-allprojects {
- repositories {
- google()
- mavenCentral()
- maven(url = "https://jitpack.io")
- }
-}
+plugins {
+ alias(libs.plugins.android.application) apply false
+ alias(libs.plugins.kotlin.android) apply false
+} \ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 00000000..f12ff9c9
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,40 @@
+[versions]
+kotlin = "1.9.0"
+constraintlayout = "2.1.4"
+cardview = "1.0.0"
+recyclerview = "1.3.0"
+appcompat = "1.6.1"
+mpandroidchart = "v3.1.0"
+okhttp = "4.10.0"
+core-ktx = "1.10.1"
+fragment-ktx = "1.6.0"
+preference-ktx = "1.2.0"
+material = "1.7.0"
+androidx-webkit = "1.7.0"
+androidx-lifecycle-viewmodel-ktx = "2.6.1"
+androidx-lifecycle-runtime-ktx = "2.6.1"
+androidx-security-crypto = "1.1.0-alpha06"
+androidx-annotation = "1.6.0"
+android-gradle-plugin = "8.1.1"
+
+[libraries]
+kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
+androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
+androidx-cardview = { group = "androidx.cardview", name = "cardview", version.ref = "cardview" }
+androidx-recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
+androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
+mpandroidchart = { group = "com.github.PhilJay", name = "MPAndroidChart", version.ref = "mpandroidchart" }
+square-okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
+androidx-core-ktx = { group = "androidx.core", name = "core", version.ref = "core-ktx" }
+androidx-fragment-ktx = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment-ktx" }
+androidx-preference-ktx = { group = "androidx.preference", name = "preference-ktx", version.ref = "preference-ktx" }
+material = { group = "com.google.android.material", name = "material", version.ref = "material" }
+androidx-webkit = { group = "androidx.webkit", name = "webkit", version.ref = "androidx-webkit" }
+androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle-viewmodel-ktx" }
+androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidx-lifecycle-runtime-ktx" }
+androidx-security-crypto = { group = "androidx.security", name = "security-crypto", version.ref = "androidx-security-crypto" }
+androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "androidx-annotation" }
+
+[plugins]
+android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
+kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } \ No newline at end of file
diff --git a/main/build.gradle.kts b/main/build.gradle.kts
index 99c04b16..3f9bc90d 100644
--- a/main/build.gradle.kts
+++ b/main/build.gradle.kts
@@ -6,10 +6,9 @@ import com.android.build.gradle.api.ApplicationVariant
*/
plugins {
- id("com.android.application")
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
id("checkstyle")
-
- id("kotlin-android")
}
android {
@@ -232,36 +231,25 @@ android.applicationVariants.all(object : Action<ApplicationVariant> {
dependencies {
// https://maven.google.com/web/index.html
- // https://developer.android.com/jetpack/androidx/releases/core
- val preferenceVersion = "1.2.0"
- val coreVersion = "1.10.1"
- val materialVersion = "1.7.0"
- val fragment_version = "1.6.0"
-
-
- implementation("androidx.annotation:annotation:1.6.0")
- implementation("androidx.core:core:$coreVersion")
+ implementation(libs.androidx.annotation)
// Is there a nicer way to do this?
- dependencies.add("uiImplementation", "androidx.constraintlayout:constraintlayout:2.1.4")
- dependencies.add("uiImplementation", "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22")
- dependencies.add("uiImplementation", "androidx.cardview:cardview:1.0.0")
- dependencies.add("uiImplementation", "androidx.recyclerview:recyclerview:1.3.0")
- dependencies.add("uiImplementation", "androidx.appcompat:appcompat:1.6.1")
- dependencies.add("uiImplementation", "com.github.PhilJay:MPAndroidChart:v3.1.0")
- dependencies.add("uiImplementation", "com.squareup.okhttp3:okhttp:4.10.0")
- dependencies.add("uiImplementation", "androidx.core:core:$coreVersion")
- dependencies.add("uiImplementation", "androidx.core:core-ktx:$coreVersion")
- dependencies.add("uiImplementation", "androidx.fragment:fragment-ktx:$fragment_version")
- dependencies.add("uiImplementation", "androidx.preference:preference:$preferenceVersion")
- dependencies.add("uiImplementation", "androidx.preference:preference-ktx:$preferenceVersion")
- dependencies.add("uiImplementation", "com.google.android.material:material:$materialVersion")
- dependencies.add("uiImplementation", "androidx.webkit:webkit:1.7.0")
- dependencies.add("uiImplementation", "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
- dependencies.add("uiImplementation", "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
- dependencies.add("uiImplementation","androidx.security:security-crypto:1.1.0-alpha06")
-
+ dependencies.add("uiImplementation", libs.kotlin)
+ dependencies.add("uiImplementation", libs.androidx.appcompat)
+ dependencies.add("uiImplementation", libs.androidx.constraintlayout)
+ dependencies.add("uiImplementation", libs.androidx.cardview)
+ dependencies.add("uiImplementation", libs.androidx.recyclerview)
+ dependencies.add("uiImplementation", libs.androidx.core.ktx)
+ dependencies.add("uiImplementation", libs.androidx.fragment.ktx)
+ dependencies.add("uiImplementation", libs.androidx.preference.ktx)
+ dependencies.add("uiImplementation", libs.androidx.webkit)
+ dependencies.add("uiImplementation", libs.androidx.lifecycle.viewmodel.ktx)
+ dependencies.add("uiImplementation", libs.androidx.lifecycle.runtime.ktx)
+ dependencies.add("uiImplementation", libs.androidx.security.crypto)
+ dependencies.add("uiImplementation", libs.mpandroidchart)
+ dependencies.add("uiImplementation", libs.square.okhttp)
+ dependencies.add("uiImplementation", libs.material)
testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21")
testImplementation("junit:junit:4.13.2")
diff --git a/remoteExample/build.gradle b/remoteExample/build.gradle
index 648a30bf..179555bb 100644
--- a/remoteExample/build.gradle
+++ b/remoteExample/build.gradle
@@ -3,8 +3,9 @@
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
*/
-apply plugin: 'com.android.application'
-
+plugins {
+ alias libs.plugins.android.application
+}
android {
compileSdkVersion 33
diff --git a/settings.gradle.kts b/settings.gradle.kts
index b4b170fe..51e9dcbd 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -2,6 +2,22 @@
* Copyright (c) 2012-2016 Arne Schwabe
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
*/
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ google()
+ mavenCentral()
+
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ maven(url = "https://jitpack.io")
+ }
+}
include(":main")
include(":tlsexternalcertprovider")
diff --git a/tlsexternalcertprovider/build.gradle b/tlsexternalcertprovider/build.gradle
index 2fda4308..ee86ed6d 100644
--- a/tlsexternalcertprovider/build.gradle
+++ b/tlsexternalcertprovider/build.gradle
@@ -3,7 +3,9 @@
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
*/
-apply plugin: 'com.android.application'
+plugins {
+ alias libs.plugins.android.application
+}
ext {
bouncycastleVersion = '1.49'