0

I have to instantiate a Class which is generated by my custom annotation processor on a GWT client Class which extends Composite. Generated class is also at the same package with this view. However, when I run the super dev mode (SDM), I get the following error.

No source code is available for type com.test.gwt.client.MyGeneratedClass

Regular GWT compilation gives no error. However, I get the error at SDM compilation.

How can make GWT SDM compile this view?

Baris
  • 471
  • 6
  • 19

2 Answers2

0

You have to instruct JavaC to write the generated sources to disk (using the -s option; if using Maven you have nothing to do), then make sure the destination directory of generated source files is in the classpath for GWT (if using Maven, use at least version 3.5.1 of the maven-compiler-plugin; failing that you'd have to hack around with the build-helper-maven-plugin).

Also note that GWT itself does not run annotation processors so whenever you make a change, make sure to recompile your classes to re-run the annotation processors. This is particularly important when using SuperDevMode (though your IDE might take care of that for you)

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • I am using Ant. Generated sources (.java and .class) are along with the client class of GWT in the same package after build. However, GWT compiler fails and tells `did you forget to inherit a required module? Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly` – Baris Sep 21 '16 at 14:38
  • This is an issue only at SuperDev mode. Even the SDM server starts without any problem, I get the error when I press "compile" at the browser. – Baris Sep 23 '16 at 09:23
  • I can't help further without more information on your build. Maybe show snippets of your Ant build file? (how you compile your Java classes and how you run SDM) – Thomas Broyer Sep 23 '16 at 09:59
0

Adding Eclipse generated folder, which includes AP generated class, in the classpath solved this issue:

        <java classname="com.google.gwt.dev.codeserver.CodeServer">
        <classpath>
            .
            .
            .
            <pathelement location=".apt_generated"/>
            .
            .
            .
        </classpath>
Baris
  • 471
  • 6
  • 19