Skip to content

Commit 756d7c4

Browse files
authored
chore: Upgrade to Gradle 8 (#63)
1 parent c8236fa commit 756d7c4

21 files changed

+800
-640
lines changed

build-logic/plugins/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ plugins {
2020
}
2121

2222
java {
23-
sourceCompatibility = JavaVersion.VERSION_11
24-
targetCompatibility = JavaVersion.VERSION_11
23+
sourceCompatibility = JavaVersion.VERSION_17
24+
targetCompatibility = JavaVersion.VERSION_17
2525
}
2626

2727
ktlint {
@@ -30,7 +30,7 @@ ktlint {
3030

3131
dependencies {
3232
compileOnly(libs.plugin.android.gradle)
33-
compileOnly(libs.plugin.kotlin.gradle)
33+
compileOnly(libs.plugin.kotlin.android)
3434
compileOnly(libs.plugin.dokka)
3535
compileOnly(libs.plugin.ktlint)
3636
}

build-logic/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ import org.gradle.api.tasks.compile.JavaCompile
2121
import org.gradle.api.tasks.testing.Test
2222
import org.gradle.kotlin.dsl.configure
2323
import org.gradle.kotlin.dsl.extra
24+
import org.gradle.kotlin.dsl.gradleKotlinDsl
2425
import org.gradle.kotlin.dsl.provideDelegate
2526
import org.gradle.kotlin.dsl.withType
27+
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
2628
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2729

28-
val optInAnnotations = listOf(
29-
"com.amplifyframework.annotations.InternalApiWarning",
30-
"com.amplifyframework.annotations.InternalAmplifyApi"
31-
)
30+
3231

3332
/**
3433
* This convention plugin configures an Android library module
@@ -62,9 +61,9 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
6261
maxHeapSize = "4g"
6362
}
6463

65-
tasks.withType<KotlinCompile> {
66-
compilerOptions {
67-
freeCompilerArgs.addAll(optInAnnotations.map { "-opt-in=$it" })
64+
tasks.withType<KotlinCompile>().configureEach {
65+
kotlinOptions {
66+
jvmTarget = JavaVersion.VERSION_11.toString()
6867
}
6968
}
7069
}
@@ -83,9 +82,12 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
8382
extension.apply {
8483
compileSdk = 33
8584

85+
buildFeatures {
86+
buildConfig = true
87+
}
88+
8689
defaultConfig {
8790
minSdk = 24
88-
targetSdk = 33
8991
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
9092
testInstrumentationRunnerArguments += "clearPackageData" to "true"
9193
consumerProguardFiles += rootProject.file("configuration/consumer-rules.pro")
@@ -107,14 +109,14 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
107109
}
108110

109111
compileOptions {
110-
sourceCompatibility = JavaVersion.VERSION_1_8
111-
targetCompatibility = JavaVersion.VERSION_1_8
112+
sourceCompatibility = JavaVersion.VERSION_11
113+
targetCompatibility = JavaVersion.VERSION_11
112114
}
113115

114116
// Needed when running integration tests. The oauth2 library uses relies on two
115117
// dependencies (Apache's httpcore and httpclient), both of which include
116118
// META-INF/DEPENDENCIES. Tried a couple other options to no avail.
117-
packagingOptions {
119+
packaging {
118120
resources.excludes.add("META-INF/DEPENDENCIES")
119121
}
120122

build-logic/plugins/src/main/kotlin/ComponentConventionPlugin.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16+
import org.gradle.api.JavaVersion
1617
import org.gradle.api.Plugin
1718
import org.gradle.api.Project
19+
import org.gradle.kotlin.dsl.withType
20+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
21+
22+
val optInAnnotations = listOf(
23+
"com.amplifyframework.annotations.InternalApiWarning",
24+
"com.amplifyframework.annotations.InternalAmplifyApi"
25+
)
1826

1927
/**
2028
* Shared plugin for UI component libraries
@@ -25,6 +33,12 @@ class ComponentConventionPlugin : Plugin<Project> {
2533
pluginManager.apply("amplify.android.library")
2634
pluginManager.apply("amplify.android.publishing")
2735
pluginManager.apply("amplify.android.dokka")
36+
37+
tasks.withType<KotlinCompile>().configureEach {
38+
kotlinOptions {
39+
freeCompilerArgs = freeCompilerArgs + optInAnnotations.map { "-opt-in=$it" }
40+
}
41+
}
2842
}
2943
}
3044
}

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
agp = "7.3.1"
2+
agp = "8.0.0"
33
amplify = "2.8.7"
44
cameraX = "1.2.0"
55
compose = "1.3.2"
@@ -47,7 +47,7 @@ test-robolectric = "org.robolectric:robolectric:4.9.2"
4747

4848
# Dependencies for convention plugins
4949
plugin-android-gradle = { module = "com.android.tools.build:gradle", version.ref = "agp" }
50-
plugin-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
50+
plugin-kotlin-android = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
5151
plugin-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
5252
plugin-ktlint = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" }
5353

gradle/wrapper/gradle-wrapper.jar

1.52 KB
Binary file not shown.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Wed Nov 30 09:21:44 EST 2022
21
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
42
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
64
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)