GWT-exporter. Working example

戏子无情 提交于 2019-12-11 03:13:39

问题


I have a Java lib and I need to convert it to JS. I found the solution GWT to create utility javascript library to use gwt-exporter. I never used GWT before. I tried GWT-exporter. Getting started but it's not clear how to use it. Simply how to run the project to generate JS?

pom.xml

<dependencies>
    <dependency>
        <groupId>org.timepedia.exporter</groupId>
        <artifactId>gwtexporter</artifactId>
        <version>2.4.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

Java class:

import org.timepedia.exporter.client.ExporterUtil;

public class JS implements EntryPoint {
public void onModuleLoad() {
    // Export all Exportable classes
    ExporterUtil.exportAll();
}

}

Where to find dependency for EntryPoint?

Maybe someone can share working example?


回答1:


https://code.google.com/p/gwt-exporter/wiki/GettingStarted is poor. To compile JS I added gwt-maven-plugin.

Also I created .gwt.xml file with description of my module.

Following dependency is mandatory

    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <scope>provided</scope>
    </dependency>



回答2:


Apart from adding gwt-exporter to your class-path, did you update your module file (application_name.gwt.xml) inheriting the gwt-exporter dependency?.

If so, in this file you should have an entry-point tag pointing to the class to run when the app starts. Open that java file and add the exportAll call.

Finally visit all the classes/methods you want to make available in javascript and annotate them appropriately like in the getting started page is indicated



来源:https://stackoverflow.com/questions/30990652/gwt-exporter-working-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!