Skip to content

Commit 66fa56e

Browse files
committed
Merge branch 'improve-gradle' into dev
2 parents 951dabe + 9eb8624 commit 66fa56e

File tree

7 files changed

+182
-103
lines changed

7 files changed

+182
-103
lines changed

build.gradle.kts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
plugins {
2-
val kotlinVersion = "2.1.10"
3-
id("com.android.application") version "8.8.0" apply (false)
4-
id("org.jetbrains.kotlin.android") version kotlinVersion apply (false)
5-
id("org.jetbrains.kotlin.kapt") version kotlinVersion apply (false)
6-
id("org.jetbrains.kotlin.multiplatform") version kotlinVersion apply (false)
7-
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
2+
alias(libs.plugins.agp) apply false
3+
alias(libs.plugins.kotlin.android) apply false
4+
alias(libs.plugins.ksp) apply false
5+
alias(libs.plugins.ktlint.plugin) apply false
6+
alias(libs.plugins.shadow) apply false
87
}
98

109
apply {
11-
from("translators.gradle.kts")
12-
}
13-
14-
allprojects {
15-
repositories {
16-
google()
17-
mavenCentral()
18-
maven(url = "https://plugins.gradle.org/m2/")
19-
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
20-
maven(url = "https://jitpack.io")
21-
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers/") // Repository for kotlin-css-jvm old versions, now that the Gradle Plugin Portal no longer brings these in by mirroring JCenter
22-
}
10+
from("gradle/translators.gradle.kts")
2311
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ android.enableJetifier=true
66
android.defaults.buildfeatures.buildconfig=true
77
android.nonTransitiveRClass=false
88
android.nonFinalResIds=false
9+
org.gradle.configureondemand=true
10+
org.gradle.warning.mode=all
11+
org.gradle.caching=true

gradle/libs.versions.toml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
[versions]
2+
agp = "8.8.0"
3+
annotation = "1.9.1"
4+
appcompat = "1.7.0"
5+
appintro = "6.3.1"
6+
commonsCodec = "1.16.0"
7+
commonsIo = "1.3.2"
8+
commonsLang3 = "3.14.0"
9+
dagger = "2.55"
10+
desugar = "2.1.4"
11+
dexmaker = "2.28.3"
12+
espresso = "3.6.1"
13+
guava = "33.2.1-android"
14+
hamcrest = "2.2"
15+
jsr250 = "1.0"
16+
jsr305 = "3.0.2"
17+
junit = "1.2.1"
18+
junitJupiter = "5.10.1"
19+
junitVersion = "4.13.2"
20+
konfetti-xml = "2.0.2"
21+
kotlin = "2.1.10"
22+
kotlinxCoroutinesCoreCommon = "1.3.8"
23+
ksp = "2.1.10-1.0.30"
24+
ktlint-plugin = "11.6.1"
25+
ktor = "1.6.8"
26+
ktxCoroutine = "1.10.1"
27+
legacy-support = "1.0.0"
28+
material = "1.12.0"
29+
mockito-kotlin = "5.4.0"
30+
opencsv = "5.9"
31+
rules = "1.6.1"
32+
shadow = "8.1.1"
33+
sqliteJdbc = "3.45.1.0"
34+
uiautomator = "2.3.0"
35+
36+
[libraries]
37+
annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" }
38+
appIntro = { group = "com.github.AppIntro", name = "AppIntro", version.ref = "appintro" }
39+
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
40+
commons-codec = { module = "commons-codec:commons-codec", version.ref = "commonsCodec" }
41+
commons-io = { module = "org.apache.commons:commons-io", version.ref = "commonsIo" }
42+
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commonsLang3" }
43+
dagger = { group = "com.google.dagger", name = "dagger", version.ref = "dagger" }
44+
dagger-compiler = { group = "com.google.dagger", name = "dagger-compiler", version.ref = "dagger" }
45+
desugar_jdk_libs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugar" }
46+
dexmaker-mockito = { group = "com.linkedin.dexmaker", name = "dexmaker-mockito", version.ref = "dexmaker" }
47+
espresso-contrib = { group = "androidx.test.espresso", name = "espresso-contrib", version.ref = "espresso" }
48+
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" }
49+
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
50+
hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
51+
jsr250-api = { group = "javax.annotation", name = "jsr250-api", version.ref = "jsr250" }
52+
jsr305 = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "jsr305" }
53+
junit = { group = "androidx.test.ext", name = "junit", version.ref = "junit" }
54+
junit-junit = { module = "junit:junit", version.ref = "junitVersion" }
55+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junitJupiter" }
56+
konfetti-xml = { group = "nl.dionsegijn", name = "konfetti-xml", version.ref = "konfetti-xml" }
57+
kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
58+
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "ktxCoroutine" }
59+
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "ktxCoroutine" }
60+
kotlinx-coroutines-core-common = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-common", version.ref = "kotlinxCoroutinesCoreCommon" }
61+
kotlinx-coroutines-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "ktxCoroutine" }
62+
ktor-client-android = { group = "io.ktor", name = "ktor-client-android", version.ref = "ktor" }
63+
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
64+
ktor-client-jackson = { group = "io.ktor", name = "ktor-client-jackson", version.ref = "ktor" }
65+
ktor-client-json = { group = "io.ktor", name = "ktor-client-json", version.ref = "ktor" }
66+
ktor-client-mock = { group = "io.ktor", name = "ktor-client-mock", version.ref = "ktor" }
67+
ktor-jackson = { group = "io.ktor", name = "ktor-jackson", version.ref = "ktor" }
68+
legacy-preference-v14 = { group = "androidx.legacy", name = "legacy-preference-v14", version.ref = "legacy-support" }
69+
legacy-support-v4 = { group = "androidx.legacy", name = "legacy-support-v4", version.ref = "legacy-support" }
70+
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
71+
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version.ref = "mockito-kotlin" }
72+
opencsv = { group = "com.opencsv", name = "opencsv", version.ref = "opencsv" }
73+
rules = { group = "androidx.test", name = "rules", version.ref = "rules" }
74+
sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqliteJdbc" }
75+
uiautomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "uiautomator" }
76+
77+
[bundles]
78+
androidTest = [
79+
"annotation",
80+
"dagger",
81+
"dexmaker-mockito",
82+
"espresso-contrib",
83+
"espresso-core",
84+
"junit",
85+
"ktor-client-mock",
86+
"ktor-jackson",
87+
"mockito-kotlin",
88+
"rules",
89+
"uiautomator"
90+
]
91+
test = [
92+
"dagger",
93+
"junit-junit",
94+
"mockito-kotlin",
95+
]
96+
97+
[plugins]
98+
agp = { id = "com.android.application", version.ref = "agp" }
99+
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
100+
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
101+
ktlint-plugin = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-plugin" }
102+
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
File renamed without changes.

settings.gradle.kts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
pluginManagement {
22
repositories {
33
gradlePluginPortal()
4-
google()
4+
google {
5+
content {
6+
includeGroupByRegex("com\\.android.*")
7+
includeGroupByRegex("com\\.google.*")
8+
includeGroupByRegex("androidx.*")
9+
}
10+
}
511
}
6-
resolutionStrategy.eachPlugin {
7-
if (requested.id.id == "com.android.application") {
8-
useModule("com.android.tools.build:gradle:${requested.version}")
12+
}
13+
14+
include(":uhabits-android", ":uhabits-core")
15+
dependencyResolutionManagement {
16+
@Suppress("UnstableApiUsage")
17+
repositories {
18+
google {
19+
content {
20+
includeGroupByRegex("com\\.android.*")
21+
includeGroupByRegex("com\\.google.*")
22+
includeGroupByRegex("androidx.*")
23+
}
924
}
25+
mavenCentral()
26+
maven(url = "https://plugins.gradle.org/m2/")
27+
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
28+
maven(url = "https://jitpack.io")
1029
}
1130
}
1231

uhabits-android/build.gradle.kts

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919

2020
plugins {
21-
id("com.android.application") version "8.8.0"
22-
id("org.jetbrains.kotlin.android")
23-
id("org.jetbrains.kotlin.kapt")
24-
id("org.jlleitschuh.gradle.ktlint")
21+
alias(libs.plugins.agp)
22+
alias(libs.plugins.kotlin.android)
23+
alias(libs.plugins.ksp)
24+
alias(libs.plugins.ktlint.plugin)
2525
}
2626

2727
tasks.compileLint {
@@ -40,7 +40,6 @@ kotlin {
4040
}
4141

4242
android {
43-
4443
namespace = "org.isoron.uhabits"
4544
compileSdk = 35
4645
// compileSdkPreview = "VanillaIceCream"
@@ -66,16 +65,16 @@ android {
6665
}
6766

6867
buildTypes {
69-
getByName("release") {
68+
release {
7069
isMinifyEnabled = true
7170
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.txt")
7271
if (signingConfigs.findByName("release") != null) {
7372
signingConfig = signingConfigs.getByName("release")
7473
}
7574
}
7675

77-
getByName("debug") {
78-
isTestCoverageEnabled = true
76+
debug {
77+
enableUnitTestCoverage = true
7978
}
8079
}
8180

@@ -84,64 +83,35 @@ android {
8483
targetCompatibility(JavaVersion.VERSION_11)
8584
sourceCompatibility(JavaVersion.VERSION_11)
8685
}
87-
kotlinOptions {
88-
jvmTarget = JavaVersion.VERSION_11.toString()
89-
}
90-
91-
buildFeatures {
92-
viewBinding = true
93-
}
9486

95-
lint {
96-
abortOnError = false
97-
}
87+
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
88+
buildFeatures.viewBinding = true
89+
lint.abortOnError = false
9890
}
9991

10092
dependencies {
101-
val daggerVersion = "2.51.1"
102-
val kotlinVersion = "2.1.10"
103-
val kxCoroutinesVersion = "1.10.1"
104-
val ktorVersion = "1.6.8"
105-
val espressoVersion = "3.6.1"
106-
107-
androidTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
108-
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
109-
androidTestImplementation("com.google.dagger:dagger:$daggerVersion")
110-
androidTestImplementation("com.linkedin.dexmaker:dexmaker-mockito:2.28.3")
111-
androidTestImplementation("io.ktor:ktor-client-mock:$ktorVersion")
112-
androidTestImplementation("io.ktor:ktor-jackson:$ktorVersion")
113-
androidTestImplementation("androidx.annotation:annotation:1.7.1")
114-
androidTestImplementation("androidx.test.ext:junit:1.2.1")
115-
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0")
116-
androidTestImplementation("androidx.test:rules:1.6.1")
117-
androidTestImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0")
118-
compileOnly("javax.annotation:jsr250-api:1.0")
119-
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
120-
implementation("com.github.AppIntro:AppIntro:6.3.1")
121-
implementation("com.google.code.findbugs:jsr305:3.0.2")
122-
implementation("com.google.dagger:dagger:$daggerVersion")
123-
implementation("com.google.guava:guava:33.1.0-android")
124-
implementation("io.ktor:ktor-client-android:$ktorVersion")
125-
implementation("io.ktor:ktor-client-core:$ktorVersion")
126-
implementation("io.ktor:ktor-client-jackson:$ktorVersion")
127-
implementation("io.ktor:ktor-client-json:$ktorVersion")
128-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
129-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kxCoroutinesVersion")
130-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kxCoroutinesVersion")
131-
implementation("androidx.appcompat:appcompat:1.7.0")
132-
implementation("androidx.legacy:legacy-preference-v14:1.0.0")
133-
implementation("androidx.legacy:legacy-support-v4:1.0.0")
134-
implementation("com.google.android.material:material:1.12.0")
135-
implementation("com.opencsv:opencsv:5.9")
136-
implementation("nl.dionsegijn:konfetti-xml:2.0.2")
93+
compileOnly(libs.jsr250.api)
94+
coreLibraryDesugaring(libs.desugar.jdk.libs)
95+
implementation(libs.appIntro)
96+
implementation(libs.jsr305)
97+
implementation(libs.dagger)
98+
implementation(libs.guava)
99+
implementation(libs.ktor.client.android)
100+
implementation(libs.ktor.client.core)
101+
implementation(libs.ktor.client.jackson)
102+
implementation(libs.ktor.client.json)
103+
implementation(libs.kotlin.stdlib.jdk8)
104+
implementation(libs.kotlinx.coroutines.android)
105+
implementation(libs.kotlinx.coroutines.core)
106+
implementation(libs.appcompat)
107+
implementation(libs.legacy.preference.v14)
108+
implementation(libs.legacy.support.v4)
109+
implementation(libs.material)
110+
implementation(libs.opencsv)
111+
implementation(libs.konfetti.xml)
137112
implementation(project(":uhabits-core"))
138-
kapt("com.google.dagger:dagger-compiler:$daggerVersion")
139-
kaptAndroidTest("com.google.dagger:dagger-compiler:$daggerVersion")
140-
testImplementation("com.google.dagger:dagger:$daggerVersion")
141-
testImplementation("junit:junit:4.13.2")
142-
testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0")
143-
}
113+
ksp(libs.dagger.compiler)
144114

145-
kapt {
146-
correctErrorTypes = true
115+
androidTestImplementation(libs.bundles.androidTest)
116+
testImplementation(libs.bundles.test)
147117
}

uhabits-core/build.gradle.kts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
plugins {
2121
kotlin("multiplatform")
22-
id("org.jlleitschuh.gradle.ktlint")
22+
alias(libs.plugins.ktlint.plugin)
2323
}
2424

2525
kotlin {
@@ -30,7 +30,7 @@ kotlin {
3030
val commonMain by getting {
3131
dependencies {
3232
implementation(kotlin("stdlib-common"))
33-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
33+
implementation(libs.kotlinx.coroutines.core.common)
3434
}
3535
}
3636

@@ -44,34 +44,31 @@ kotlin {
4444
val jvmMain by getting {
4545
dependencies {
4646
implementation(kotlin("stdlib-jdk8"))
47-
compileOnly("com.google.dagger:dagger:2.51.1")
48-
implementation("com.google.guava:guava:33.1.0-android")
49-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1")
50-
implementation("androidx.annotation:annotation:1.7.1")
51-
implementation("com.google.code.findbugs:jsr305:3.0.2")
52-
implementation("com.opencsv:opencsv:5.9")
53-
implementation("commons-codec:commons-codec:1.16.0")
54-
implementation("org.apache.commons:commons-lang3:3.14.0")
47+
compileOnly(libs.dagger)
48+
implementation(libs.guava)
49+
implementation(libs.kotlinx.coroutines.core.jvm)
50+
implementation(libs.annotation)
51+
implementation(libs.jsr305)
52+
implementation(libs.opencsv)
53+
implementation(libs.commons.codec)
54+
implementation(libs.commons.lang3)
5555
}
5656
}
5757

5858
val jvmTest by getting {
5959
dependencies {
6060
implementation(kotlin("test"))
6161
implementation(kotlin("test-junit"))
62-
implementation("org.xerial:sqlite-jdbc:3.45.1.0")
63-
implementation("org.hamcrest:hamcrest:2.2")
64-
implementation("org.apache.commons:commons-io:1.3.2")
65-
implementation("org.mockito.kotlin:mockito-kotlin:5.4.0")
66-
implementation("org.junit.jupiter:junit-jupiter:5.10.1")
62+
implementation(libs.sqlite.jdbc)
63+
implementation(libs.hamcrest)
64+
implementation(libs.commons.io)
65+
implementation(libs.mockito.kotlin)
66+
implementation(libs.junit.jupiter)
6767
}
6868
}
6969
}
7070
}
7171

72-
tasks.named<org.gradle.language.jvm.tasks.ProcessResources>("jvmProcessResources") {
73-
duplicatesStrategy = DuplicatesStrategy.INCLUDE
74-
}
75-
tasks.named<org.gradle.language.jvm.tasks.ProcessResources>("jvmTestProcessResources") {
72+
tasks.withType<ProcessResources> {
7673
duplicatesStrategy = DuplicatesStrategy.INCLUDE
7774
}

0 commit comments

Comments
 (0)