Sunday, December 3, 2017

Re: JsInterop: annotations not found

In the bright light of morning, I can see the problem. The javac message tells me javac is searching my srcdir for some of the jsinterop sources. They are in the jar files in my class path, but not in my srcdir. I will experiment to find the best way to handle this.

Thanks for your help.



On Saturday, December 2, 2017 at 11:00:29 PM UTC-8, Bob Woodbury wrote:
I am learning to use jsinterop, and I am stuck at square one -- javac won't recognize the @JsType annotation.

I'm using the jdk1.8.0_102 and apache-ant-1.10.1 and gwt-2.8.2 on Linux (Fedora).

My project compiles without problems until I try to add "MyClass" with the @JsType annotation.

I lifted the following code from the tutorial at: http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJsInterop.html


package com.webshoz.insight.client.iaol;


import jsinterop.annotations.*;  // I have tried compiling with and without this import, without success.


@JsType
public class MyClass {


   
public String name;


   
public MyClass(String name) {
       
this.name = name;
   
}


   
public void sayHello() {
       
return "Hello" + this.name;
   
}
}



The relevant parts of my Ant build file are:


<?xml version="1.0" encoding="utf-8" ?>
<project name="Insight" default="build" basedir=".">


 
<path id="project.class.path">
   
<pathelement location="war/WEB-INF/classes"/>
   
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
 
</path>


 
<target name="javac" description="Compile java source">
   
<javac srcdir="src" includes="**" encoding="utf-8"
       
destdir="war/WEB-INF/classes"
       
source="1.8" target="1.8" nowarn="false"
       
includeantruntime="false"
       
debug="true" debuglevel="lines,vars,source">
     
<classpath refid="project.class.path"/>
     
<compilerarg value="-Xlint:deprecation"/>
     
<compilerarg value="-Xlint:unchecked"/>
     
<compilerarg value="-verbose"/>
     
<compilerarg value="-Xlint"/>
     
<compilerarg value="-XprintProcessorInfo"/>
   
</javac>
 
</target>


 
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
   
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
     
<classpath>
       
<pathelement location="src"/>
       
<path refid="project.class.path"/>
     
</classpath>
     
<jvmarg value="-Xmx512M"/>
     
<arg line="-generateJsInteropExports -strict -XdisableUpdateCheck"/>
     
<arg value="com.webshoz.insight.Application"/>
     
<arg value="com.webshoz.insight.Iaol"/>
   
</java>
 
</target>


</project>


The javac compiler puts out the following:

[javac] Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [java.lang.Override, jsinterop.annotations.JsType] and returns false.
[javac] warning: No processor claimed any of these annotations: jsinterop.annotations.JsType
[javac] [search path for source files: /house/Dev/Insight/branches/IAOL/src]

Can anyone tell me what I'm missing? Thanks!

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