2

我正在尝试仅使用 Ant 的 GWT 的 Java 到 Javascript 编译器。

我可以在不扩展任何 Google 类(例如com.google.gwt.core.Core或类似类)的情况下使用 GWT 编译器吗?如果有怎么办?我目前在 GWT 2.4.0 上使用下面的设置。

我正在调用蚂蚁任务:

构建.xml

 <target name="gwtc" description="GWT compile to JavaScript (production mode)">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
      <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
        <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
        <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
      </classpath>
      <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
      <jvmarg value="-Xmx256M"/>
      <arg line="-war"/>
      <arg value="war"/>
      <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
      <arg line="${gwt.args}"/>
      <arg value="foo.Test1"/>
    </java>
  </target>

foo/Test.java

package foo;

public class Test1 {
    public String field1;
    public String field2;
    public int field3;

}

脚/Test1.gwt.xml

<module rename-to="hello">
    <source path="foo.Test1"/>
    <!--entry-point class="foo.Test1"/-->
</module>

并输出:

gwtc:
     [java] Compiling module foo.Test1
     [java]    [ERROR] Unable to find type 'java.lang.Object'
     [java]       [ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User')
4

1 回答 1

1

该错误表明您需要'com.google.gwt.core.Core'gwt.xml文件中继承,并不是说您的类应该扩展/实现它。试试这个:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE 
    module 
    PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.3.0//EN" 
    "http://google-web-toolkit.googlecode.com/svn/tags/2.3.0/distro-source/core/src/gwt-module.dtd">

<module rename-to="hello">
    <inherits name="com.google.gwt.core.Core" />
    <source path="foo" />
</module>

还是您不希望您的模块继承它?

于 2011-09-19T14:28:02.643 回答