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

Update to some new gradle 8.4 APIs #127

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 16 additions & 10 deletions keeper-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version libs.versions.kotlin.get()
`java-gradle-plugin`
id("org.jetbrains.dokka") version "1.8.20"
id("org.jetbrains.dokka") version "1.9.0"
alias(libs.plugins.mavenPublish)
alias(libs.plugins.binaryCompatibilityValidator)
id("org.jetbrains.kotlin.plugin.sam.with.receiver") version libs.versions.kotlin.get()
Expand All @@ -35,8 +35,8 @@ tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17) // Match AGP's requirement
// Because Gradle's Kotlin handling is stupid, this falls out of date quickly
apiVersion.set(KotlinVersion.KOTLIN_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
apiVersion.set(KotlinVersion.KOTLIN_1_9)
languageVersion.set(KotlinVersion.KOTLIN_1_9)
// freeCompilerArgs.add(listOf("-progressive"))
// We use class SAM conversions because lambdas compiled into invokedynamic are not
// Serializable, which causes accidental headaches with Gradle configuration caching. It's
Expand Down Expand Up @@ -91,11 +91,16 @@ tasks.withType<DokkaTask>().configureEach {
.toURL()
)
}

val agpBaseUrlProvider =
libs.versions.agp
.map { it.substringBeforeLast('.') }
.map { agpBaseVersion ->
"https://developer.android.com/reference/tools/gradle-api/$agpBaseVersion"
}
externalDocumentationLink {
packageListUrl.set(
URI("https://developer.android.com/reference/tools/gradle-api/7.3/package-list").toURL()
)
url.set(URI("https://developer.android.com/reference/tools/gradle-api/7.3/classes").toURL())
packageListUrl.set(agpBaseUrlProvider.map { "$it/package-list" }.map { URI(it).toURL() })
url.set(agpBaseUrlProvider.map { "$it/classes" }.map { URI(it).toURL() })
}
}
}
Expand All @@ -108,9 +113,10 @@ mavenPublishing {
// Fix missing implicit task dependency in Gradle's test kit
tasks.named("processTestResources") { dependsOn("pluginUnderTestMetadata") }

val addTestPlugin: Configuration = configurations.create("addTestPlugin")
// TODO how can we lazily chain this to other configurations?
val addTestPlugin = configurations.dependencyScope("addTestPlugin").get()

configurations { testImplementation.get().extendsFrom(addTestPlugin) }
configurations { testImplementation.configure { extendsFrom(addTestPlugin) } }

tasks.pluginUnderTestMetadata {
// make sure the test can access plugins for coordination.
Expand All @@ -123,7 +129,7 @@ dependencies {
compileOnly(libs.zipflinger)
compileOnly(libs.agp)

addTestPlugin(libs.agp)
addTestPlugin.invoke(libs.agp)
addTestPlugin(libs.kgp)
addTestPlugin(libs.kgp.api)
testImplementation(libs.javapoet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package com.slack.keeper
import java.util.Locale
import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.NamedDomainObjectProvider
import org.gradle.api.artifacts.DependencyScopeConfiguration
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFile
import org.gradle.api.file.RegularFileProperty
Expand Down Expand Up @@ -136,7 +137,7 @@ constructor(private val execOps: ExecOperations) : DefaultTask() {
enableAssertions: Property<Boolean>,
extensionJvmArgs: ListProperty<String>,
traceReferencesArgs: ListProperty<String>,
r8Configuration: Configuration
r8Configuration: NamedDomainObjectProvider<DependencyScopeConfiguration>
): InferAndroidTestKeepRules.() -> Unit = {
if (automaticallyAddR8Repo.get()) {
// This is the maven repo where r8 tagged releases are hosted. Only the r8 artifact is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ public class KeeperPlugin : Plugin<Project> {
) {
// Set up r8 configuration
val r8Configuration =
configurations.create(CONFIGURATION_NAME) {
configurations.dependencyScope(CONFIGURATION_NAME) {
description = "R8 dependencies for Keeper. This is used solely for the TraceReferences CLI"
isVisible = false
isCanBeConsumed = false
isCanBeResolved = true
defaultDependencies {
logger.debug("keeper r8 default version: $TRACE_REFERENCES_DEFAULT_VERSION")
add(project.dependencies.create("com.android.tools:r8:$TRACE_REFERENCES_DEFAULT_VERSION"))
Expand Down
Loading