From 77eba4c78a1a1a21d1feed7b0cb66b08b91e6ce4 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 4 May 2015 12:33:42 +0300 Subject: [PATCH] Add Kotlin example --- teavm-samples/pom.xml | 1 + teavm-samples/teavm-samples-kotlin/.gitignore | 4 + teavm-samples/teavm-samples-kotlin/pom.xml | 131 ++++++++++++++++++ .../src/main/kotlin/Hello.kt | 15 ++ .../src/main/webapp/WEB-INF/web.xml | 21 +++ .../src/main/webapp/index.html | 31 +++++ 6 files changed, 203 insertions(+) create mode 100644 teavm-samples/teavm-samples-kotlin/.gitignore create mode 100644 teavm-samples/teavm-samples-kotlin/pom.xml create mode 100644 teavm-samples/teavm-samples-kotlin/src/main/kotlin/Hello.kt create mode 100644 teavm-samples/teavm-samples-kotlin/src/main/webapp/WEB-INF/web.xml create mode 100644 teavm-samples/teavm-samples-kotlin/src/main/webapp/index.html diff --git a/teavm-samples/pom.xml b/teavm-samples/pom.xml index 6513d89c4..4dd090a69 100644 --- a/teavm-samples/pom.xml +++ b/teavm-samples/pom.xml @@ -35,5 +35,6 @@ teavm-samples-storage teavm-samples-video teavm-samples-async + teavm-samples-kotlin \ No newline at end of file diff --git a/teavm-samples/teavm-samples-kotlin/.gitignore b/teavm-samples/teavm-samples-kotlin/.gitignore new file mode 100644 index 000000000..8bd3a0588 --- /dev/null +++ b/teavm-samples/teavm-samples-kotlin/.gitignore @@ -0,0 +1,4 @@ +/target/ +/.settings/ +/.classpath +/.project diff --git a/teavm-samples/teavm-samples-kotlin/pom.xml b/teavm-samples/teavm-samples-kotlin/pom.xml new file mode 100644 index 000000000..7e7147a5d --- /dev/null +++ b/teavm-samples/teavm-samples-kotlin/pom.xml @@ -0,0 +1,131 @@ + + + 4.0.0 + + + org.teavm + teavm-samples + 0.3.0-SNAPSHOT + + teavm-samples-kotlin + + war + + TeaVM Kotlin web application + A sample application written in Kotlin and compiled by TeaVM + + + 0.11.91.1 + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + junit + junit + test + + + org.teavm + teavm-classlib + ${project.version} + provided + + + org.teavm + teavm-dom + ${project.version} + provided + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + org.teavm + teavm-maven-plugin + ${project.version} + + + web-client + prepare-package + + build-javascript + + + ${project.build.directory}/generated/js/teavm + org.teavm.samples.kotlin.KotlinPackage + SEPARATE + false + true + true + true + + + + + + maven-war-plugin + 2.4 + + + + ${project.build.directory}/generated/js + + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + \ No newline at end of file diff --git a/teavm-samples/teavm-samples-kotlin/src/main/kotlin/Hello.kt b/teavm-samples/teavm-samples-kotlin/src/main/kotlin/Hello.kt new file mode 100644 index 000000000..f71b3bcf6 --- /dev/null +++ b/teavm-samples/teavm-samples-kotlin/src/main/kotlin/Hello.kt @@ -0,0 +1,15 @@ +package org.teavm.samples.kotlin + +import org.teavm.jso.* +import org.teavm.dom.browser.* +import org.teavm.dom.html.* +import org.teavm.dom.events.* + +fun main(args : Array) { + var window = JS.getGlobal() as Window; + var document = window.getDocument(); + + document.getElementById("hello-kotlin").addEventListener("click", EventListener() { + window.alert("Hello, developer!"); + }) +} diff --git a/teavm-samples/teavm-samples-kotlin/src/main/webapp/WEB-INF/web.xml b/teavm-samples/teavm-samples-kotlin/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..bfc410b12 --- /dev/null +++ b/teavm-samples/teavm-samples-kotlin/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/teavm-samples/teavm-samples-kotlin/src/main/webapp/index.html b/teavm-samples/teavm-samples-kotlin/src/main/webapp/index.html new file mode 100644 index 000000000..988fa4e9a --- /dev/null +++ b/teavm-samples/teavm-samples-kotlin/src/main/webapp/index.html @@ -0,0 +1,31 @@ + + + + Hello kotlin + + + + + +

+ +

This application was compiled by TeaVM from the following Kotlin source:

+
+package org.teavm.samples.kotlin
+
+import org.teavm.jso.*
+import org.teavm.dom.browser.*
+import org.teavm.dom.html.*
+import org.teavm.dom.events.*
+
+fun main(args : Array<String>) {
+    var window = JS.getGlobal() as Window;
+    var document = window.getDocument();
+
+    document.getElementById("hello-kotlin").addEventListener("click", EventListener<MouseEvent>() {
+       window.alert("Hello, developer!");
+    })
+}
+    
+ + \ No newline at end of file