【问题标题】:GWT 2.2 project with CssResource compile problem using ant带有 CssResource 的 GWT 2.2 项目使用 ant 编译问题
【发布时间】:2011-03-31 14:39:48
【问题描述】:

在更大的 GWT 2.2.0 应用程序中,我们希望使用动态 CellTables。与其他小部件不同,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 之外编译它必须做什么。 感谢您的任何评论。

【问题讨论】:

    标签: gwt ant cssresource


    【解决方案1】:

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

    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_generating_interfaces

    【讨论】:

    • 感谢您的提示。尽管我不明白为什么生成的界面应该比手动编写的界面“更好”,但对 InterfaceGenerator 的实验使我找到了一个解决方案,该解决方案首先避免使用 @Import:而不是在虚线上执行 @ImpportWithPrefix “ gwt-"-styles 生成器使用@Classname 注释。因此,所有样式都可以通过一个界面导入,无需@Import其他样式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-01
    • 2011-04-04
    • 2012-01-22
    • 2011-12-16
    相关资源
    最近更新 更多