For my project I’ve trying to extend GWT classes that not inherited with client modules.
For example I want to create a simple implementation of com.google.gwt.resources.ext.ResourceGenerator.
public class SimpleResourceGenerator implements ResourceGenerator
and use instead of ClientBundle’s default @ResourceGeneratorType – BundleResourceGenerator
@ResourceGeneratorType(SimpleResourceGenerator.class)
public interface Resources extends ClientBundle {
but unsuccess.
If I place my SimpleResourceGenerator class under “client” package, GWT compiler says:
[ERROR] Line 11: No source code is available for type com.google.gwt.resources.ext.ResourceGenerator; did you forget to inherit a required module?
[ERROR] Line 13: No source code is available for type com.google.gwt.core.ext.TreeLogger; did you forget to inherit a required module?
[ERROR] Line 13: No source code is available for type com.google.gwt.resources.ext.ResourceContext; did you forget to inherit a required module?
[ERROR] Line 13: No source code is available for type com.google.gwt.core.ext.typeinfo.JMethod; did you forget to inherit a required module?
[ERROR] Line 14: No source code is available for type com.google.gwt.core.ext.UnableToCompleteException; did you forget to inherit a required module?
[ERROR] Line 19: No source code is available for type com.google.gwt.resources.ext.ClientBundleFields; did you forget to inherit a required module?
[ERROR] Line 36: No source code is available for type com.google.gwt.resources.ext.ClientBundleRequirements; did you forget to inherit a required module?
If I link all gwt-user and gwt-dev sources to project I have other unresolved dependencies.
Loading inherited module 'com.google.gwt.user.User'
Loading inherited module 'com.google.gwt.animation.Animation'
Loading inherited module 'com.google.gwt.core.Core'
Loading inherited module 'com.google.gwt.core.CrossSiteIframeLinker'
[ERROR] Unable to load class 'com.google.gwt.core.linker.DirectInstallLinker'
java.lang.ClassNotFoundException: com.google.gwt.core.linker.DirectInstallLinker
I can’t understand the GWT compiler and how it resolves types while compile-time. Why it finds some of GWT classes and can’t find the others.
The only way I see is to compile SimpleResourceGenerator’s module rewriting
<generate-with
class="com.google.gwt.resources.rebind.context.StaticClientBundleGenerator">
<!-- We have to specify on which types to execute the Generator -->
<when-type-assignable
class="com.google.gwt.resources.client.ClientBundle" />
</generate-with>
from inherited com.google.gwt.resources.Resources.gwt.xml with own generator
<generate-with
class="com.example.gwt.SimpleBundleGenerator">
<when-type-assignable
class="com.google.gwt.resources.client.ClientBundle" />
</generate-with>
and extend com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.
But it seems a little too complex to me.
Is there a more simple way to extend GWT classes than deferred binding via generators and code replacement?
Generators should not be included in a “client” package, but the java sources it generates should.
The “client” package is for the gwt-compile to find the java source files that it should use when compiling your app to javascript and a Generator is used to produce javasource files on compiletime.