[KPM] Implement KotlinExternalModelContainer

KT-51262
KT-51220
This commit is contained in:
sebastian.sellmair
2022-02-13 16:11:10 +01:00
committed by Space
parent 55448943af
commit f1655e5f4e
14 changed files with 332 additions and 6 deletions
@@ -7,6 +7,7 @@ plugins {
dependencies {
implementation(gradleKotlinDsl())
compileOnly(project(":kotlin-gradle-plugin"))
compileOnly(project(":kotlin-gradle-plugin-idea"))
compileOnly("com.android.tools.build:gradle:7.0.0")
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:OptIn(InternalKotlinGradlePluginApi::class)
package org.jetbrains.kotlin.gradle.android
import org.jetbrains.kotlin.gradle.kpm.KotlinExternalModelKey
import org.jetbrains.kotlin.gradle.kpm.idea.InternalKotlinGradlePluginApi
import java.io.File
import java.io.Serializable
internal val androidDslKey = KotlinExternalModelKey<AndroidDsl>()
class AndroidDsl : Serializable {
var compileSdk = 0
var isMinifyEnabled: Boolean = false
var androidManifest: File? = null
}
@@ -78,4 +78,9 @@ fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
androidVariant.getCompileClasspath(mainBytecodeKey),
project.getAndroidRuntimeJars()
)
val androidDsl = AndroidDsl()
androidDsl.androidManifest = project.file("AndroidManifest.xml")
androidDsl.compileSdk = 23
androidCommon.external[androidDslKey] = androidDsl
}
@@ -6,9 +6,10 @@
package org.jetbrains.kotlin.gradle.android
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinGradleFragment
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinGradleFragmentInternal
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinGradleModule
val KotlinGradleModule.androidCommon: KotlinGradleFragment
get() = fragments.findByName("android") ?: fragments.create("android") { fragment ->
val KotlinGradleModule.androidCommon: KotlinGradleFragmentInternal
get() = (fragments.findByName("android") ?: fragments.create("android") { fragment ->
fragment.refines(common)
}
}) as KotlinGradleFragmentInternal