From b5627cabaf778f8d708f995654e28c4ed613dd6f Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Mon, 11 Dec 2023 18:37:38 -0500 Subject: [PATCH] Integrate buildconfig plugin to project to replace old version templates work (#677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses a nicer plugin to handle buildconfig constants --- agp-handlers/agp-handler-80/build.gradle.kts | 16 ------- agp-handlers/agp-handler-80/gradle.properties | 3 -- agp-handlers/agp-handler-82/build.gradle.kts | 26 ++++++++++++ agp-handlers/agp-handler-82/gradle.properties | 3 ++ .../gradle/agphandler/v82/AgpHandler82.kt} | 14 ++++--- agp-handlers/agp-handler-83/build.gradle.kts | 12 +++++- .../gradle/agphandler/v83/AgpHandler83.kt | 11 ++--- agp-handlers/agp-handler-api/build.gradle.kts | 5 +++ .../kotlin/slack/gradle/agp/AgpHandler.kt | 31 ++++++++++++++ .../slack/gradle/agp/AgpHandlersTest.kt | 42 +++++++++++++++++++ build.gradle.kts | 30 ++++++------- gradle/libs.versions.toml | 3 ++ settings.gradle.kts | 7 +++- skate-plugin/build.gradle.kts | 36 +++++----------- skate-plugin/version-templates/Version.kt | 22 ---------- slack-plugin/build.gradle.kts | 32 +++----------- .../gradle/StandardProjectConfigurations.kt | 7 ++-- .../version-templates/KotlinBuildConfig.kt | 9 ---- 18 files changed, 172 insertions(+), 137 deletions(-) delete mode 100644 agp-handlers/agp-handler-80/build.gradle.kts delete mode 100644 agp-handlers/agp-handler-80/gradle.properties create mode 100644 agp-handlers/agp-handler-82/build.gradle.kts create mode 100644 agp-handlers/agp-handler-82/gradle.properties rename agp-handlers/{agp-handler-80/src/main/kotlin/slack/gradle/agphandler/v80/AgpHandler80.kt => agp-handler-82/src/main/kotlin/slack/gradle/agphandler/v82/AgpHandler82.kt} (77%) create mode 100644 agp-handlers/agp-handler-api/src/test/kotlin/slack/gradle/agp/AgpHandlersTest.kt delete mode 100644 skate-plugin/version-templates/Version.kt delete mode 100644 slack-plugin/version-templates/KotlinBuildConfig.kt diff --git a/agp-handlers/agp-handler-80/build.gradle.kts b/agp-handlers/agp-handler-80/build.gradle.kts deleted file mode 100644 index 565fe621f..000000000 --- a/agp-handlers/agp-handler-80/build.gradle.kts +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - kotlin("jvm") - alias(libs.plugins.ksp) - alias(libs.plugins.mavenPublish) -} - -dependencies { - ksp(libs.autoService.ksp) - - api(projects.agpHandlers.agpHandlerApi) - - implementation(libs.autoService.annotations) - - compileOnly("com.android.tools.build:gradle:8.2.0") - compileOnly(gradleApi()) -} diff --git a/agp-handlers/agp-handler-80/gradle.properties b/agp-handlers/agp-handler-80/gradle.properties deleted file mode 100644 index 5718a91b8..000000000 --- a/agp-handlers/agp-handler-80/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -POM_ARTIFACT_ID=sgp-agp-handler-80 -POM_NAME=Slack Gradle Plugin (AGP Handler 8.0) -POM_DESCRIPTION=Slack Gradle Plugin (AGP Handler 8.0) diff --git a/agp-handlers/agp-handler-82/build.gradle.kts b/agp-handlers/agp-handler-82/build.gradle.kts new file mode 100644 index 000000000..658868fa2 --- /dev/null +++ b/agp-handlers/agp-handler-82/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + kotlin("jvm") + alias(libs.plugins.ksp) + alias(libs.plugins.mavenPublish) + alias(libs.plugins.buildConfig) +} + +buildConfig { + packageName("slack.gradle.agphandler.v82") + buildConfigField("String", "AGP_VERSION", libs.versions.agp.map { "\"$it\"" }) + useKotlinOutput { + topLevelConstants = true + internalVisibility = true + } +} + +dependencies { + ksp(libs.autoService.ksp) + + api(projects.agpHandlers.agpHandlerApi) + + implementation(libs.autoService.annotations) + + compileOnly(gradleApi()) + compileOnly(libs.agp) +} diff --git a/agp-handlers/agp-handler-82/gradle.properties b/agp-handlers/agp-handler-82/gradle.properties new file mode 100644 index 000000000..9c08ff4f0 --- /dev/null +++ b/agp-handlers/agp-handler-82/gradle.properties @@ -0,0 +1,3 @@ +POM_ARTIFACT_ID=sgp-agp-handler-82 +POM_NAME=Slack Gradle Plugin (AGP Handler 8.2) +POM_DESCRIPTION=Slack Gradle Plugin (AGP Handler 8.2) diff --git a/agp-handlers/agp-handler-80/src/main/kotlin/slack/gradle/agphandler/v80/AgpHandler80.kt b/agp-handlers/agp-handler-82/src/main/kotlin/slack/gradle/agphandler/v82/AgpHandler82.kt similarity index 77% rename from agp-handlers/agp-handler-80/src/main/kotlin/slack/gradle/agphandler/v80/AgpHandler80.kt rename to agp-handlers/agp-handler-82/src/main/kotlin/slack/gradle/agphandler/v82/AgpHandler82.kt index e3ce5956e..40a362cad 100644 --- a/agp-handlers/agp-handler-80/src/main/kotlin/slack/gradle/agphandler/v80/AgpHandler80.kt +++ b/agp-handlers/agp-handler-82/src/main/kotlin/slack/gradle/agphandler/v82/AgpHandler82.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package slack.gradle.agphandler.v80 +package slack.gradle.agphandler.v82 import com.android.build.api.AndroidPluginVersion import com.android.build.gradle.internal.SdkLocator @@ -21,9 +21,10 @@ import com.google.auto.service.AutoService import java.io.File import org.gradle.api.provider.ProviderFactory import slack.gradle.agp.AgpHandler +import slack.gradle.agp.computeAndroidPluginVersion import slack.gradle.agp.internal.NoOpIssueReporter -public class AgpHandler80 private constructor(override val agpVersion: AndroidPluginVersion) : +public class AgpHandler82 private constructor(override val agpVersion: AndroidPluginVersion) : AgpHandler { override fun getAndroidSdkDirectory(projectRootDir: File, providers: ProviderFactory): File = @@ -31,15 +32,16 @@ public class AgpHandler80 private constructor(override val agpVersion: AndroidPl @AutoService(AgpHandler.Factory::class) public class Factory : AgpHandler.Factory { - override val minVersion: AndroidPluginVersion = AndroidPluginVersion(8, 0, 0) + override val minVersion: AndroidPluginVersion by lazy { + computeAndroidPluginVersion(AGP_VERSION) + } - // TODO Remove once it's public - // https://issuetracker.google.com/issues/297440098 + // Public in AGP 8.3 https://issuetracker.google.com/issues/297440098 @Suppress("invisible_reference", "invisible_member") override val currentVersion: AndroidPluginVersion by lazy { com.android.build.api.extension.impl.CURRENT_AGP_VERSION } - override fun create(): AgpHandler = AgpHandler80(currentVersion) + override fun create(): AgpHandler = AgpHandler82(currentVersion) } } diff --git a/agp-handlers/agp-handler-83/build.gradle.kts b/agp-handlers/agp-handler-83/build.gradle.kts index cacbf5e85..5e81dbf58 100644 --- a/agp-handlers/agp-handler-83/build.gradle.kts +++ b/agp-handlers/agp-handler-83/build.gradle.kts @@ -2,6 +2,16 @@ plugins { kotlin("jvm") alias(libs.plugins.ksp) alias(libs.plugins.mavenPublish) + alias(libs.plugins.buildConfig) +} + +buildConfig { + packageName("slack.gradle.agphandler.v83") + buildConfigField("String", "AGP_VERSION", libs.versions.agpAlpha.map { "\"$it\"" }) + useKotlinOutput { + topLevelConstants = true + internalVisibility = true + } } dependencies { @@ -11,6 +21,6 @@ dependencies { implementation(libs.autoService.annotations) - compileOnly("com.android.tools.build:gradle:8.3.0-alpha17") compileOnly(gradleApi()) + compileOnly(libs.agpAlpha) } diff --git a/agp-handlers/agp-handler-83/src/main/kotlin/slack/gradle/agphandler/v83/AgpHandler83.kt b/agp-handlers/agp-handler-83/src/main/kotlin/slack/gradle/agphandler/v83/AgpHandler83.kt index 93be6bf92..97fed1b3e 100644 --- a/agp-handlers/agp-handler-83/src/main/kotlin/slack/gradle/agphandler/v83/AgpHandler83.kt +++ b/agp-handlers/agp-handler-83/src/main/kotlin/slack/gradle/agphandler/v83/AgpHandler83.kt @@ -22,6 +22,7 @@ import com.google.auto.service.AutoService import java.io.File import org.gradle.api.provider.ProviderFactory import slack.gradle.agp.AgpHandler +import slack.gradle.agp.computeAndroidPluginVersion import slack.gradle.agp.internal.NoOpIssueReporter public class AgpHandler83 private constructor(override val agpVersion: AndroidPluginVersion) : @@ -36,13 +37,9 @@ public class AgpHandler83 private constructor(override val agpVersion: AndroidPl @AutoService(AgpHandler.Factory::class) public class Factory : AgpHandler.Factory { - override val minVersion: AndroidPluginVersion = - AndroidPluginVersion( - 8, - 3, - 0, - ) - .alpha(13) + override val minVersion: AndroidPluginVersion by lazy { + computeAndroidPluginVersion(AGP_VERSION) + } override val currentVersion: AndroidPluginVersion by lazy { AndroidPluginVersion.getCurrent() } diff --git a/agp-handlers/agp-handler-api/build.gradle.kts b/agp-handlers/agp-handler-api/build.gradle.kts index 78b2ab898..4e96f8f5c 100644 --- a/agp-handlers/agp-handler-api/build.gradle.kts +++ b/agp-handlers/agp-handler-api/build.gradle.kts @@ -8,4 +8,9 @@ dependencies { compileOnly(gradleApi()) compileOnly(libs.agp) + + testImplementation(gradleApi()) + testImplementation(libs.agp) + testImplementation(libs.junit) + testImplementation(libs.truth) } diff --git a/agp-handlers/agp-handler-api/src/main/kotlin/slack/gradle/agp/AgpHandler.kt b/agp-handlers/agp-handler-api/src/main/kotlin/slack/gradle/agp/AgpHandler.kt index 297eff73d..15a98bccc 100644 --- a/agp-handlers/agp-handler-api/src/main/kotlin/slack/gradle/agp/AgpHandler.kt +++ b/agp-handlers/agp-handler-api/src/main/kotlin/slack/gradle/agp/AgpHandler.kt @@ -19,6 +19,8 @@ import com.android.build.api.AndroidPluginVersion import java.io.File import org.gradle.api.provider.ProviderFactory +private val NUMBER_REGEX = Regex("d") + /** An interface for handling different AGP versions via (mostly) version-agnostic APIs. */ public interface AgpHandler { /** The current AGP version. */ @@ -46,3 +48,32 @@ public interface AgpHandler { /** Returns a new [AndroidPluginVersion] with any preview information stripped. */ public val AndroidPluginVersion.baseVersion: AndroidPluginVersion get() = AndroidPluginVersion(major, minor, micro) + +/** Returns a computed [AndroidPluginVersion] for the given [input] version string. */ +public fun computeAndroidPluginVersion(input: String): AndroidPluginVersion { + val split = input.split('-') + require(split.isNotEmpty()) { "Could not parse AGP version from '$input'" } + val baseVersionNumberStrings = split[0].split('.') + val (major, minor, micro) = + Array(3) { index -> + if (baseVersionNumberStrings.size >= index + 1) { + baseVersionNumberStrings[index].toInt() + } else { + 0 + } + } + val baseVersion = AndroidPluginVersion(major, minor, micro) + return if (split.size == 2) { + // There's a preview here + val (previewType, number) = split[1].partition { !it.isDigit() } + when (previewType) { + "alpha" -> baseVersion.alpha(number.toInt()) + "beta" -> baseVersion.beta(number.toInt()) + "rc" -> baseVersion.rc(number.toInt()) + "dev" -> baseVersion.dev() + else -> error("Unrecognized preview type '$previewType' with version '$number'") + } + } else { + baseVersion + } +} diff --git a/agp-handlers/agp-handler-api/src/test/kotlin/slack/gradle/agp/AgpHandlersTest.kt b/agp-handlers/agp-handler-api/src/test/kotlin/slack/gradle/agp/AgpHandlersTest.kt new file mode 100644 index 000000000..3a50c8176 --- /dev/null +++ b/agp-handlers/agp-handler-api/src/test/kotlin/slack/gradle/agp/AgpHandlersTest.kt @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Slack Technologies, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package slack.gradle.agp + +import com.google.common.truth.Truth.assertThat +import org.junit.Test + +class AgpHandlersTest { + @Test + fun parseTest() { + assertVersion("8.0.0-alpha01") + assertVersion("8.0.0-beta01") + assertVersion("8.0.0-beta11") + assertVersion("8.0.0-rc11") + assertVersion("8.0.0-dev") + } + + private fun assertVersion(version: String) { + val versionToCheck = + if (version[version.lastIndex - 1] == '0') { + // AGP doesn't print the leading zero in their versions here + version.substring(0, version.lastIndex - 1) + version[version.lastIndex] + } else { + version + } + assertThat(computeAndroidPluginVersion(version).toString()) + .isEqualTo("Android Gradle Plugin version $versionToCheck") + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 85c5ee22b..235e1d2a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,6 +15,7 @@ */ import com.diffplug.gradle.spotless.KotlinExtension import com.diffplug.gradle.spotless.SpotlessExtension +import com.github.gmazzo.gradle.plugins.BuildConfigExtension import com.vanniktech.maven.publish.MavenPublishBaseExtension import dev.bmac.gradle.intellij.GenerateBlockMapTask import dev.bmac.gradle.intellij.PluginUploader @@ -56,6 +57,7 @@ plugins { alias(libs.plugins.sortDependencies) apply false alias(libs.plugins.intellij) apply false alias(libs.plugins.pluginUploader) apply false + alias(libs.plugins.buildConfig) apply false } configure { @@ -167,14 +169,6 @@ data class KotlinBuildConfig(val kotlin: String) { // https://kotlinlang.org/docs/whatsnew1520.html#support-for-jspecify-nullness-annotations "-Xjspecify-annotations=strict", ) - - fun asTemplatesMap(): Map { - return mapOf( - "kotlinCompilerArgs" to kotlinCompilerArgs.joinToString(", ") { "\"$it\"" }, - "kotlinJvmCompilerArgs" to kotlinJvmCompilerArgs.joinToString(", ") { "\"$it\"" }, - "kotlinVersion" to kotlin - ) - } } tasks.dokkaHtmlMultiModule { @@ -186,16 +180,18 @@ val kotlinVersion = libs.versions.kotlin.get() val kotlinBuildConfig = KotlinBuildConfig(kotlinVersion) subprojects { - // This is overly magic but necessary in order to plumb this - // down to subprojects - tasks - .withType() - .matching { it.name == "copyVersionTemplates" } - .configureEach { - val templatesMap = kotlinBuildConfig.asTemplatesMap() - inputs.property("buildversions", templatesMap.hashCode()) - expand(templatesMap) + if (project.path == ":slack-plugin") { + project.pluginManager.withPlugin("com.github.gmazzo.buildconfig") { + configure { + buildConfigField("String", "KOTLIN_VERSION", "\"$kotlinVersion\"") + // Using Any here due to https://github.com/gmazzo/gradle-buildconfig-plugin/issues/9 + buildConfigField("kotlin.Any", "KOTLIN_COMPILER_ARGS", + "listOf(${kotlinBuildConfig.kotlinCompilerArgs.joinToString(", ") { "\"$it\"" }})") + buildConfigField("kotlin.Any", "KOTLIN_JVM_COMPILER_ARGS", + "listOf(${kotlinBuildConfig.kotlinJvmCompilerArgs.joinToString(", ") { "\"$it\"" }})") + } } + } pluginManager.withPlugin("java") { configure { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ad3bb7d10..a6927f886 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,6 @@ [versions] agp = "8.2.0" +agpAlpha = "8.3.0-alpha17" anvil = "2.4.8" bugsnagGradle = "8.1.0" compose-jb = "1.5.11" @@ -28,6 +29,7 @@ wire = "4.9.3" [plugins] bestPracticesPlugin = { id = "com.autonomousapps.plugin-best-practices-plugin", version = "0.10" } +buildConfig = { id = "com.github.gmazzo.buildconfig", version = "4.2.0" } dependencyAnalysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependencyAnalysisPlugin" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } @@ -46,6 +48,7 @@ wire = { id = "com.squareup.wire", version.ref = "wire" } [libraries] agp = { module = "com.android.tools.build:gradle", version.ref = "agp" } +agpAlpha = { module = "com.android.tools.build:gradle", version.ref = "agpAlpha" } autoService-annotations = "com.google.auto.service:auto-service-annotations:1.1.1" autoService-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.1.0" bugsnag = "com.bugsnag:bugsnag:3.7.1" diff --git a/settings.gradle.kts b/settings.gradle.kts index ac55489d3..25d7c44d1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -128,6 +128,11 @@ pluginManagement { exclusiveContent { forRepository(::gradlePluginPortal) filter { + includeModule("com.github.gmazzo.buildconfig", "plugin") + includeModule( + "com.github.gmazzo.buildconfig", + "com.github.gmazzo.buildconfig.gradle.plugin" + ) includeModule("com.github.ben-manes", "gradle-versions-plugin") includeModule( "com.github.ben-manes.versions", @@ -174,7 +179,7 @@ rootProject.name = "slack-gradle-plugin" // Please keep these in alphabetical order! include( - ":agp-handlers:agp-handler-80", + ":agp-handlers:agp-handler-82", ":agp-handlers:agp-handler-83", ":agp-handlers:agp-handler-api", ":skate-plugin", diff --git a/skate-plugin/build.gradle.kts b/skate-plugin/build.gradle.kts index e39235253..42391ccda 100644 --- a/skate-plugin/build.gradle.kts +++ b/skate-plugin/build.gradle.kts @@ -1,5 +1,4 @@ import com.jetbrains.plugin.structure.base.utils.exists -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.nio.file.Paths import java.util.Locale import kotlin.io.path.readText @@ -9,6 +8,7 @@ plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.intellij) alias(libs.plugins.pluginUploader) + alias(libs.plugins.buildConfig) } group = "com.slack.intellij" @@ -61,32 +61,16 @@ fun readGitRepoCommit(): String? { } } -// region Version.kt template for setting the project version in the build -sourceSets { - main { java.srcDir(layout.buildDirectory.dir("generated/sources/version-templates/kotlin/main")) } -} - -val copyVersionTemplatesProvider = - tasks.register("copySkateVersionTemplates") { - inputs.property("version", project.property("VERSION_NAME")) - from(project.layout.projectDirectory.dir("version-templates")) - into(project.layout.buildDirectory.dir("generated/sources/version-templates/kotlin/main")) - expand( - mapOf( - "projectVersion" to project.property("VERSION_NAME").toString(), - "bugsnagKey" to project.findProperty("SgpIntellijBugsnagKey")?.toString().orEmpty(), - "gitSha" to readGitRepoCommit().orEmpty(), - ) - ) - filteringCharset = "UTF-8" +buildConfig { + packageName("com.slack.sgp.intellij") + buildConfigField("String", "VERSION", "\"${project.property("VERSION_NAME")}\"") + buildConfigField("String", "BUGSNAG_KEY", "\"${project.findProperty("SgpIntellijBugsnagKey")?.toString().orEmpty()}\"") + buildConfigField("String", "GIT_SHA", provider { "\"${readGitRepoCommit().orEmpty()}\"" }) + useKotlinOutput { + topLevelConstants = true + internalVisibility = true } - -tasks.withType().configureEach { dependsOn(copyVersionTemplatesProvider) } - -tasks - .matching { it.name == "kotlinSourcesJar" } - .configureEach { dependsOn(copyVersionTemplatesProvider) } -// endregion +} dependencies { implementation(libs.bugsnag) { exclude(group = "org.slf4j") } diff --git a/skate-plugin/version-templates/Version.kt b/skate-plugin/version-templates/Version.kt deleted file mode 100644 index 220db212d..000000000 --- a/skate-plugin/version-templates/Version.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2023 Slack LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@file:JvmName("Version") - -package com.slack.sgp.intellij - -internal const val VERSION = "$projectVersion" -internal const val BUGSNAG_KEY = "$bugsnagKey" -internal const val GIT_SHA = "$gitSha" diff --git a/slack-plugin/build.gradle.kts b/slack-plugin/build.gradle.kts index e6d0eb627..6ea8206c9 100644 --- a/slack-plugin/build.gradle.kts +++ b/slack-plugin/build.gradle.kts @@ -6,6 +6,7 @@ plugins { alias(libs.plugins.mavenPublish) alias(libs.plugins.bestPracticesPlugin) alias(libs.plugins.moshix) + alias(libs.plugins.buildConfig) } gradlePlugin { @@ -23,31 +24,13 @@ gradlePlugin { } } -sourceSets { - main.configure { - java.srcDir( - project.layout.buildDirectory.dir("generated/sources/version-templates/kotlin/main") - ) +buildConfig { + packageName("slack.gradle.dependencies") + useKotlinOutput { + internalVisibility = true } } -// NOTE: DON'T CHANGE THIS TASK NAME WITHOUT CHANGING IT IN THE ROOT BUILD FILE TOO! -val copyVersionTemplatesProvider = - tasks.register("copyVersionTemplates") { - from(project.layout.projectDirectory.dir("version-templates")) - into(project.layout.buildDirectory.dir("generated/sources/version-templates/kotlin/main")) - filteringCharset = "UTF-8" - - doFirst { - if (destinationDir.exists()) { - // Clear output dir first if anything is present - destinationDir.listFiles()?.forEach { it.delete() } - } - } - } - -tasks.named("compileKotlin") { dependsOn(copyVersionTemplatesProvider) } - // Copy our hooks into resources for InstallCommitHooks tasks.named("processResources") { from(rootProject.layout.projectDirectory.dir("config/git/hooks")) { @@ -56,9 +39,6 @@ tasks.named("processResources") { } } -// Necessary for gradle exec optimizations in gradle 8 -tasks.matching { it.name == "sourcesJar" }.configureEach { dependsOn(copyVersionTemplatesProvider) } - moshi { enableSealed.set(true) } dependencies { @@ -66,7 +46,7 @@ dependencies { api(libs.okhttp) // Better I/O api(libs.okio) - api(projects.agpHandlers.agpHandler80) + api(projects.agpHandlers.agpHandler82) api(projects.agpHandlers.agpHandler83) api(projects.agpHandlers.agpHandlerApi) diff --git a/slack-plugin/src/main/kotlin/slack/gradle/StandardProjectConfigurations.kt b/slack-plugin/src/main/kotlin/slack/gradle/StandardProjectConfigurations.kt index 383b525c0..ce975591c 100644 --- a/slack-plugin/src/main/kotlin/slack/gradle/StandardProjectConfigurations.kt +++ b/slack-plugin/src/main/kotlin/slack/gradle/StandardProjectConfigurations.kt @@ -63,7 +63,7 @@ import slack.dependencyrake.RakeDependencies import slack.gradle.AptOptionsConfig.AptOptionsConfigurer import slack.gradle.AptOptionsConfigs.invoke import slack.gradle.avoidance.ComputeAffectedProjectsTask -import slack.gradle.dependencies.KotlinBuildConfig +import slack.gradle.dependencies.BuildConfig import slack.gradle.dependencies.SlackDependencies import slack.gradle.lint.DetektTasks import slack.gradle.lint.LintTasks @@ -104,7 +104,7 @@ internal class StandardProjectConfigurations( private val kotlinCompilerArgs = mutableListOf() .apply { - addAll(KotlinBuildConfig.kotlinCompilerArgs) + @Suppress("UNCHECKED_CAST") addAll(BuildConfig.KOTLIN_COMPILER_ARGS as List) // Left as a toe-hold for any future dynamic arguments } .distinct() @@ -913,7 +913,8 @@ internal class StandardProjectConfigurations( jvmTarget.set(JvmTarget.fromTarget(actualJvmTarget)) // Potentially useful for static analysis or annotation processors javaParameters.set(true) - freeCompilerArgs.addAll(KotlinBuildConfig.kotlinJvmCompilerArgs) + @Suppress("UNCHECKED_CAST") + freeCompilerArgs.addAll(BuildConfig.KOTLIN_JVM_COMPILER_ARGS as List) // Set the module name to a dashified version of the project path to ensure uniqueness // in created .kotlin_module files diff --git a/slack-plugin/version-templates/KotlinBuildConfig.kt b/slack-plugin/version-templates/KotlinBuildConfig.kt deleted file mode 100644 index d8484a148..000000000 --- a/slack-plugin/version-templates/KotlinBuildConfig.kt +++ /dev/null @@ -1,9 +0,0 @@ -@file:JvmName("KotlinBuildConfig") - -package slack.gradle.dependencies - -internal object KotlinBuildConfig { - const val kotlin = "$kotlinVersion" - val kotlinCompilerArgs = listOf($kotlinCompilerArgs) - val kotlinJvmCompilerArgs = listOf($kotlinJvmCompilerArgs) -} \ No newline at end of file