KT-3008 Add module kind attribute to Maven plugin. Fix tests from libraries subproject
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
any annotated methods with documentReady
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(Kotlin.modules['browser-example-with-library'].sample.myApp)
|
||||
$(document).ready(kotlin.modules['browser-example-with-library'].sample.myApp)
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
any annotated methods with documentReady
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(Kotlin.modules['browser-example'].sample.myApp)
|
||||
$(document).ready(kotlin.modules['browser-example'].sample.myApp)
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
||||
// into Rhino and running assertions on that. See https://github.com/abesto/kotlin/commit/120ec1bda3d95630189d4d33d0b2afb4253b5186
|
||||
// for the (original) discussion on this.
|
||||
assertFileContains("libraryProject/build/kotlin2js/main/test-library.js", "Counter: Kotlin.createClass")
|
||||
assertFileContains("mainProject/web/js/app.js", "var counter = new Kotlin.modules['test-library'].example.library.Counter(counterText);")
|
||||
assertFileContains("mainProject/web/js/app.js", "var counter = new \$module\$test_library.example.library.Counter(counterText);")
|
||||
}
|
||||
|
||||
project.build("build") {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>test-js-extraArguments</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<moduleKind>umd</moduleKind>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
println(getGreeting())
|
||||
}
|
||||
|
||||
fun getGreeting() : String {
|
||||
return "Hello, World!"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import java.io.*;
|
||||
|
||||
File file = new File(basedir, "target/js/test-js-extraArguments.js");
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException("Could not find generated JS : " + file);
|
||||
}
|
||||
+16
@@ -74,12 +74,28 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
@Parameter(defaultValue = "false")
|
||||
private boolean sourceMap;
|
||||
|
||||
/**
|
||||
* <p>Specifies which JS module system to generate compatible sources for. Options are:</p>
|
||||
* <ul>
|
||||
* <li><b>amd</b> —
|
||||
* <a href="https://github.com/amdjs/amdjs-api/wiki/AMD"></a>Asynchronous Module System</a>;</li>
|
||||
* <li><b>commonjs</b> — npm/CommonJS conventions based on synchronous <code>require</code>
|
||||
* function;</li>
|
||||
* <li><b>plain</b> (default) — no module system, keep all modules in global scope;</li>
|
||||
* <li><b>umd</b> — Universal Module Definition, stub wrapper that detects current
|
||||
* module system in runtime and behaves as <code>plain</code> if none detected.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Parameter(defaultValue = "plain")
|
||||
private String moduleKind;
|
||||
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JSCompilerArguments arguments) throws MojoExecutionException {
|
||||
arguments.outputFile = outputFile;
|
||||
arguments.noStdlib = true;
|
||||
arguments.metaInfo = metaInfo;
|
||||
arguments.kjsm = kjsm;
|
||||
arguments.moduleKind = moduleKind;
|
||||
|
||||
List<String> libraries = getKotlinJavascriptLibraryFiles();
|
||||
getLog().debug("libraryFiles: " + libraries);
|
||||
|
||||
Reference in New Issue
Block a user