Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Gradle version catalog #1059

Merged
merged 9 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion api-tester/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
plugins {
alias libs.plugins.android.application
alias libs.plugins.kotlin.android
}

apply from: "$rootProject.projectDir/base-application.gradle"

android {
Expand All @@ -13,6 +18,7 @@ android {
dependencies {
implementation project(path: ':public')
implementation project(path: ':purchases')
implementation "androidx.annotation:annotation:$annotationVersion"
implementation project(path: ':feature:amazon')

implementation libs.androidx.annotation
}
4 changes: 0 additions & 4 deletions base-application.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
vegaro marked this conversation as resolved.
Show resolved Hide resolved

android {
compileSdkVersion compileVersion
buildToolsVersion buildToolsVersion
Expand Down
43 changes: 11 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
buildscript {
ext.kotlinVersion = "1.6.21"
ext.compileVersion = 33
ext.buildToolsVersion = "33.0.2"
ext.minVersion = 14
ext.billingVersion = "5.1.0"
ext.lifecycleVersion = "2.5.0"
ext.testLibrariesVersion = "1.4.0"
ext.testJUnitVersion = "1.1.3"
ext.robolectricVersion = "4.10.3"
ext.mockkVersion = "1.12.8"
ext.assertJVersion = "3.22.0"
ext.annotationVersion = "1.3.0"
ext.androidxCoreVersion = "1.8.0"
ext.mockwebserverVersion = "4.2.0"
ext.tinkVersion = "1.8.0"
ext.detektVersion = "1.23.0"
ext.coroutinesVersion = "1.6.4"

repositories {
mavenCentral()
google()
}
dependencies {
classpath "com.vanniktech:gradle-maven-publish-plugin:0.22.0"
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.8.10"
classpath "org.jetbrains.kotlinx:kover-gradle-plugin:0.7.0"
}
}

plugins {
id "io.gitlab.arturbosch.detekt" version "$detektVersion"
id "com.savvasdalkitsis.module-dependency-graph" version "0.9"
alias libs.plugins.android.application apply false
alias libs.plugins.android.library apply false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now we are adding both the application and library plugins here and applying them on the respective modules each. Is it necessary to specify both here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Think this is the equivalent of adding the AGP plugin. Removing either plugin gives the same error as removing the parcelize (The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.). Removing application gives the issue in the apps, I am getting it in api-tester, and removing the library one gives it in common.

I think these plugins need to be applied both in the base and in the module's build.gradle. I guess it makes sense for the android plugins, because at the end of the day the need to build an android project, and this is the build.gradle of the project, but I am still not sure about the parcelize one.

alias libs.plugins.androidx.navigation.safeargs apply false
alias libs.plugins.dependencyGraph
alias libs.plugins.detekt
alias libs.plugins.dokka
alias libs.plugins.kotlin.android apply false
alias libs.plugins.kotlin.kapt apply false
alias libs.plugins.kotlin.parcelize apply false
alias libs.plugins.mavenPublish apply false
}

dependencies {
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion"
detektPlugins libs.detekt.formatting
}

allprojects {
Expand Down Expand Up @@ -85,8 +66,6 @@ task detektAllBaseline(type: io.gitlab.arturbosch.detekt.DetektCreateBaselineTas
exclude("**/test/**/*.kt")
}

apply plugin: 'org.jetbrains.dokka'
tonidero marked this conversation as resolved.
Show resolved Hide resolved

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(file("docs/" + project.property("VERSION_NAME")))
includes.from("README.md")
Expand Down
34 changes: 22 additions & 12 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
alias libs.plugins.kover
alias libs.plugins.mavenPublish
}

apply from: "$rootProject.projectDir/library.gradle"

android {
namespace 'com.revenuecat.purchases.common'

Expand All @@ -24,17 +32,19 @@ dependencies {
implementation project(":public")
implementation project(":utils")
implementation project(":strings")
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "androidx.core:core-ktx:$androidxCoreVersion"
implementation "com.google.crypto.tink:tink-android:$tinkVersion"
implementation "com.android.billingclient:billing:$billingVersion"

implementation libs.androidx.core
implementation libs.billing
implementation libs.kotlin.stdlib
implementation libs.tink

testImplementation project(":test-utils")
testImplementation "androidx.test:core:$testLibrariesVersion"
testImplementation "androidx.test:runner:$testLibrariesVersion"
testImplementation "androidx.test:rules:$testLibrariesVersion"
testImplementation "androidx.test.ext:junit:$testJUnitVersion"
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation "io.mockk:mockk:$mockkVersion"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation "com.squareup.okhttp3:mockwebserver:$mockwebserverVersion"
testImplementation libs.androidx.test.core
testImplementation libs.androidx.test.junit
testImplementation libs.androidx.test.rules
testImplementation libs.androidx.test.runner
testImplementation libs.assertJ
testImplementation libs.mockk
testImplementation libs.okhttp.mockwebserver
testImplementation libs.robolectric
}
26 changes: 13 additions & 13 deletions examples/MagicWeather/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
alias libs.plugins.android.application
alias libs.plugins.kotlin.android
}

android {
Expand Down Expand Up @@ -52,15 +52,15 @@ android {
}

dependencies {
implementation "com.revenuecat.purchases:purchases:$purchasesVersion"
implementation "com.revenuecat.purchases:purchases-store-amazon:$purchasesVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "androidx.core:core-ktx:$androidxCoreVersion"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout
implementation libs.androidx.core
implementation libs.androidx.lifecycle.livedata
implementation libs.androidx.lifecycle.viewmodel
implementation libs.androidx.navigation.fragment
implementation libs.androidx.navigation.ui
implementation libs.kotlin.stdlib
implementation libs.material
implementation libs.revenuecat
implementation libs.revenuecat.amazon
}
20 changes: 5 additions & 15 deletions examples/MagicWeather/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.compileVersion = 31
ext.kotlinVersion = "1.6.21"
ext.purchasesVersion = "6.1.1"
ext.lifecycleVersion = "2.5.0"
ext.androidxCoreVersion = "1.8.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
ext.compileVersion = 33
}

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
plugins {
alias libs.plugins.android.application apply false
alias libs.plugins.kotlin.android apply false
}

allprojects {
Expand Down
25 changes: 25 additions & 0 deletions examples/MagicWeather/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[versions]
androidxNavigation = "2.5.3"
kotlin = "1.6.21"
lifecycle = "2.5.0"
purchases = "6.1.1"

[plugins]
android-application = 'com.android.application:8.0.0'
kotlin-android = { id = 'org.jetbrains.kotlin.android', version.ref = 'kotlin' }

[libraries]
androidx-appcompat = "androidx.appcompat:appcompat:1.4.1"
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.3"
androidx-core = "androidx.core:core-ktx:1.8.0"
androidx-lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
androidx-navigation-fragment = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "androidxNavigation" }
androidx-navigation-ui = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "androidxNavigation" }

kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }

material = "com.google.android.material:material:1.6.0"

revenuecat = { module = "com.revenuecat.purchases:purchases", version.ref = "purchases" }
revenuecat-amazon = { module = "com.revenuecat.purchases:purchases-store-amazon", version.ref = "purchases" }
8 changes: 8 additions & 0 deletions examples/MagicWeather/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}

include ':app'
rootProject.name = "MagicWeatherKotlin"
33 changes: 13 additions & 20 deletions examples/purchase-tester/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
apply from: "$rootProject.projectDir/base-application.gradle"

apply plugin: 'androidx.navigation.safeargs.kotlin'

buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3'
}
plugins {
alias libs.plugins.android.application
alias libs.plugins.kotlin.android
alias libs.plugins.androidx.navigation.safeargs
}

apply from: "$rootProject.projectDir/base-application.gradle"

android {
buildFeatures {
Expand Down Expand Up @@ -63,13 +56,13 @@ repositories {
dependencies {
implementation project(path: ':purchases')
implementation project(path: ':feature:amazon')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.6.0'
implementation "androidx.datastore:datastore-preferences:1.0.0"

implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
implementation libs.androidx.navigation.fragment
implementation libs.androidx.navigation.ui
implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout
implementation libs.androidx.datastore.preferences
implementation libs.androidx.recyclerview
implementation libs.kotlin.stdlib
implementation libs.material
}
35 changes: 20 additions & 15 deletions feature/amazon/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
alias libs.plugins.kotlin.parcelize
alias libs.plugins.kover
alias libs.plugins.mavenPublish
}

apply from: "$rootProject.projectDir/library.gradle"

android {
namespace 'com.revenuecat.purchases.amazon'
}

ext {
amazonVersion = "3.0.3"
amazon2Version = "2.0.76"
amazon2FileName = "in-app-purchasing-${amazon2Version}.jar"
}
Expand All @@ -15,22 +23,19 @@ dependencies {
implementation project(":strings")
implementation project(":utils")

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "androidx.annotation:annotation:$annotationVersion"

implementation "com.amazon.device:amazon-appstore-sdk:$amazonVersion"
implementation libs.amazon.appstore.sdk
implementation libs.androidx.annotation
implementation libs.kotlin.stdlib

testImplementation "com.amazon.device:amazon-appstore-sdk:$amazonVersion"
testImplementation project(":test-utils")
testImplementation "androidx.test:core:$testLibrariesVersion"
testImplementation "androidx.test:core-ktx:$testLibrariesVersion"
testImplementation "androidx.test:runner:$testLibrariesVersion"
testImplementation "androidx.test:rules:$testLibrariesVersion"
testImplementation "androidx.test.ext:junit:$testJUnitVersion"
testImplementation "androidx.test.ext:junit-ktx:$testJUnitVersion"
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation "io.mockk:mockk:$mockkVersion"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation libs.amazon.appstore.sdk
testImplementation libs.androidx.test.core
testImplementation libs.androidx.test.junit
testImplementation libs.androidx.test.rules
testImplementation libs.androidx.test.runner
testImplementation libs.assertJ
testImplementation libs.mockk
testImplementation libs.robolectric
}

// Not running with this flag causes verification issues due to the way the Amazon jar is compiled
Expand Down
34 changes: 20 additions & 14 deletions feature/google/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
alias libs.plugins.kover
alias libs.plugins.mavenPublish
}

apply from: "$rootProject.projectDir/library.gradle"

android {
namespace 'com.revenuecat.purchases.google'
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])

implementation project(":common")
implementation project(":public")
implementation project(":strings")
implementation project(":utils")

implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
implementation "androidx.core:core-ktx:$androidxCoreVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "com.android.billingclient:billing:$billingVersion"
implementation libs.androidx.core
implementation libs.billing
implementation libs.kotlin.stdlib
implementation libs.playServices.ads.identifier

testImplementation project(":test-utils")
testImplementation "androidx.test:core:$testLibrariesVersion"
testImplementation "androidx.test:runner:$testLibrariesVersion"
testImplementation "androidx.test:rules:$testLibrariesVersion"
testImplementation "androidx.test.ext:junit:$testJUnitVersion"
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation "io.mockk:mockk:$mockkVersion"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'

testImplementation libs.androidx.test.core
testImplementation libs.androidx.test.junit
testImplementation libs.androidx.test.rules
testImplementation libs.androidx.test.runner
testImplementation libs.assertJ
testImplementation libs.mockk
testImplementation libs.robolectric
testImplementation libs.playServices.ads.identifier
}
Loading