diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt index bf759b3c..12fd998c 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/ApplicationPlugin.kt @@ -11,8 +11,8 @@ import com.android.build.gradle.internal.dsl.BaseAppModuleExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.the @Suppress("Unused") @@ -21,7 +21,7 @@ class ApplicationPlugin : Plugin { override fun apply(project: Project) { project.pluginManager.apply(AppPlugin::class) AndroidCommon.configure(project) - project.extensions.getByType().run { + project.extensions.configure { val minifySwitch = project.providers.environmentVariable("DISABLE_MINIFY") adbOptions.installOptions("--user 0") diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt index 6dff57a1..86742c24 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt @@ -7,15 +7,16 @@ import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.withType @Suppress("Unused") class DependencyUpdatesPlugin : Plugin { + override fun apply(project: Project) { project.pluginManager.apply(VersionsPlugin::class) project.pluginManager.apply(VersionCatalogUpdatePlugin::class) - project.tasks.withType().configureEach { + project.tasks.withType { rejectVersionIf { when (candidate.group) { "commons-codec", @@ -26,7 +27,7 @@ class DependencyUpdatesPlugin : Plugin { } checkForGradleUpdate = false } - project.extensions.getByType().run { + project.extensions.configure { keep.keepUnusedLibraries.set(true) } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinKaptPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinKaptPlugin.kt index a798ec8e..893b89d3 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinKaptPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinKaptPlugin.kt @@ -8,7 +8,7 @@ package app.passwordstore.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.configure import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin import org.jetbrains.kotlin.gradle.plugin.KaptExtension import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper @@ -22,7 +22,7 @@ class KotlinKaptPlugin : Plugin { apply(Kapt3GradleSubplugin::class) } project.afterEvaluate { - project.extensions.getByType().run { + project.extensions.configure { javacOptions { if (hasDaggerCompilerDependency()) { // https://dagger.dev/dev-guide/compiler-options#fastinit-mode diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt index 542bfeb6..a0342698 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/PublishedAndroidLibraryPlugin.kt @@ -10,7 +10,7 @@ import me.tylerbwong.gradle.metalava.extension.MetalavaExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.provideDelegate import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningPlugin @@ -25,18 +25,18 @@ class PublishedAndroidLibraryPlugin : Plugin { apply(SigningPlugin::class) apply("me.tylerbwong.gradle.metalava") } - project.extensions.getByType().run { + project.extensions.configure { publishToMavenCentral(SonatypeHost.DEFAULT, true) signAllPublications() } project.afterEvaluate { - project.extensions.getByType().run { + project.extensions.configure { val signingKey: String? by project val signingPassword: String? by project useInMemoryPgpKeys(signingKey, signingPassword) } } - project.extensions.getByType().run { + project.extensions.configure { documentation.set(Documentation.PUBLIC) inputKotlinNulls.set(true) outputKotlinNulls.set(true) diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt index 6807b6ef..813155b4 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/RenameArtifactsPlugin.kt @@ -7,7 +7,7 @@ import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.VariantOutputConfiguration import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.register @Suppress("Unused") @@ -15,7 +15,7 @@ class RenameArtifactsPlugin : Plugin { override fun apply(project: Project) { project.pluginManager.withPlugin("com.android.application") { - project.extensions.getByType().run { + project.extensions.configure { onVariants { variant -> project.tasks.register("collect${variant.name.capitalize()}Apks") { variantName.set(variant.name) diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt index 034c62f9..c377ee0f 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/SentryPlugin.kt @@ -8,14 +8,14 @@ import io.sentry.android.gradle.extensions.SentryPluginExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.configure @Suppress("Unused") class SentryPlugin : Plugin { override fun apply(project: Project) { project.pluginManager.withPlugin("com.android.application") { - project.extensions.getByType().run { + project.extensions.configure { onVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) { variant -> val sentryDsn = project.providers.environmentVariable(SENTRY_DSN_PROPERTY) @@ -25,7 +25,7 @@ class SentryPlugin : Plugin { } } project.plugins.apply(SentryPlugin::class) - project.extensions.getByType().run { + project.extensions.configure { autoUploadProguardMapping.set( project.providers.gradleProperty(SENTRY_UPLOAD_MAPPINGS_PROPERTY).isPresent ) @@ -38,6 +38,7 @@ class SentryPlugin : Plugin { } private companion object { + private const val SENTRY_DSN_PROPERTY = "SENTRY_DSN" private const val SENTRY_UPLOAD_MAPPINGS_PROPERTY = "sentryUploadMappings" } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt index 5fda1a25..b6b0a4ad 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/versioning/VersioningPlugin.kt @@ -13,7 +13,7 @@ import java.util.Properties import java.util.concurrent.atomic.AtomicBoolean import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.register import org.gradle.kotlin.dsl.withType @@ -45,11 +45,15 @@ class VersioningPlugin : Plugin { } project.plugins.withType { androidAppPluginApplied.set(true) - extensions.getByType().onVariants { variant -> - val mainOutput = - variant.outputs.single { it.outputType == VariantOutputConfiguration.OutputType.SINGLE } - mainOutput.versionName.set(versionName) - mainOutput.versionCode.set(versionCode) + extensions.configure { + onVariants { variant -> + val mainOutput = + variant.outputs.single { + it.outputType == VariantOutputConfiguration.OutputType.SINGLE + } + mainOutput.versionName.set(versionName) + mainOutput.versionCode.set(versionCode) + } } } val version = Semver(versionName)