私のプロジェクトでは、クライアントモジュールで継承されていないGWTクラスを拡張しようとしています。たとえば、com.google.gwt.resources.ext.ResourceGeneratorの簡単な実装を作成したいと思います。
public class SimpleResourceGenerator implements ResourceGenerator
ClientBundleのデフォルトの@ResourceGeneratorTypeの代わりに使用します-BundleResourceGenerator
@ResourceGeneratorType(SimpleResourceGenerator.class)
public interface Resources extends ClientBundle {
しかし失敗。
SimpleResourceGeneratorクラスを「client」パッケージの下に置くと、GWTコンパイラーは次のように言います。
[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?
すべてのgwt-userおよびgwt-devソースをプロジェクトにリンクすると、他の未解決の依存関係があります。
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
GWTコンパイラと、コンパイル時に型を解決する方法を理解できません。一部のGWTクラスが検出され、他のクラスが検出されない理由。
私が見る唯一の方法は、SimpleResourceGeneratorのモジュール書き換えをコンパイルすることです
<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>
継承されたcom.google.gwt.resources.Resources.gwt.xmlから独自のジェネレーターを使用
<generate-with
class="com.example.gwt.SimpleBundleGenerator">
<when-type-assignable
class="com.google.gwt.resources.client.ClientBundle" />
</generate-with>
com.google.gwt.resources.rebind.context.AbstractClientBundleGeneratorを拡張します。
しかし、それは私には少し複雑すぎるようです。ジェネレーターやコード置換を介した遅延バインディングよりもGWTクラスを拡張する簡単な方法はありますか?