diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml index d007b8780e5..75089686103 100644 --- a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml @@ -5,9 +5,9 @@ - + - + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected new file mode 100644 index 00000000000..c36a7c11434 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.log.expected @@ -0,0 +1,13 @@ +OUT: +Buildfile: [TestData]/build.xml + +build: + [mkdir] Created dir: [Temp]/lib +[kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js] +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + [copy] Copying 2 files to [Temp] + +BUILD SUCCESSFUL +Total time: [time] + +Return code: 0 diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml new file mode 100644 index 00000000000..fc7fe550f84 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/jslib-example/LibraryExample.kt b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/jslib-example/LibraryExample.kt new file mode 100644 index 00000000000..faf1e678458 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/jslib-example/LibraryExample.kt @@ -0,0 +1,6 @@ +package library.sample + +public class ClassA() { + val value: Int = 100 +} + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/root1/foo.kt b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/root1/foo.kt new file mode 100644 index 00000000000..c2ddea45024 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/root1/foo.kt @@ -0,0 +1,14 @@ +package foo + +import library.sample.* + +var ok = "FAIL" + +fun main(args: Array) { + val x = ClassA().value + if (x == 100) { + ok = "OK" + } +} + +fun box(): String = ok diff --git a/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java b/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java index a4b32f8fafa..3fc713efb0d 100644 --- a/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java @@ -117,6 +117,11 @@ public class AntTaskJsTest extends AntTaskBaseTest { doJsAntTest("jslib-example.js"); } + @Test + public void simpleWithoutStdlibAndJsFileAsAnotherLib() throws Exception { + doJsAntTest("jslib-example.js"); + } + @Test public void simpleWithMainFQArgs() throws Exception { doJsAntTest(); diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt b/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt index 458c004d65e..8d7eafc0eec 100644 --- a/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt +++ b/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt @@ -126,8 +126,10 @@ public object LibraryUtils { traverseArchive(lib) { (content, path) -> files.add(content) } + lib.getName().endsWith(KotlinJavascriptMetadataUtils.JS_EXT) -> + files.add(FileUtil.loadFile(lib)) else -> - throw IllegalArgumentException("Unknown library format (directory or zip expected): $lib") + throw IllegalArgumentException("Unknown library format (directory, zip or js file expected): $lib") } }