From 514becf949967dd07a18b05e588ab3f5bad5a6b0 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Wed, 18 Dec 2013 16:58:49 +0400 Subject: [PATCH] Adds description of JavaScript build process --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/README.md b/README.md index 2173a4bc9..2ddec942b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,66 @@ But there is something more: loop invariant motion and many other; * implementation of subset of core Java library; +How to use +---------- + +There are some options of using TeaVM. One is the maven build. First, you write your code as if it were an +ordinary Java project: + + package org.teavm.samples; + + public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, world!"); + } + } + +Second, you include the following dependency in your `pom.xml`: + + + org.teavm + teavm-classlib + 0.0.1-SNAPSHOT + provided + + +Third, you add `teavm-maven-plugin` in your build configuration: + + + org.teavm + teavm-maven-plugin + 0.0.1-SNAPSHOT + + + generate-javascript + + build-javascript + + process-classes + + true + org.teavm.samples.HelloWorld + + + + + +Now you can execute `mvn clean package` and get the generated JavaScript file `target/javascript/classes.js`. +It contains the `main` global function, which you may call. In the general case you should provide +an HTML page, which includes both of +[runtime.js](https://github.com/konsoletyper/teavm/blob/master/teavm-core/src/main/resources/org/teavm/javascript/runtime.js) +and `classes.js` files and calls `main` function in some condition. Here is an example: + + + + +