KT-3008 Add support of module kind to Ant task. Repair Ant JS tests
This commit is contained in:
@@ -27,6 +27,7 @@ class Kotlin2JsTask : KotlinCompilerBaseTask() {
|
|||||||
var outputPostfix: File? = null
|
var outputPostfix: File? = null
|
||||||
var sourceMap: Boolean = false
|
var sourceMap: Boolean = false
|
||||||
var metaInfo: Boolean = false
|
var metaInfo: Boolean = false
|
||||||
|
var moduleKind: String = "plain"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link K2JsArgumentConstants.CALL} (default) if need generate a main function call (main function will be auto detected)
|
* {@link K2JsArgumentConstants.CALL} (default) if need generate a main function call (main function will be auto detected)
|
||||||
@@ -73,5 +74,7 @@ class Kotlin2JsTask : KotlinCompilerBaseTask() {
|
|||||||
if (noStdlib) args.add("-no-stdlib")
|
if (noStdlib) args.add("-no-stdlib")
|
||||||
if (sourceMap) args.add("-source-map")
|
if (sourceMap) args.add("-source-map")
|
||||||
if (metaInfo) args.add("-meta-info")
|
if (metaInfo) args.add("-meta-info")
|
||||||
|
|
||||||
|
args += listOf("-module-kind", moduleKind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Binary file not shown.
+4
-3
@@ -1,4 +1,4 @@
|
|||||||
(function (Kotlin) {
|
this['jslib-example'] = function (Kotlin) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var _ = Kotlin.defineRootPackage(null, /** @lends _ */ {
|
var _ = Kotlin.defineRootPackage(null, /** @lends _ */ {
|
||||||
library: Kotlin.definePackage(null, /** @lends _.library */ {
|
library: Kotlin.definePackage(null, /** @lends _.library */ {
|
||||||
@@ -27,11 +27,12 @@
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
equals_za3rmp$: function (other) {
|
equals_za3rmp$: function (other) {
|
||||||
return this === other || (other !== null && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value)));
|
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value))));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
Kotlin.defineModule('jslib-example', _);
|
Kotlin.defineModule('jslib-example', _);
|
||||||
}(Kotlin));
|
return _;
|
||||||
|
}(kotlin);
|
||||||
|
|||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
(function(global) {
|
||||||
|
var modules = {};
|
||||||
|
modules.kotlin = kotlin;
|
||||||
|
|
||||||
|
function define(name, dependencies, body) {
|
||||||
|
var resolvedDependencies = [];
|
||||||
|
for (var i = 0; i < dependencies.length; ++i) {
|
||||||
|
resolvedDependencies[i] = modules[dependencies[i]];
|
||||||
|
}
|
||||||
|
modules[name] = body.apply(body, resolvedDependencies);
|
||||||
|
}
|
||||||
|
define.amd = {};
|
||||||
|
|
||||||
|
global.define = define;
|
||||||
|
})(this);
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
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]
|
||||||
|
[copy] Copying 1 file to [Temp]
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL
|
||||||
|
Total time: [time]
|
||||||
|
|
||||||
|
Return code: 0
|
||||||
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
<project name="Ant Task Test" default="build">
|
||||||
|
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||||
|
<property name="library.path" value="${test.data}/jslib-example"/>
|
||||||
|
<property name="temp.library.path" value="${temp}/lib"/>
|
||||||
|
<target name="build">
|
||||||
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
|
<kotlin2js src="${library.path}" output="${temp.library.path}/jslib-example.js" metaInfo="true" moduleKind="umd"/>
|
||||||
|
|
||||||
|
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call" moduleKind="amd">
|
||||||
|
<library>
|
||||||
|
<pathelement path="${temp.library.path}/jslib-example.meta.js"/>
|
||||||
|
</library>
|
||||||
|
</kotlin2js>
|
||||||
|
<copy todir="${temp}">
|
||||||
|
<fileset dir="${temp.library.path}">
|
||||||
|
<include name="**/*.js"/>
|
||||||
|
<exclude name="META-INF/**"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
<copy todir="${temp}" file="${test.data}/amd.js"/>
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package library.sample
|
||||||
|
|
||||||
|
import kotlin.js.Date
|
||||||
|
|
||||||
|
public class ClassA() {
|
||||||
|
val value: Int = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun Date.extFun(): Int = 100
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
import library.sample.*
|
||||||
|
import kotlin.js.Date
|
||||||
|
|
||||||
|
var ok = "FAIL"
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val x = ClassA().value
|
||||||
|
if (x == 100) {
|
||||||
|
ok = "OK"
|
||||||
|
}
|
||||||
|
val date = Date()
|
||||||
|
println(date.extFun())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String = ok
|
||||||
@@ -120,6 +120,10 @@ public class AntTaskJsTest extends AbstractAntTaskTest {
|
|||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSimpleWithStdlibAndJsFileAsAnotherLibModuleKind() throws Exception {
|
||||||
|
doJsAntTest("amd.js", "jslib-example.js");
|
||||||
|
}
|
||||||
|
|
||||||
public void testSimpleWithStdlibAndTwoJsFilesAsLibraries() throws Exception {
|
public void testSimpleWithStdlibAndTwoJsFilesAsLibraries() throws Exception {
|
||||||
doJsAntTest("jslib-example1.js", "jslib-example2.js");
|
doJsAntTest("jslib-example1.js", "jslib-example2.js");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user