• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

edibleday/teavm-gradle-plugin: Gradle plugin for compiling(transpiling) JVM byte ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

edibleday/teavm-gradle-plugin

开源软件地址(OpenSource Url):

https://github.com/edibleday/teavm-gradle-plugin

开源编程语言(OpenSource Language):

Kotlin 100.0%

开源软件介绍(OpenSource Introduction):

About

This is Gradle plugin for compiling(transpiling) Java bytecode to JavaScript using TeaVM. Plugin uses TeaVMTool for compilation. Plugin is written in Kotlin and depends on kotlin-stdlib. Project that uses plugin will depend on teavm-classlib, teavm-jso and teavm-jso-apis. All dependencies can be acquired from Maven Central repo.

Plugin is tested with Java 6 and Kotlin but it should be able to transpile other JVM outputs too.

Quick Start

Add repositories and classpath in build script:

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
    }

    dependencies {
        classpath 'com.edibleday:teavm-gradle-plugin:VERSION'
    }
}

Replace VERSION with actual version of plugin. See releases for version list.

You can also use git commit hash as version. Check JitPack for list of hashes and build status.

Apply plugin to project:

apply plugin: "com.edibleday.teavm"

Add repositories for TeaVM dependencies

repositories {
    mavenCentral()
}

Set main class (one with public static void main(String [] args) method):

mainClassName = "my.package.Main"

Optionally set compilation options:

teavmc { //Optional configuration block
    /* Where to put final web app*/
    installDirectory "${project.buildDir}/teavm"
    /* Main javascript file name */
    targetFileName "app.js"
    /* Include simple html file that can launch app */
    mainPageIncluded true
    /* Copy sources to install directory for simpler debugging */
    copySources false
    /* Generate javascript to java mapping for debugging */
    generateSourceMap false
    /* Minify javascript */
    minified true
    /* Runtime javascript inclusion
        NONE: don't include runtime
        MERGED: merge runtime into main javascript file
        SEPARATE: include runtime as separated file
     */
    runtime org.teavm.tooling.RuntimeCopyOperation.SEPARATE
}

To compile project, run teavmc task:

./gradlew teavmc

Resulting application will be put into installDirectory (by default `build/teavm').

To run app, open main.html from installDirectory.

Usage

Sample is located here. Check comments in build.gradle file.

To compile javascript application, use teavmc task. By default output will be located in build/teavm directory.

It's possible to add source code for source code copying tasks by using dependency with teavmsources configuration that points to source artifact. Sample:

dependencies {
    teavmsources "com.test:test:1.0.0:sources"
}

Building

Use this command to build and publish plugin to local maven repo:

./gradlew publishToMavenLocal



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap