JS: add support of JS module kind to Gradle task. Add tests of support of module kind to Maven tests
This commit is contained in:
@@ -56,6 +56,13 @@
|
||||
<plugin>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<version>1.9</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mozilla</groupId>
|
||||
<artifactId>rhino</artifactId>
|
||||
<version>1.7.7.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<projectsDirectory>src/it</projectsDirectory>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
var amdModules = {};
|
||||
function define(moduleName, dependencies, body) {
|
||||
var resolvedDependencies = [];
|
||||
for (var i = 0; i < dependencies.length; ++i) {
|
||||
resolvedDependencies.push(amdModules[dependencies[i]]);
|
||||
}
|
||||
amdModules[moduleName] = body.apply(body, resolvedDependencies);
|
||||
}
|
||||
define.amd = {};
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
define("check", ["test-js-moduleKind"], function(app) {
|
||||
if (app.foo.bar() != "OK") {
|
||||
throw new Error("Unexpected result");
|
||||
}
|
||||
});
|
||||
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>test-js-extraArguments</artifactId>
|
||||
<artifactId>test-js-moduleKind</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
@@ -35,6 +35,33 @@
|
||||
<moduleKind>umd</moduleKind>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<type>jar</type>
|
||||
<overWrite>false</overWrite>
|
||||
<outputDirectory>${project.build.directory}/js/</outputDirectory>
|
||||
<includes>**/*.js</includes>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
+2
-8
@@ -14,12 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains
|
||||
package foo
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
println(getGreeting())
|
||||
}
|
||||
|
||||
fun getGreeting() : String {
|
||||
return "Hello, World!"
|
||||
}
|
||||
fun bar() = "OK"
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import java.io.*;
|
||||
import org.mozilla.javascript.tools.shell.Main;
|
||||
|
||||
File file = new File(basedir, "target/js/test-js-extraArguments.js");
|
||||
File file = new File(basedir, "target/js/test-js-moduleKind.js");
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException("Could not find generated JS : " + file);
|
||||
}
|
||||
|
||||
String basePath = basedir.getPath();
|
||||
Main.main(new String[] {
|
||||
"-O", "-1",
|
||||
"-f", basePath + "/amd.js",
|
||||
"-f", basePath + "/target/js/kotlin.js",
|
||||
"-f", basePath + "/target/js/test-js-moduleKind.js",
|
||||
"-f", basePath + "/check.js"})
|
||||
|
||||
Reference in New Issue
Block a user