使用ant使用CssResource编译问题的GWT 2.2项目
在较大的 GWT 2.2.0 应用程序中,我们希望使用动态 CellTable。与其他小部件不同,CellTable 不使用 css 样式的标准名称(例如“gwt-MenuItem”)。因此,我们必须从标准 css 迁移到 CssResource,它还必须包含标准的“gwt-”样式,如下所示:
public interface IPreferences
{
public interface MyCssResource extends CssResource
{
String content();
...
}
@ImportedWithPrefix("gwt")
public interface GwtCss extends CssResource
{
String MenuItem();
String MenuBar();
String TabLayoutPanelTab();
}
...
public interface MyResources extends ClientBundle
{
public static final MyResources INSTANCE = GWT.create(MyResources.class);
@Source("preferences.css")
@Import(GwtCss.class) <--- any imported interface will produce error
MyCssResource cssStd();
}
}
这在托管模式下工作正常,可以使用 eclipse 进行编译,但不能使用 ant 进行编译:
<target name="gwtc" depends="compile" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<pathelement location="gwt-servlet.jar"/>
<pathelement location="gwt-dev.jar"/>
<pathelement location="gwt-user.jar"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="war"/>
<arg value="...module.file"/>
</java>
</target>
[java] [ERROR] Annotation error: cannot resolve ...IPreferences$GwtCss
[java] java.lang.ClassNotFoundException: ...IPreferences$GwtCss
我可以没有找到任何提示必须做什么才能在 Eclipse 之外编译它。 感谢您的任何评论。
In a larger GWT 2.2.0 application we want to use dynamic CellTables. Unlike other widgets, CellTable does not use standard names for css styles (like e.g. "gwt-MenuItem"). So we have to move from standard css to CssResource, which must inlcude the standard "gwt-" styles also, like the following:
public interface IPreferences
{
public interface MyCssResource extends CssResource
{
String content();
...
}
@ImportedWithPrefix("gwt")
public interface GwtCss extends CssResource
{
String MenuItem();
String MenuBar();
String TabLayoutPanelTab();
}
...
public interface MyResources extends ClientBundle
{
public static final MyResources INSTANCE = GWT.create(MyResources.class);
@Source("preferences.css")
@Import(GwtCss.class) <--- any imported interface will produce error
MyCssResource cssStd();
}
}
This works fine in hosted mode and can be compiled using eclipse, but it does not compile using ant:
<target name="gwtc" depends="compile" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<pathelement location="gwt-servlet.jar"/>
<pathelement location="gwt-dev.jar"/>
<pathelement location="gwt-user.jar"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="war"/>
<arg value="...module.file"/>
</java>
</target>
[java] [ERROR] Annotation error: cannot resolve ...IPreferences$GwtCss
[java] java.lang.ClassNotFoundException: ...IPreferences$GwtCss
I could not find any hint what must be done to compile this outside of eclipse.
Thank you for any comment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在单独的任务中生成资源文件。生成它的调用(作为文档中的示例)是:
所以它可以是一个 java 任务,就像编译器一样。它记录在 gwt CssResource 文档中:http://code.google .com/p/google-web-toolkit/wiki/CssResource#Automatically_generate_interfaces
You need to generate the resource files in a separate task. The call (as an example from the documentation) to generate it is:
So it can be a java task, just like the compiler. It's documented at the gwt CssResource documentation: http://code.google.com/p/google-web-toolkit/wiki/CssResource#Automatically_generating_interfaces