Add convention for Multiplatform Android

pull/1323/head
lihenggui 2 years ago
parent 85325f1267
commit 429dabc14b

@ -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<Project> {
override fun apply(target: Project) {
with(target) {
plugins.apply("org.jetbrains.kotlin.multiplatform")
configureAndroidKotlinMultiplatform()
}
}
}

@ -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<Project> {
override fun apply(target: Project) {
with(target) {

@ -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<KotlinMultiplatformExtension> {
jvm()
@ -79,3 +83,10 @@ internal fun Project.configureKotlinMultiplatform() {
}
}
}
internal fun Project.configureAndroidKotlinMultiplatform() {
extensions.configure<KotlinMultiplatformExtension> {
androidTarget()
}
configureKotlinMultiplatform()
}

Loading…
Cancel
Save