Wizard: correctly add Kotlin dependencies to singleplatform modules with gradle dsl build system
#KT-35695 fixed
This commit is contained in:
+1
-2
@@ -15,9 +15,8 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation 'androidx.core:core-ktx:1.1.0'
|
implementation 'androidx.core:core-ktx:1.1.0'
|
||||||
implementation kotlin('stdlib-jdk7')
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation kotlin('stdlib-jdk8')
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7'
|
||||||
}
|
}
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 29
|
||||||
|
|||||||
+1
-1
@@ -8,5 +8,5 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('stdlib-jdk8')
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||||
}
|
}
|
||||||
+11
-3
@@ -113,6 +113,8 @@ abstract class KotlinLibraryDependencyIR(
|
|||||||
override val version: Version,
|
override val version: Version,
|
||||||
override val dependencyType: DependencyType
|
override val dependencyType: DependencyType
|
||||||
) : LibraryDependencyIR {
|
) : LibraryDependencyIR {
|
||||||
|
abstract val isInMppModule: Boolean
|
||||||
|
|
||||||
override val artifact: LibraryArtifact
|
override val artifact: LibraryArtifact
|
||||||
get() = MavenArtifact(
|
get() = MavenArtifact(
|
||||||
MAVEN_CENTRAL,
|
MAVEN_CENTRAL,
|
||||||
@@ -123,9 +125,13 @@ abstract class KotlinLibraryDependencyIR(
|
|||||||
override fun BuildFilePrinter.render() {
|
override fun BuildFilePrinter.render() {
|
||||||
when (this) {
|
when (this) {
|
||||||
is GradlePrinter -> call(dependencyType.gradleName) {
|
is GradlePrinter -> call(dependencyType.gradleName) {
|
||||||
+"kotlin("
|
if (GradlePrinter.GradleDsl.KOTLIN == dsl || isInMppModule) {
|
||||||
+artifactName.quotified
|
+"kotlin("
|
||||||
+")"
|
+artifactName.quotified
|
||||||
|
+")"
|
||||||
|
} else {
|
||||||
|
+"org.jetbrains.kotlin:kotlin-$artifactName".quotified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is MavenPrinter -> node("dependency") {
|
is MavenPrinter -> node("dependency") {
|
||||||
singleLineNode("groupId") { +"org.jetbrains.kotlin" }
|
singleLineNode("groupId") { +"org.jetbrains.kotlin" }
|
||||||
@@ -144,6 +150,7 @@ abstract class KotlinLibraryDependencyIR(
|
|||||||
|
|
||||||
data class KotlinStdlibDependencyIR(
|
data class KotlinStdlibDependencyIR(
|
||||||
val type: StdlibType,
|
val type: StdlibType,
|
||||||
|
override val isInMppModule: Boolean,
|
||||||
override val version: Version,
|
override val version: Version,
|
||||||
override val dependencyType: DependencyType
|
override val dependencyType: DependencyType
|
||||||
) : KotlinLibraryDependencyIR(type.artifact, version, dependencyType) {
|
) : KotlinLibraryDependencyIR(type.artifact, version, dependencyType) {
|
||||||
@@ -152,6 +159,7 @@ data class KotlinStdlibDependencyIR(
|
|||||||
|
|
||||||
data class KotlinArbitraryDependencyIR(
|
data class KotlinArbitraryDependencyIR(
|
||||||
val name: String,
|
val name: String,
|
||||||
|
override val isInMppModule: Boolean,
|
||||||
override val version: Version,
|
override val version: Version,
|
||||||
override val dependencyType: DependencyType
|
override val dependencyType: DependencyType
|
||||||
) : KotlinLibraryDependencyIR(name, version, dependencyType) {
|
) : KotlinLibraryDependencyIR(name, version, dependencyType) {
|
||||||
|
|||||||
+12
-2
@@ -105,7 +105,12 @@ class ModulesToIRsConverter(
|
|||||||
+configurator.createModuleIRs(data, module)
|
+configurator.createModuleIRs(data, module)
|
||||||
addIfNotNull(
|
addIfNotNull(
|
||||||
configurator.createStdlibType(data, module)?.let { stdlibType ->
|
configurator.createStdlibType(data, module)?.let { stdlibType ->
|
||||||
KotlinStdlibDependencyIR(stdlibType, kotlinVersion, DependencyType.MAIN)
|
KotlinStdlibDependencyIR(
|
||||||
|
type = stdlibType,
|
||||||
|
isInMppModule = false,
|
||||||
|
version = kotlinVersion,
|
||||||
|
dependencyType = DependencyType.MAIN
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -179,7 +184,12 @@ class ModulesToIRsConverter(
|
|||||||
if (sourceset.sourcesetType == SourcesetType.main) {
|
if (sourceset.sourcesetType == SourcesetType.main) {
|
||||||
addIfNotNull(
|
addIfNotNull(
|
||||||
target.configurator.createStdlibType(data, target)?.let { stdlibType ->
|
target.configurator.createStdlibType(data, target)?.let { stdlibType ->
|
||||||
KotlinStdlibDependencyIR(stdlibType, data.kotlinVersion, DependencyType.MAIN)
|
KotlinStdlibDependencyIR(
|
||||||
|
type = stdlibType,
|
||||||
|
isInMppModule = true,
|
||||||
|
version = data.kotlinVersion,
|
||||||
|
dependencyType = DependencyType.MAIN
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModuleType
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModuleType
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.ModuleKind
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.SourcesetType
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.SourcesetType
|
||||||
|
|
||||||
class KotlinTestTemplate : Template() {
|
class KotlinTestTemplate : Template() {
|
||||||
@@ -29,6 +30,8 @@ class KotlinTestTemplate : Template() {
|
|||||||
framework.reference.settingValue.dependencyNames.map { dependencyName ->
|
framework.reference.settingValue.dependencyNames.map { dependencyName ->
|
||||||
KotlinArbitraryDependencyIR(
|
KotlinArbitraryDependencyIR(
|
||||||
dependencyName,
|
dependencyName,
|
||||||
|
isInMppModule = sourceset.original.parent?.kind
|
||||||
|
?.let { it == ModuleKind.multiplatform || it == ModuleKind.target } != false,
|
||||||
version = KotlinPlugin::version.settingValue,
|
version = KotlinPlugin::version.settingValue,
|
||||||
dependencyType = DependencyType.MAIN
|
dependencyType = DependencyType.MAIN
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user