Fixed import of MPP modules with single artifacts

#KT-38037 Fixed
This commit is contained in:
Andrey Uskov
2020-05-11 23:40:01 +03:00
parent a8623b9b28
commit 2eb354f211
6 changed files with 170 additions and 0 deletions
@@ -942,6 +942,30 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
}
@Test
@PluginTargetVersions(gradleVersion = "4.0+", pluginVersion = "1.3.30+")
fun testMutableArtifactLists() {
configureByFiles()
importProject(true)
checkProjectStructure(true, false, false) {
module("KT38037") {}
module("KT38037.mpp-bottom-actual") {}
module("KT38037.mpp-bottom-actual.commonMain") {}
module("KT38037.mpp-bottom-actual.commonTest") {}
module("KT38037.mpp-bottom-actual.jvm18Main") {}
module("KT38037.mpp-bottom-actual.jvm18Test") {}
module("KT38037.mpp-bottom-actual.main") {}
module("KT38037.mpp-bottom-actual.test") {}
module("KT38037.mpp-mid-actual") {}
module("KT38037.mpp-mid-actual.commonMain") {}
module("KT38037.mpp-mid-actual.commonTest") {}
module("KT38037.mpp-mid-actual.jvmWithJavaMain") {}
module("KT38037.mpp-mid-actual.jvmWithJavaTest") {}
module("KT38037.mpp-mid-actual.main") {}
module("KT38037.mpp-mid-actual.test") {}
}
}
private fun checkProjectStructure(
exhaustiveModuleList: Boolean = true,
exhaustiveSourceSourceRootList: Boolean = true,
@@ -268,6 +268,11 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
.resolveDependencies(configuration)
.apply {
forEach<ExternalDependency?> { (it as? AbstractExternalDependency)?.scope = scope }
forEach<ExternalDependency?> {
if (it is DefaultExternalProjectDependency && it.projectDependencyArtifacts !is ArrayList) {
it.projectDependencyArtifacts = ArrayList(it.projectDependencyArtifacts)
}
}
}
.flatMap { dependencyAdjuster.adjustDependency(it) }
val singleDependencyFiles = resolvedDependencies.mapNotNullTo(LinkedHashSet<File>()) {
@@ -0,0 +1,18 @@
buildscript {
repositories {
{{kotlin_plugin_repositories}}
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}")
{{extraPluginDependencies}}
}
}
allprojects {
repositories {
{{kotlin_plugin_repositories}}
}
}
@@ -0,0 +1,62 @@
apply plugin: 'kotlin-multiplatform'
apply plugin: 'maven-publish'
group 'org.jetbrains.qa.combompp'
buildscript {
repositories {
{{kotlin_plugin_repositories}}
}
}
repositories {
{{kotlin_plugin_repositories}}
}
kotlin {
jvm("jvm18") {
withJava()
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
sourceSets {
commonMain {
dependencies {
api kotlin('stdlib-common', '{{kotlin_plugin_version}}')
api kotlin('stdlib', '{{kotlin_plugin_version}}')
}
}
commonTest {
dependencies {
api kotlin('test-common', '{{kotlin_plugin_version}}')
api kotlin('test-annotations-common', '{{kotlin_plugin_version}}')
api kotlin('test', '{{kotlin_plugin_version}}')
}
}
// setting up the targets source sets
jvm18Main {
kotlin.srcDir('src/jvm18Main/customSrc')
dependencies {
implementation kotlin('stdlib-jdk8', '{{kotlin_plugin_version}}')
}
}
jvm18Test {
dependencies {
api kotlin('test')
api kotlin('test-junit')
}
}
}
}
dependencies {
jvm18TestApi "org.assertj:assertj-core:3.11.1"
}
@@ -0,0 +1,52 @@
group 'org.jetbrains.qa.combompp'
version '1.0'
apply plugin: 'kotlin-multiplatform'
apply plugin: 'maven-publish'
buildscript {
repositories {
{{kotlin_plugin_repositories}}
}
}
repositories {
{{kotlin_plugin_repositories}}
}
kotlin {
jvm("jvmWithJava") {
withJava()
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
sourceSets {
commonMain {
dependencies {
api project(":mpp-bottom-actual")
implementation kotlin('stdlib-common', '{{kotlin_plugin_version}}')
implementation kotlin('stdlib', '{{kotlin_plugin_version}}')
}
}
commonTest {
dependencies {
implementation kotlin('test-common', '{{kotlin_plugin_version}}')
implementation kotlin('test-annotations-common', '{{kotlin_plugin_version}}')
implementation kotlin('test', '{{kotlin_plugin_version}}')
}
}
jvmWithJavaMain {
dependencies {
}
}
jvmWithJavaTest {
dependencies {
implementation kotlin('test', '{{kotlin_plugin_version}}')
implementation kotlin('test-junit', '{{kotlin_plugin_version}}')
}
}
}
}
@@ -0,0 +1,9 @@
pluginManagement {
repositories {
{{kotlin_plugin_repositories}}
}
}
rootProject.name = 'KT38037'
include ':mpp-bottom-actual', ':mpp-mid-actual'
enableFeaturePreview('GRADLE_METADATA')