Fixed Kotlin2JsCompile not picking dependencies from configurations other than compile.
Example:
apply plugin: 'kotlin2js'
dependencies {
...
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}
Here, the `:compileTestKotlin2Js` task did not pick the dependency and used the `compile` classpath.
This has been fixed.
Also, fixed `testCompileTestCouldAccessProduction` and added `testJsCustomSourceSet`.
This commit is contained in:
+19
-2
@@ -79,10 +79,10 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
@Test
|
@Test
|
||||||
fun testCompileTestCouldAccessProduction() {
|
fun testCompileTestCouldAccessProduction() {
|
||||||
val project = Project("kotlin2JsProjectWithTests", "2.10")
|
val project = Project("kotlin2JsProjectWithTests", "2.10")
|
||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|
||||||
assertContains(
|
assertContains(
|
||||||
":compileKotlin2Js",
|
":compileKotlin2Js",
|
||||||
":compileTestKotlin2Js"
|
":compileTestKotlin2Js"
|
||||||
@@ -93,6 +93,23 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testJsCustomSourceSet() {
|
||||||
|
val project = Project("kotlin2JsProjectWithCustomSourceset", "2.10")
|
||||||
|
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
|
||||||
|
assertContains(
|
||||||
|
":compileKotlin2Js",
|
||||||
|
":compileIntegrationTestKotlin2Js"
|
||||||
|
)
|
||||||
|
|
||||||
|
assertFileExists("build/kotlin2js/main/module.js")
|
||||||
|
assertFileExists("build/kotlin2js/integrationTest/module-inttests.js")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testKotlinJsBuiltins() {
|
fun testKotlinJsBuiltins() {
|
||||||
val project = Project("kotlinBuiltins", "3.2")
|
val project = Project("kotlinBuiltins", "3.2")
|
||||||
|
|||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin2js'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
integrationTest
|
||||||
|
}
|
||||||
|
|
||||||
|
task integrationTest(type: Test) {
|
||||||
|
testClassesDir = sourceSets.integrationTest.output.classesDir
|
||||||
|
classpath = sourceSets.integrationTest.runtimeClasspath
|
||||||
|
}
|
||||||
|
|
||||||
|
compileIntegrationTestKotlin2Js.dependsOn compileKotlin2Js
|
||||||
|
|
||||||
|
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||||
|
compileIntegrationTestKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/integrationTest/module-inttests.js"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||||
|
integrationTestCompile files(file(compileKotlin2Js.kotlinOptions.outputFile).parent)
|
||||||
|
integrationTestCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
task jarSources(type: Jar) {
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
classifier = 'source'
|
||||||
|
}
|
||||||
|
artifacts {
|
||||||
|
compile jarSources
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import example.MyProductionClass
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class MainIT {
|
||||||
|
@Test
|
||||||
|
fun mySimpleTest() {
|
||||||
|
listOf(1, 2, 3).forEach { // check that stdlib is available
|
||||||
|
MyProductionClass().i = it // check that production code is available
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
class MyProductionClass {
|
||||||
|
var i = 0
|
||||||
|
}
|
||||||
+1
@@ -15,6 +15,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||||
|
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
task jarSources(type: Jar) {
|
task jarSources(type: Jar) {
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import org.junit.Test
|
|||||||
import example.MyProductionClass
|
import example.MyProductionClass
|
||||||
|
|
||||||
class MyTest {
|
class MyTest {
|
||||||
@Test
|
@Test
|
||||||
fun mySimpleTest() {
|
fun mySimpleTest() {
|
||||||
MyProductionClass().i = 10
|
MyProductionClass().i = 10
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -55,6 +55,11 @@ const val USING_EXPERIMENTAL_INCREMENTAL_MESSAGE = "Using experimental kotlin in
|
|||||||
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile(), CompilerArgumentAware {
|
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile(), CompilerArgumentAware {
|
||||||
abstract protected fun populateCompilerArguments(): T
|
abstract protected fun populateCompilerArguments(): T
|
||||||
|
|
||||||
|
protected val additionalClasspath = arrayListOf<File>()
|
||||||
|
protected val compileClasspath: Iterable<File>
|
||||||
|
get() = (classpath + additionalClasspath)
|
||||||
|
.filterTo(LinkedHashSet(), File::exists)
|
||||||
|
|
||||||
override val serializedCompilerArguments: List<String>
|
override val serializedCompilerArguments: List<String>
|
||||||
get() {
|
get() {
|
||||||
val arguments = populateCompilerArguments()
|
val arguments = populateCompilerArguments()
|
||||||
@@ -166,10 +171,6 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null
|
private var kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null
|
||||||
private val additionalClasspath = arrayListOf<File>()
|
|
||||||
private val compileClasspath: Iterable<File>
|
|
||||||
get() = (classpath + additionalClasspath)
|
|
||||||
.filterTo(LinkedHashSet(), File::exists)
|
|
||||||
|
|
||||||
internal val kaptOptions = KaptOptions()
|
internal val kaptOptions = KaptOptions()
|
||||||
internal val pluginOptions = CompilerPluginOptions()
|
internal val pluginOptions = CompilerPluginOptions()
|
||||||
@@ -342,7 +343,7 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArguments>(),
|
|||||||
?.let { if (LibraryUtils.isKotlinJavascriptLibrary(it)) it else null }
|
?.let { if (LibraryUtils.isKotlinJavascriptLibrary(it)) it else null }
|
||||||
?.absolutePath
|
?.absolutePath
|
||||||
|
|
||||||
val dependencies = project.configurations.getByName("compile")
|
val dependencies = compileClasspath
|
||||||
.filter { LibraryUtils.isKotlinJavascriptLibrary(it) }
|
.filter { LibraryUtils.isKotlinJavascriptLibrary(it) }
|
||||||
.map { it.canonicalPath }
|
.map { it.canonicalPath }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user