diff --git a/build-logic/convention/src/main/kotlin/KmpAndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/KmpAndroidLibraryConventionPlugin.kt new file mode 100644 index 000000000..e35d844ef --- /dev/null +++ b/build-logic/convention/src/main/kotlin/KmpAndroidLibraryConventionPlugin.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * 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. + */ + +import com.google.samples.apps.nowinandroid.configureAndroidKotlinMultiplatform +import org.gradle.api.Plugin +import org.gradle.api.Project +class KmpAndroidLibraryConventionPlugin: Plugin { + override fun apply(target: Project) { + with(target) { + plugins.apply("org.jetbrains.kotlin.multiplatform") + configureAndroidKotlinMultiplatform() + } + } +} diff --git a/build-logic/convention/src/main/kotlin/KmpLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/KmpLibraryConventionPlugin.kt index ed9a20f47..d2a73858c 100644 --- a/build-logic/convention/src/main/kotlin/KmpLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/KmpLibraryConventionPlugin.kt @@ -18,10 +18,6 @@ import com.google.samples.apps.nowinandroid.configureKotlinMultiplatform import org.gradle.api.Plugin import org.gradle.api.Project -/** - * A plugin that applies the Kotlin Multiplatform plugin and configures it for the project. - * https://github.com/cashapp/sqldelight/blob/master/buildLogic/multiplatform-convention/src/main/kotlin/app/cash/sqldelight/multiplatform/MultiplatformConventions.kt - */ class KmpLibraryConventionPlugin: Plugin { override fun apply(target: Project) { with(target) { diff --git a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinMultiplatform.kt b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinMultiplatform.kt index 80ac2dbdd..355e705b5 100644 --- a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinMultiplatform.kt +++ b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinMultiplatform.kt @@ -21,6 +21,10 @@ import org.gradle.kotlin.dsl.configure import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.konan.target.HostManager +/** + * A plugin that applies the Kotlin Multiplatform plugin and configures it for the project. + * https://github.com/cashapp/sqldelight/blob/master/buildLogic/multiplatform-convention/src/main/kotlin/app/cash/sqldelight/multiplatform/MultiplatformConventions.kt + */ internal fun Project.configureKotlinMultiplatform() { extensions.configure { jvm() @@ -79,3 +83,10 @@ internal fun Project.configureKotlinMultiplatform() { } } } + +internal fun Project.configureAndroidKotlinMultiplatform() { + extensions.configure { + androidTarget() + } + configureKotlinMultiplatform() +}