Friday, October 6, 2017

How to use JsInterop in GWT

Hi, 


I just started playing with Gwt and want to try JsInterop.

This is very important feature for me. 

I have a big part of java 8 code needs to be translated to JavaScript.



I copied a demo project which is working by default.

My problem appeared after I defined a simple POJO class annotated with @JsType. 

Intellij Idea sees the annotation type in the project, but building fails with error that annotation class is undefined.


GWT version 2.8.1. 

GWT maven plugin is gwt-maven-plugin 1.0-rc-8.



Compiler options are:


  <compilerArgs>       <compileArg>-XjsInteropMode</compileArg>       <compileArg>-generateJsInteropExports</compileArg>       <compileArg>JS</compileArg>    </compilerArgs>


[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------  [ERROR] /home/egnyte/demo/gwt/StockWatcherSample-master/src/main/java/de/google/gwt/stockwatcher/client/sub/Mesage.java:[5,37] package com.google.gwt.core.client.js does not exist  [ERROR] /home/egnyte/demo/gwt/StockWatcherSample-master/src/main/java/de/google/gwt/stockwatcher/client/sub/Mesage.java:[7,2] cannot find symbol    symbol: class JsType  [INFO] 2 errors   [INFO] -------------------------------------------------------------  [INFO] ------------------------------------------------------------------------  [INFO] BUILD FAILURE  [INFO] ------------------------------------------------------------------------  [INFO] Total time: 3.119 s  [INFO] Finished at: 2017-10-06T16:09:52+02:00  [INFO] Final Memory: 21M/258M  [INFO] ------------------------------------------------------------------------  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project stockwatcher: Compilation failure: Compilation failure:  [ERROR] /home/egnyte/demo/gwt/StockWatcherSample-master/src/main/java/de/google/gwt/stockwatcher/client/sub/Mesage.java:[5,37] package com.google.gwt.core.client.js does not exist  [ERROR] /home/egnyte/demo/gwt/StockWatcherSample-master/src/main/java/de/google/gwt/stockwatcher/client/sub/Mesage.java:[7,2] cannot find symbol  [ERROR] symbol: class JsType


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment