Fix the use case of an old-style project depending on an MPP lib

* Setup the attributes for the resolvable and output configurations
This commit is contained in:
Sergey Igushkin
2018-08-02 03:10:31 +03:00
parent 3ff61f59a7
commit 3f60798848
9 changed files with 102 additions and 10 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Assert
import org.junit.Test
@@ -20,6 +21,7 @@ class NewMultiplatformIT : BaseGradleIT() {
fun testLibAndApp() {
val libProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val appProject = Project("sample-app", gradleVersion, "new-mpp-lib-and-app")
val oldStyleAppProject = Project("sample-old-style-app", gradleVersion, "new-mpp-lib-and-app")
with(libProject) {
build("publish") {
@@ -86,6 +88,22 @@ class NewMultiplatformIT : BaseGradleIT() {
checkAppBuild()
}
}
with(oldStyleAppProject) {
setupWorkingDir()
gradleBuildScript().appendText("\nallprojects { repositories { maven { url '$libLocalRepoUri' } } }")
build("assemble") {
assertSuccessful()
assertTasksExecuted(":app-js:compileKotlin2Js", ":app-jvm:compileKotlin")
val jvmClassFile = projectDir.resolve(kotlinClassesDir("app-jvm") + "com/example/app/JvmAppKt.class")
checkBytecodeContains(jvmClassFile, "CommonKt.id", "MainKt.expectedFun")
val jsCompiledFilePath = kotlinClassesDir("app-js") + "app-js.js"
assertFileContains(jsCompiledFilePath, "lib.expectedFun", "lib.id")
}
}
}
@Test
@@ -0,0 +1,5 @@
apply plugin: 'kotlin2js'
dependencies {
compile 'com.example:sample-lib:1.0'
}
@@ -0,0 +1,10 @@
package com.example.app
import com.example.lib.id
import com.example.lib.expectedFun
fun idUsage(x: Int): Int = id(x)
fun main(args: Array<String>) {
expectedFun()
}
@@ -0,0 +1,5 @@
apply plugin: 'kotlin'
dependencies {
compile 'com.example:sample-lib:1.0'
}
@@ -0,0 +1,10 @@
package com.example.app
import com.example.lib.id
import com.example.lib.expectedFun
fun idUsage(x: Int): Int = id(x)
fun main(args: Array<String>) {
expectedFun()
}
@@ -0,0 +1,18 @@
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
// NB: Build of this module depends on 'sample-lib' publication. You need to add the local
// repository where 'sample-lib' artifacts are published.
}
}
@@ -0,0 +1,3 @@
enableFeaturePreview('GRADLE_METADATA')
include 'app-jvm', 'app-js'