Friday, October 6, 2017

Re: How to use JsInterop in GWT



On Friday, October 6, 2017 at 4:32:47 PM UTC+2, Daneel Yaitskov wrote:

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

The com.google.gwt.core.client.js annotations are the old ones and have been removed in GWT 2.8. See http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJsInterop.html for the up-to-date documentation (using "jsinterop.annotations" package)

If your IDE does not choke on them, it probably means it adds GWT 2.7 somehow to your build dependencies.

You also need to delete the -XjsInteropMode and JS lines, leaving only -generateJsInteropExports

--
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