gwtgwt-compiler

GWT compile POJO


I'm trying to use just the Java to Javascript compiler of the GWT from Ant.

Can I use the GWT compiler without extending any Google classes such as com.google.gwt.core.Core or similar. If so how? I'm currently using the setup below on GWT 2.4.0.

I'm calling the ant task:

build.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;

}

foot/Test1.gwt.xml

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

And output:

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')

Solution

  • The error indicates that you need to inherit 'com.google.gwt.core.Core' in your gwt.xml file and it is not saying that your class should extend/implement it. Give this a try:

    <?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>
    

    Or is it that you don't want your module to inherit it?