[JS] Remove maven examples
This commit is contained in:
committed by
Space Team
parent
7a04c38863
commit
3f7e33df60
@@ -1,15 +0,0 @@
|
||||
## Sample Application
|
||||
|
||||
This (really simple ;) application shows how to use Kotlin and the maven plugin to generate JavaScript and invoke it from inside a HTML web page.
|
||||
|
||||
The source [Hello.kt](https://github.com/JetBrains/kotlin/blob/master/libraries/examples/browser-example-with-library/src/main/kotlin/sample/Hello.kt) uses the [kotlin.browser](https://jetbrains.github.com/kotlin/versions/snapshot/apidocs/kotlin/browser/package-summary.html) API to access the *document* property to modify the HTML.
|
||||
|
||||
### Running the sample in a web browser
|
||||
|
||||
To run the example try:
|
||||
|
||||
cd libraries/examples/browser-example-with-library
|
||||
mvn install
|
||||
open sample.html
|
||||
|
||||
This should open a browser which then shows some simple HTML which then includes some dynamically generated content.
|
||||
@@ -1,137 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.8.255-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>browser-example-with-library</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library-example</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- testing -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>${selenium.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>htmlunit-driver</artifactId>
|
||||
<version>${htmlunit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>js</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xuse-deprecated-legacy-compiler</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
||||
<includes>*.js</includes>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library-example</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
||||
<includes>*.js</includes>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvm>${jdk_1_8}/bin/java</jvm>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,25 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Kotlin Sample</h1>
|
||||
|
||||
<div id="foo">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="src/js/jquery.js"></script>
|
||||
<script src="target/js/lib/kotlin.js"></script>
|
||||
<script src="target/js/lib/kotlin-js-library-example.js"></script>
|
||||
<script type="text/javascript" src="target/js/browser-example-with-library.js"></script>
|
||||
|
||||
<!--
|
||||
TODO ideally we should be able to code generate this entry point if we can discover
|
||||
any annotated methods with documentReady
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(this['browser-example-with-library'].sample.myApp)
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package sample
|
||||
|
||||
import kotlin.Pair
|
||||
import kotlinx.browser.document
|
||||
import library.sample.*
|
||||
import kotlin.js.Date
|
||||
|
||||
fun myApp() {
|
||||
val element = document.getElementById("foo")
|
||||
if (element != null) {
|
||||
val p = Pair(10, 20)
|
||||
val x = pairAdd(p)
|
||||
val y = pairMul(p)
|
||||
val z = IntHolder(100).value
|
||||
val u = Date().extFun()
|
||||
element.appendChild(document.createTextNode("x=$x y=$y z=$z u=$u"))
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test.sample
|
||||
|
||||
import org.junit.Test as test
|
||||
import org.openqa.selenium.WebDriver
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver
|
||||
import org.openqa.selenium.By
|
||||
import java.io.File
|
||||
import kotlin.test.*
|
||||
|
||||
open class SampleTest {
|
||||
open val driver: WebDriver = HtmlUnitDriver(true)
|
||||
|
||||
@test fun homePage(): Unit {
|
||||
driver.get("file://" + File("sample.html").canonicalPath)
|
||||
Thread.sleep(1000)
|
||||
|
||||
val foo = driver.findElement(By.id("foo"))!!
|
||||
val text = foo.text ?: ""
|
||||
println("Found $foo with text '$text'")
|
||||
assertEquals("x=30 y=200 z=100 u=1000", text.trim())
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
## Sample Application
|
||||
|
||||
This (really simple ;) application shows how to use Kotlin and the maven plugin to generate JavaScript and invoke it from inside a HTML web page.
|
||||
|
||||
The source [Hello.kt](https://github.com/JetBrains/kotlin/blob/master/libraries/examples/browser-example/src/main/kotlin/sample/Hello.kt) uses the [kotlin.browser](https://jetbrains.github.com/kotlin/versions/snapshot/apidocs/kotlin/browser/package-summary.html) API to access the *document* property to modify the HTML.
|
||||
|
||||
### Running the sample in a web browser
|
||||
|
||||
To run the example try:
|
||||
|
||||
cd libraries/examples/browser-example
|
||||
mvn install
|
||||
open sample.html
|
||||
|
||||
This should open a browser which then shows some simple HTML which then includes some dynamically generated content.
|
||||
|
||||
## Running the sample on Java 7 with JavaFX and [kool.io](https://kool.io/)'s browser
|
||||
|
||||
You can also run the sample as Java code on a JVM using JavaFX (which includes its own webkit rendering engine for HTML / CSS / JS support) using the [kool.io JavaFX browser](https://github.com/koolio/kool/blob/master/samples/kool-template-sample/ReadMe.md).
|
||||
|
||||
First you need to install [Java 7 update 4](https://www.oracle.com/technetwork/java/javase/overview/index.html) or later which ships with JavaFX.
|
||||
|
||||
You will need to setup **JAVA_HOME** and **PATH** environment variables to point to the latest JDK. If you install Java 7 and use a Mac you might want to run this first...
|
||||
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
You can check you have JavaFX in your JDK install via
|
||||
|
||||
ls -l $JAVA_HOME/jre/lib/jfxrt.jar
|
||||
|
||||
which should find the JavaFX runtime jar (jfxrt.jar).
|
||||
|
||||
### Running the sample in JavaFX
|
||||
|
||||
To run the sample try...
|
||||
|
||||
mvn test -Pjavafx
|
||||
|
||||
Assuming you've Java 7 enabled and JAVA_HOME points to the JRE/JDK for Java 7 or later which includes JavaFX.
|
||||
|
||||
This should popup a JVM process with an embedded webkit based browser running the application; using the compiled bytecode on the JVM rather than JavaScript.
|
||||
@@ -1,182 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.8.255-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>browser-example</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- testing -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>${selenium.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>htmlunit-driver</artifactId>
|
||||
<version>${htmlunit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>js</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xuse-deprecated-legacy-compiler</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
||||
<includes>*.js</includes>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvm>${jdk_1_8}/bin/java</jvm>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<!-- runs the JavaFX UI - Requires Java7 update 4 or later -->
|
||||
<profile>
|
||||
<id>javafx</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.kool</groupId>
|
||||
<artifactId>kool-javafx</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>run</id>
|
||||
<phase>test</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<java fork="true" classpathref="maven.test.classpath" classname="io.kool.javafx.JavafxPackage">
|
||||
<arg value="file://sample-javafx.html"/>
|
||||
</java>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>snapshots.fusesource.org</id>
|
||||
<name>FuseSource Snapshots Repository</name>
|
||||
<url>https://repo.fusesource.com/nexus/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
@@ -1,16 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Kotlin Sample</h1>
|
||||
|
||||
<div id="foo">
|
||||
</div>
|
||||
|
||||
<script type="text/kotlin">
|
||||
sample.SamplePackage.myApp()
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,24 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Kotlin Sample</h1>
|
||||
|
||||
<div id="foo">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="src/js/jquery.js"></script>
|
||||
<script src="target/js/lib/kotlin.js"></script>
|
||||
<script type="text/javascript" src="target/js/browser-example.js"></script>
|
||||
|
||||
<!--
|
||||
TODO ideally we should be able to code generate this entry point if we can discover
|
||||
any annotated methods with documentReady
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(this['browser-example'].sample.myApp)
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-8981
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package sample
|
||||
|
||||
import kotlinx.browser.document
|
||||
|
||||
fun myApp() {
|
||||
val element = document.getElementById("foo")
|
||||
if (element != null) {
|
||||
element.appendChild(document.createTextNode("Some Dynamically Created Content!!!"))
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test.sample
|
||||
|
||||
import org.junit.Test as test
|
||||
import org.openqa.selenium.WebDriver
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver
|
||||
import org.openqa.selenium.By
|
||||
import java.io.File
|
||||
import kotlin.test.*
|
||||
|
||||
open class SampleTest {
|
||||
open val driver: WebDriver = HtmlUnitDriver(true)
|
||||
|
||||
@test fun homePage(): Unit {
|
||||
driver.get("file://" + File("sample.html").canonicalPath)
|
||||
Thread.sleep(1000)
|
||||
|
||||
val foo = driver.findElement(By.id("foo"))!!
|
||||
val text = foo.text ?: ""
|
||||
println("Found $foo with text '$text'")
|
||||
assertEquals("Some Dynamically Created Content!!!", text.trim())
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.8.255-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>js-example</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>js</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>js tests</id>
|
||||
<goals>
|
||||
<goal>test-js</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xuse-deprecated-legacy-compiler</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>main sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test sources</id>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classesDirectory>${project.basedir}/target/js</classesDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test jar</id>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<testClassesDirectory>${project.basedir}/target/test-js</testClassesDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<forceCreation>true</forceCreation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package sample
|
||||
|
||||
public fun main(args: Array<String>): Unit {
|
||||
val hello = Hello()
|
||||
hello.doSomething()
|
||||
}
|
||||
|
||||
public class Hello {
|
||||
var x = 0
|
||||
|
||||
fun doSomething(): Unit {
|
||||
x++
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test.sample
|
||||
|
||||
import sample.Hello
|
||||
import kotlin.test.Test
|
||||
|
||||
class SampleTest {
|
||||
@Test
|
||||
fun dummy(): Unit {
|
||||
Hello().doSomething()
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.8.255-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-js-library-example</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>read-project-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<files>
|
||||
<file>../../../resources/kotlinManifest.properties</file>
|
||||
</files>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
|
||||
<args>
|
||||
<arg>-Xuse-deprecated-legacy-compiler</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<configuration>
|
||||
<forceCreation>true</forceCreation>
|
||||
<includes>
|
||||
<include>*.js</include>
|
||||
</includes>
|
||||
<archive>
|
||||
<forced/>
|
||||
<manifestEntries>
|
||||
<Built-By>${manifest.impl.vendor}</Built-By>
|
||||
|
||||
<Implementation-Vendor>${manifest.impl.vendor}</Implementation-Vendor>
|
||||
<Implementation-Version>${build.number}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<!-- This is just to avoid deployment this module as it is example project -->
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package library.sample
|
||||
|
||||
import kotlin.js.Date
|
||||
|
||||
public fun pairAdd(p: Pair<Int, Int>): Int = p.first + p.second
|
||||
|
||||
public fun pairMul(p: Pair<Int, Int>): Int = p.first * p.second
|
||||
|
||||
public data class IntHolder(val value: Int)
|
||||
|
||||
public fun Date.extFun(): Int = 1000
|
||||
Reference in New Issue
Block a user