Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Dependency Analysis Plugin Changelog

# Version 3.9.0
* (Reverted) Compiled against Kotlin 2.3.20. Compiling against Kotlin 2.2.21 again, with language level 2.2.

# Version 3.8.0
* [feat]: record lambda in binaryClassAccesses.
* [feat]: support analysis of a Gradle version catalog dependency.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.plugins.signing.Sign
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.tasks.DokkaGeneratePublicationTask

@Suppress("unused")
internal class BaseConventionPlugin(private val project: Project) {
Expand Down Expand Up @@ -80,33 +80,43 @@ internal class BaseConventionPlugin(private val project: Project) {
.map { it.toBoolean() }

val taskGraph = gradle.taskGraph
val isFunctionalTest: Provider<Boolean> = providers
.provider { taskGraph.hasTask(":functionalTest") }
val isFunctionalTest: Provider<Boolean> = providers.provider { taskGraph.hasTask(":functionalTest") }

tasks.withType(Sign::class.java).configureEach { t ->
with(t) {
inputs.property("version", publishedVersion)
inputs.property("is-snapshot", isSnapshot)
inputs.property("is-ci", isCi)
inputs.property("is-functional-test", isFunctionalTest)

// Don't sign snapshots
onlyIf("Not a snapshot") { !isSnapshot.get() }
onlyIf("Not a snapshot") {
!(inputs.properties["is-snapshot"] as Boolean)
}
// We currently don't support publishing from CI
onlyIf("release environment") { !isCi.get() }
onlyIf("release environment") {
!(inputs.properties["is-ci"] as Boolean)
}
// Don't sign when running functional tests
onlyIf("not running functional tests") { !isFunctionalTest.get() }
onlyIf("not running functional tests") {
!(inputs.properties["is-functional-test"] as Boolean)
}

doFirst {
logger.quiet("Signing v${publishedVersion.get()}")
val version = inputs.properties["version"] as String
logger.quiet("Signing v$version")
}
}
}

tasks.withType(DokkaTask::class.java).configureEach { t ->
t.inputs.property("is-functional-test", isFunctionalTest)
tasks.withType(DokkaGeneratePublicationTask::class.java).configureEach { t ->
val key = "is-functional-test"
t.inputs.property(key, isFunctionalTest)

// Don't sign when running functional tests
t.onlyIf("not running functional tests") { !isFunctionalTest.get() }
t.onlyIf("not running functional tests") {
!(t.inputs.properties[key] as Boolean)
}
}

configureMetalava()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class DagpExtension(

private fun setupPublishingRepo() {
// Don't validate because I don't want to wait 15min for my build to finish.
mavenPublish.publishToMavenCentral(automaticRelease = true, validateDeployment = false)
mavenPublish.publishToMavenCentral(automaticRelease = true)
mavenPublish.signAllPublications()

// We set the version explicitly because it seems there may be a race condition bug otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ internal class KotlinConfigurer(private val project: Project) {
private val versionCatalog = project.extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
private val javaTarget = versionCatalog.findVersion("javaTarget").orElseThrow().requiredVersion
private val kotlin = versionCatalog.findVersion("kotlin").get().requiredVersion

// this function expects strings of the form 2.x, not 2.x.y
private val kotlinVersion = KotlinVersion.fromVersion(kotlin.substringBeforeLast('.'))
private val kotlinLanguageVersion = versionCatalog.findVersion("kotlinLanguageVersion").get().requiredVersion
.toKotlinVersion()

fun configure(): Unit = project.run {
configureKotlinExtension()
configureKotlinTarget()
configureKotlinVersion()
}

private fun String.toKotlinVersion(): KotlinVersion = KotlinVersion.fromVersion(this)

private fun Project.configureKotlinExtension() {
project.extensions.getByType(KotlinJvmProjectExtension::class.java).run {
explicitApi()
Expand All @@ -34,9 +35,10 @@ internal class KotlinConfigurer(private val project: Project) {
private fun Project.configureKotlinTarget() {
tasks.withType(KotlinCompile::class.java).configureEach { t ->
t.compilerOptions {
// Ensure compatibility with Gradle 8.x. See https://docs.gradle.org/9.0.0/userguide/compatibility.html.
apiVersion.set(kotlinVersion)
languageVersion.set(kotlinVersion)
// Ensure compatibility with various versions of Gradle.
// See https://docs.gradle.org/9.4.1/userguide/compatibility.html.
apiVersion.set(kotlinLanguageVersion)
languageVersion.set(kotlinLanguageVersion)
jvmTarget.set(JvmTarget.fromTarget(javaTarget))
freeCompilerArgs.add(
// equivalent to JavaCompile's `options.release`
Expand All @@ -46,9 +48,7 @@ internal class KotlinConfigurer(private val project: Project) {
}
}

/**
* @see <a href="https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1537#issuecomment-3293306966">Issue 1537</a>
*/
/** @see <a href="https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1537#issuecomment-3293306966">Issue 1537</a> */
private fun Project.configureKotlinVersion() {
configurations.configureEach { c ->
if (c.isCanBeResolved) {
Expand Down
9 changes: 6 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ jdkVersion = "17"
jspecify = "1.0.0"
junit = "5.14.1"
# IMPORTANT: keep this version in sync with build-logic/build.gradle.kts
kotlin = "2.3.20"
kotlinForAndroidtests = "2.3.20"
kotlinMetadata = "2.3.20"
# See https://docs.gradle.org/9.4.1/userguide/compatibility.html.
# Gradle 9.x uses Kotlin language version 2.2
kotlinLanguageVersion = "2.2"
kotlin = "2.2.21"
kotlinForAndroidtests = "2.2.21"
kotlinMetadata = "2.2.21"
kotlinDokka = "2.2.0"
# Cannot be called kotlin-editor as it causes `libs.versions.kotlin.get()` to fail
kotlineditor-core = "0.20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ final class DominanceTreeProject extends AbstractAndroidProject {
}

final expectedTree = """\
10.05 MiB :app
10.01 MiB :app
+--- 8.32 MiB (1.69 MiB) androidx.appcompat:appcompat:1.7.1
| +--- 2.70 MiB (2.63 MiB) androidx.core:core:1.13.0
| | \\--- 0.07 MiB androidx.versionedparcelable:versionedparcelable:1.1.1
| +--- 1.43 MiB (0.02 MiB) org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4
| | +--- 1.41 MiB org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
| | | \\--- 1.41 MiB (1.41 MiB) org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
| | | \\--- org.jetbrains.kotlin:kotlin-stdlib-common:2.3.20
| | | \\--- org.jetbrains.kotlin:kotlin-stdlib-common:2.2.21
| | \\--- 0.00 MiB (0.00 MiB) org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0
| | \\--- 0.00 MiB org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0
| +--- 0.86 MiB (0.62 MiB) androidx.fragment:fragment:1.5.4
Expand Down Expand Up @@ -81,7 +81,7 @@ final class DominanceTreeProject extends AbstractAndroidProject {
| +--- 0.02 MiB androidx.lifecycle:lifecycle-livedata-core:2.6.2
| +--- 0.01 MiB androidx.arch.core:core-common:2.2.0
| \\--- 0.01 MiB androidx.annotation:annotation-experimental:1.4.0
+--- 1.74 MiB (1.72 MiB) org.jetbrains.kotlin:kotlin-stdlib:2.3.20
+--- 1.70 MiB (1.68 MiB) org.jetbrains.kotlin:kotlin-stdlib:2.2.21
| \\--- 0.02 MiB org.jetbrains:annotations:13.0
\\--- 0.00 MiB :lib""".stripIndent().readLines()
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ final class DuplicateDependencyVersionsProject extends AbstractAndroidProject {
junit-junit-4-12 = { module = "junit:junit", version = "4.12" }
junit-junit-4-13 = { module = "junit:junit", version = "4.13" }
org-hamcrest-hamcrest-core-1-3 = { module = "org.hamcrest:hamcrest-core", version = "1.3" }
org-jetbrains-kotlin-kotlin-stdlib-common-2-3-20 = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version = "2.3.20" }
org-jetbrains-kotlin-kotlin-stdlib-common-2-2-21 = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version = "2.2.21" }
org-jetbrains-kotlin-kotlin-stdlib-jdk7-1-8-0 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version = "1.8.0" }
org-jetbrains-kotlin-kotlin-stdlib-jdk8-1-8-0 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version = "1.8.0" }
org-jetbrains-kotlin-kotlin-stdlib-2-3-20 = { module = "org.jetbrains.kotlin:kotlin-stdlib", version = "2.3.20" }
org-jetbrains-kotlin-kotlin-stdlib-2-2-21 = { module = "org.jetbrains.kotlin:kotlin-stdlib", version = "2.2.21" }
org-jetbrains-kotlinx-kotlinx-coroutines-android-1-6-4 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.6.4" }
org-jetbrains-kotlinx-kotlinx-coroutines-core-jvm-1-6-4 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version = "1.6.4" }
org-jetbrains-kotlinx-kotlinx-coroutines-core-1-6-4 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" }
Expand Down
Loading