Skip to content

Commit 0bc8d34

Browse files
chore: revert to Kotlin 2.2.21 with language level 2.2.
1 parent 559fef6 commit 0bc8d34

5 files changed

Lines changed: 40 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Dependency Analysis Plugin Changelog
22

3+
# Version 3.8.0
4+
* (Reverted) Compiled against Kotlin 2.3.20. Compiling against Kotlin 2.2.21 again, with language level 2.2.
5+
36
# Version 3.8.0
47
* [feat]: record lambda in binaryClassAccesses.
58
* [feat]: support analysis of a Gradle version catalog dependency.

build-logic/convention/src/main/kotlin/com/autonomousapps/convention/BaseConventionPlugin.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import org.gradle.api.tasks.compile.JavaCompile
1313
import org.gradle.api.tasks.testing.Test
1414
import org.gradle.jvm.toolchain.JavaLanguageVersion
1515
import org.gradle.plugins.signing.Sign
16-
import org.jetbrains.dokka.gradle.DokkaTask
16+
import org.jetbrains.dokka.gradle.tasks.DokkaGeneratePublicationTask
1717

1818
@Suppress("unused")
1919
internal class BaseConventionPlugin(private val project: Project) {
@@ -80,33 +80,43 @@ internal class BaseConventionPlugin(private val project: Project) {
8080
.map { it.toBoolean() }
8181

8282
val taskGraph = gradle.taskGraph
83-
val isFunctionalTest: Provider<Boolean> = providers
84-
.provider { taskGraph.hasTask(":functionalTest") }
83+
val isFunctionalTest: Provider<Boolean> = providers.provider { taskGraph.hasTask(":functionalTest") }
8584

8685
tasks.withType(Sign::class.java).configureEach { t ->
8786
with(t) {
8887
inputs.property("version", publishedVersion)
88+
inputs.property("is-snapshot", isSnapshot)
8989
inputs.property("is-ci", isCi)
9090
inputs.property("is-functional-test", isFunctionalTest)
9191

9292
// Don't sign snapshots
93-
onlyIf("Not a snapshot") { !isSnapshot.get() }
93+
onlyIf("Not a snapshot") {
94+
!(inputs.properties["is-snapshot"] as Boolean)
95+
}
9496
// We currently don't support publishing from CI
95-
onlyIf("release environment") { !isCi.get() }
97+
onlyIf("release environment") {
98+
!(inputs.properties["is-ci"] as Boolean)
99+
}
96100
// Don't sign when running functional tests
97-
onlyIf("not running functional tests") { !isFunctionalTest.get() }
101+
onlyIf("not running functional tests") {
102+
!(inputs.properties["is-functional-test"] as Boolean)
103+
}
98104

99105
doFirst {
100-
logger.quiet("Signing v${publishedVersion.get()}")
106+
val version = inputs.properties["version"] as String
107+
logger.quiet("Signing v$version")
101108
}
102109
}
103110
}
104111

105-
tasks.withType(DokkaTask::class.java).configureEach { t ->
106-
t.inputs.property("is-functional-test", isFunctionalTest)
112+
tasks.withType(DokkaGeneratePublicationTask::class.java).configureEach { t ->
113+
val key = "is-functional-test"
114+
t.inputs.property(key, isFunctionalTest)
107115

108116
// Don't sign when running functional tests
109-
t.onlyIf("not running functional tests") { !isFunctionalTest.get() }
117+
t.onlyIf("not running functional tests") {
118+
!(t.inputs.properties[key] as Boolean)
119+
}
110120
}
111121

112122
configureMetalava()

build-logic/convention/src/main/kotlin/com/autonomousapps/convention/internal/kotlin/KotlinConfigurer.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ internal class KotlinConfigurer(private val project: Project) {
1414
private val versionCatalog = project.extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
1515
private val javaTarget = versionCatalog.findVersion("javaTarget").orElseThrow().requiredVersion
1616
private val kotlin = versionCatalog.findVersion("kotlin").get().requiredVersion
17-
18-
// this function expects strings of the form 2.x, not 2.x.y
19-
private val kotlinVersion = KotlinVersion.fromVersion(kotlin.substringBeforeLast('.'))
17+
private val kotlinLanguageVersion = versionCatalog.findVersion("kotlinLanguageVersion").get().requiredVersion
18+
.toKotlinVersion()
2019

2120
fun configure(): Unit = project.run {
2221
configureKotlinExtension()
2322
configureKotlinTarget()
2423
configureKotlinVersion()
2524
}
2625

26+
private fun String.toKotlinVersion(): KotlinVersion = KotlinVersion.fromVersion(this)
27+
2728
private fun Project.configureKotlinExtension() {
2829
project.extensions.getByType(KotlinJvmProjectExtension::class.java).run {
2930
explicitApi()
@@ -34,9 +35,10 @@ internal class KotlinConfigurer(private val project: Project) {
3435
private fun Project.configureKotlinTarget() {
3536
tasks.withType(KotlinCompile::class.java).configureEach { t ->
3637
t.compilerOptions {
37-
// Ensure compatibility with Gradle 8.x. See https://docs.gradle.org/9.0.0/userguide/compatibility.html.
38-
apiVersion.set(kotlinVersion)
39-
languageVersion.set(kotlinVersion)
38+
// Ensure compatibility with various versions of Gradle.
39+
// See https://docs.gradle.org/9.4.1/userguide/compatibility.html.
40+
apiVersion.set(kotlinLanguageVersion)
41+
languageVersion.set(kotlinLanguageVersion)
4042
jvmTarget.set(JvmTarget.fromTarget(javaTarget))
4143
freeCompilerArgs.add(
4244
// equivalent to JavaCompile's `options.release`
@@ -46,9 +48,7 @@ internal class KotlinConfigurer(private val project: Project) {
4648
}
4749
}
4850

49-
/**
50-
* @see <a href="https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1537#issuecomment-3293306966">Issue 1537</a>
51-
*/
51+
/** @see <a href="https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1537#issuecomment-3293306966">Issue 1537</a> */
5252
private fun Project.configureKotlinVersion() {
5353
configurations.configureEach { c ->
5454
if (c.isCanBeResolved) {

gradle/libs.versions.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ jdkVersion = "17"
2323
jspecify = "1.0.0"
2424
junit = "5.14.1"
2525
# IMPORTANT: keep this version in sync with build-logic/build.gradle.kts
26-
kotlin = "2.3.20"
27-
kotlinForAndroidtests = "2.3.20"
28-
kotlinMetadata = "2.3.20"
26+
# See https://docs.gradle.org/9.4.1/userguide/compatibility.html.
27+
# Gradle 9.x uses Kotlin language version 2.2
28+
kotlinLanguageVersion = "2.2"
29+
kotlin = "2.2.21"
30+
kotlinForAndroidtests = "2.2.21"
31+
kotlinMetadata = "2.2.21"
2932
kotlinDokka = "2.2.0"
3033
# Cannot be called kotlin-editor as it causes `libs.versions.kotlin.get()` to fail
3134
kotlineditor-core = "0.20"

src/functionalTest/groovy/com/autonomousapps/android/projects/DuplicateDependencyVersionsProject.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ final class DuplicateDependencyVersionsProject extends AbstractAndroidProject {
124124
junit-junit-4-12 = { module = "junit:junit", version = "4.12" }
125125
junit-junit-4-13 = { module = "junit:junit", version = "4.13" }
126126
org-hamcrest-hamcrest-core-1-3 = { module = "org.hamcrest:hamcrest-core", version = "1.3" }
127-
org-jetbrains-kotlin-kotlin-stdlib-common-2-3-20 = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version = "2.3.20" }
127+
org-jetbrains-kotlin-kotlin-stdlib-common-2-2-21 = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version = "2.2.21" }
128128
org-jetbrains-kotlin-kotlin-stdlib-jdk7-1-8-0 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version = "1.8.0" }
129129
org-jetbrains-kotlin-kotlin-stdlib-jdk8-1-8-0 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version = "1.8.0" }
130-
org-jetbrains-kotlin-kotlin-stdlib-2-3-20 = { module = "org.jetbrains.kotlin:kotlin-stdlib", version = "2.3.20" }
130+
org-jetbrains-kotlin-kotlin-stdlib-2-2-21 = { module = "org.jetbrains.kotlin:kotlin-stdlib", version = "2.2.21" }
131131
org-jetbrains-kotlinx-kotlinx-coroutines-android-1-6-4 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.6.4" }
132132
org-jetbrains-kotlinx-kotlinx-coroutines-core-jvm-1-6-4 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version = "1.6.4" }
133133
org-jetbrains-kotlinx-kotlinx-coroutines-core-1-6-4 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" }

0 commit comments

Comments
 (0)