使用ant使用CssResource编译问题的GWT 2.2项目

发布于 2024-10-28 05:46:51 字数 1703 浏览 11 评论 0原文

在较大的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ˇ宁静的妩媚 2024-11-04 05:46:51

您需要在单独的任务中生成资源文件。生成它的调用(作为文档中的示例)是:

java -cp gwt-dev.jar:gwt-user.jar com.google.gwt.resources.css.InterfaceGenerator \
  -standalone -typeName some.package.MyCssResource -css input.css

所以它可以是一个 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:

java -cp gwt-dev.jar:gwt-user.jar com.google.gwt.resources.css.InterfaceGenerator \
  -standalone -typeName some.package.MyCssResource -css input.css

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文