Skip to content

Commit

Permalink
Refactor dependency resolution manager to toml files (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroDm authored Oct 14, 2024
1 parent 8947b52 commit 0ac2d47
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 84 deletions.
14 changes: 6 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'io.gitlab.arturbosch.detekt'
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.detekt)
}


Expand Down Expand Up @@ -61,10 +61,9 @@ dependencies {
implementation libs.androidx.constraintlayout

implementation libs.verygoodsecurity.collect
implementation libs.verygoodsecurity.pdf.viewer

implementation libs.pdf.viewer

implementation libs.compose.activity
implementation libs.activity.compose
implementation libs.compose.material
implementation libs.compose.ui.tooling.preview

Expand All @@ -75,12 +74,11 @@ dependencies {
androidTestImplementation androidTestLibs.androidx.junit.ext.ktx
androidTestImplementation androidTestLibs.androidx.runner
androidTestImplementation androidTestLibs.androidx.rules
androidTestImplementation androidTestLibs.androidx.core.ktx
androidTestImplementation androidTestLibs.androidx.uiautomator
androidTestImplementation androidTestLibs.androidx.espresso.intents
androidTestImplementation androidTestLibs.androidx.espresso.core
androidTestImplementation androidTestLibs.hamcrest.integration
androidTestImplementation(androidTestLibs.support.espresso.contrib) {
androidTestImplementation(androidTestLibs.espresso.contrib) {
exclude group: 'com.android.support', module: 'appcompat'
exclude module: 'support-annotations'
exclude module: 'support-v4'
Expand Down
31 changes: 8 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
buildscript {
apply from: 'gradle/utils.gradle'

repositories {
google()
mavenCentral()
}
dependencies {
classpath gradlePlugins.tools
classpath gradlePlugins.kotlin
classpath gradlePlugins.maven.publish
classpath gradlePlugins.dokka
classpath gradlePlugins.detekt
classpath gradlePlugins.kover
}
}

allprojects {
repositories {
google()
mavenCentral()
}
plugins {
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.android.library).apply(false)
alias(libs.plugins.kotlin.android).apply(false)
alias(libs.plugins.kotlin.parcelize).apply(false)
alias(libs.plugins.dokka).apply(false)
alias(libs.plugins.kover).apply(false)
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
20 changes: 20 additions & 0 deletions gradle/android-test-libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[versions]
androidx-test = '1.6.1'
androidx-junit-ext = '1.2.1'
androidx-junit-ext-ktx = '1.2.1'
androidx-uiautomator = '2.3.0'
androidx-espresso = '3.6.1'
espresso-contrib = '3.0.2'
hamcrest-integration = '1.3'

[libraries]
androidx-runner = { group = 'androidx.test', name = 'runner', version.ref = 'androidx-test' }
androidx-rules = { group = 'androidx.test', name = 'rules', version.ref = 'androidx-test' }
androidx-junit-ext = { group = 'androidx.test.ext', name = 'junit', version.ref = 'androidx-junit-ext' }
androidx-junit-ext-ktx = { group = 'androidx.test.ext', name = 'junit-ktx', version.ref = 'androidx-junit-ext-ktx' }
androidx-uiautomator = { group = 'androidx.test.uiautomator', name = 'uiautomator', version.ref = 'androidx-uiautomator' }
androidx-espresso-core = { group = 'androidx.test.espresso', name = 'espresso-core', version.ref = 'androidx-espresso' }
androidx-espresso-intents = { group = 'androidx.test.espresso', name = 'espresso-intents', version.ref = 'androidx-espresso' }
hamcrest-integration = { group = 'org.hamcrest', name = 'hamcrest-integration', version.ref = 'hamcrest-integration' }
espresso-contrib = { group = 'com.android.support.test.espresso', name = 'espresso-contrib', version.ref = 'espresso-contrib' }

5 changes: 5 additions & 0 deletions gradle/debug-libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]
compose-ui-tooling = '1.7.3'

[libraries]
compose-ui-tooling = { group = 'androidx.compose.ui', name = 'ui-tooling', version.ref = 'compose-ui-tooling' }
36 changes: 36 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[versions]
agp = '8.2.2'
kotlin = '1.9.22'
mavenPublish = '0.27.0'
dokka = '1.9.20'
detekt = '1.23.5'
kover = '0.8.3'
appcompat = '1.6.1'
core-ktx = '1.12.0'
okhttp = '4.12.0'
verygoodsecurity-collect = "1.9.1"
verygoodsecurity-pdf-viewer = "1.0.0"
activity-compose = '1.8.2'
androidx-compose = '1.6.2'
constraintlayout = '2.1.4'

[plugins]
android-application = { id = 'com.android.application', version.ref = 'agp' }
android-library = { id = 'com.android.library', version.ref = 'agp' }
kotlin-android = { id = 'org.jetbrains.kotlin.android', version.ref = 'kotlin' }
kotlin-parcelize = { id = 'org.jetbrains.kotlin.plugin.parcelize', version.ref = 'kotlin' }
maven-publish = { id = 'com.vanniktech.maven.publish', version.ref = 'mavenPublish' }
dokka = { id = 'org.jetbrains.dokka', version.ref = 'dokka' }
detekt = { id = 'io.gitlab.arturbosch.detekt', version.ref = 'detekt' }
kover = { id = 'org.jetbrains.kotlinx.kover', version.ref = 'kover' }

[libraries]
verygoodsecurity-collect = { group = 'com.verygoodsecurity', name = 'vgscollect', version.ref = 'verygoodsecurity-collect' }
verygoodsecurity-pdf-viewer = { group = 'com.verygoodsecurity', name = 'android-pdf-viewer', version.ref = 'verygoodsecurity-pdf-viewer' }
androidx-appcompat = { group = 'androidx.appcompat', name = 'appcompat', version.ref = 'appcompat' }
androidx-core-ktx = { group = 'androidx.core', name = 'core-ktx', version.ref = 'core-ktx' }
androidx-constraintlayout = { group = 'androidx.constraintlayout', name = 'constraintlayout', version.ref = 'constraintlayout' }
okhttp = { group = 'com.squareup.okhttp3', name = 'okhttp', version.ref = 'okhttp' }
activity-compose = { group = 'androidx.activity', name = 'activity-compose', version.ref = 'activity-compose' }
compose-material = { group = 'androidx.compose.material', name = 'material', version.ref = 'androidx-compose' }
compose-ui-tooling-preview = { group = 'androidx.compose.ui', name = 'ui-tooling-preview', version.ref = 'androidx-compose' }
11 changes: 11 additions & 0 deletions gradle/test-libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[versions]
junit = '4.13.2'
robolectric = '4.11.1'
mockk = '1.12.4'
json = '20240303'

[libraries]
junit = { group = 'junit', name = 'junit', version.ref = 'junit' }
robolectric = { group = 'org.robolectric', name = 'robolectric', version.ref = 'robolectric' }
mockk = { group = 'io.mockk', name = 'mockk', version.ref = 'mockk' }
json = { group = 'org.json', name = 'json', version.ref = 'json' }
62 changes: 19 additions & 43 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,52 +1,28 @@
include ':vgsshow'
include ':app'
rootProject.name = "vgs-show-android"
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}

// Read more about dependencyResolutionManagement in gradle docs: https://docs.gradle.org/current/userguide/platforms.html
// Currently dependabot doesn't recognize toml files and doesn't support versions references.
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
versionCatalogs {
gradlePlugins {
library('tools', 'com.android.tools.build:gradle:8.2.2')
library('kotlin', 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22')
library('maven-publish', 'com.vanniktech:gradle-maven-publish-plugin:0.28.0')
library('dokka', 'org.jetbrains.dokka:dokka-gradle-plugin:1.9.10')
library('detekt', 'io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.5')
library('kover', 'org.jetbrains.kotlinx:kover-gradle-plugin:0.7.6')
}
libs {
library('androidx-appcompat', 'androidx.appcompat:appcompat:1.6.1')
library('androidx-core-ktx', 'androidx.core:core-ktx:1.12.0')
library('androidx-constraintlayout', 'androidx.constraintlayout:constraintlayout:2.1.4')
library('okHttp', 'com.squareup.okhttp3:okhttp:4.12.0')
library('pdf-viewer', 'com.verygoodsecurity:android-pdf-viewer:1.0.0')
library('verygoodsecurity-collect', 'com.verygoodsecurity:vgscollect:1.9.1')
library('compose-activity', 'androidx.activity:activity-compose:1.8.2')
library('compose-material', 'androidx.compose.material:material:1.6.3')
library('compose-ui-tooling-preview', 'androidx.compose.ui:ui-tooling-preview:1.6.3')
debugLibs {
from(files('gradle/debug-libs.versions.toml'))
}
testLibs {
library('junit', 'junit:junit:4.13.2')
library('mockito-core', 'org.mockito:mockito-core:5.11.0')
library('mockito-inline', 'org.mockito:mockito-inline:5.2.0')
library('json', 'org.json:json:20240303')
library('robolectric', 'org.robolectric:robolectric:4.11.1')
library('mockk', 'io.mockk:mockk:1.13.10')
}
debugLibs {
library('compose-ui-tooling', 'androidx.compose.ui:ui-tooling:1.6.2')
from(files('gradle/test-libs.versions.toml'))
}
androidTestLibs {
library('androidx-junit-ext', 'androidx.test.ext:junit:1.1.5')
library('androidx-junit-ext-ktx', 'androidx.test.ext:junit-ktx:1.1.5')
library('androidx-espresso-core', 'androidx.test.espresso:espresso-core:3.5.1')
library('androidx-runner', 'androidx.test:runner:1.5.2')
library('androidx-rules', 'androidx.test:rules:1.5.0')
library('androidx-core-ktx', 'androidx.test:core-ktx:1.5.0')
library('androidx-uiautomator', 'androidx.test.uiautomator:uiautomator:2.3.0')
library('androidx-espresso-intents', 'androidx.test.espresso:espresso-intents:3.5.1')
library('hamcrest-integration', 'org.hamcrest:hamcrest-integration:1.3')
library('support-espresso-contrib', 'com.android.support.test.espresso:espresso-contrib:3.5.1')
from(files('gradle/android-test-libs.versions.toml'))
}
}
}
}

rootProject.name = "vgs-show-android"
include ':app', ':vgsshow'
22 changes: 12 additions & 10 deletions vgsshow/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
id 'io.gitlab.arturbosch.detekt'
id 'org.jetbrains.kotlinx.kover'
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.maven.publish)
alias(libs.plugins.dokka)
alias(libs.plugins.detekt)
alias(libs.plugins.kover)
}

apply from: "$rootDir/gradle/utils.gradle"

android {
namespace 'com.verygoodsecurity.vgsshow'
compileSdk 34
Expand Down Expand Up @@ -70,18 +72,18 @@ dependencies {
implementation libs.compose.material

// Http
api libs.okHttp
api libs.okhttp

// PDF viewer.
// NOTE: Used by VGSPDFView. Consumer should add this dependency by itself as it has big size.
compileOnly libs.pdf.viewer
compileOnly libs.verygoodsecurity.pdf.viewer

testImplementation testLibs.junit
testImplementation testLibs.json
testImplementation testLibs.robolectric
testImplementation testLibs.mockk
testImplementation testLibs.mockk
testImplementation libs.pdf.viewer
testImplementation libs.verygoodsecurity.pdf.viewer
}

tasks.named("dokkaHtml") {
Expand Down

0 comments on commit 0ac2d47

Please sign in to comment.