tags:

views:

1369

answers:

1

Hello all,

I need to compile my GWT 1.7 project from my ant build file....anyone know how to do that???

I was able to do this in GWT 1.5 with the following code in my ant file:

<target name="compile">
   <exec executable="${root.dir}/HelloWorld-compile.cmd"  failonerror="true"/>

+4  A: 

Hi rafael, here are some ant targets that I use to run in hosted mode and to compile using gwt 1.7.1.

<property name="src.dir" value="src/main/java" />
<property name="build.dir" value="war" />

<path id="compile.classpath">
     <fileset dir="${build.dir}/WEB-INF/lib">
      <include name="**/*.jar" />
      <include name="**/*.xml" />
     </fileset>
    </path>

<target name="hosted" depends="javac" description="Starts gwt project in a standalone hosted browser and runs embedded jetty on port 8888">
         <java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode">
          <classpath>
           <pathelement location="${src.dir}" />
           <path refid="compile.classpath" />
          </classpath>
          <jvmarg value="-Xms256M" />
          <jvmarg value="-Xmx256M" />
          <arg value="-startupUrl" />
          <arg value="index.html" />
          <arg value="com.gwt-example.ModuleName" />
         </java>
        </target>

<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
         <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
          <classpath>
           <pathelement location="${src.dir}" />
           <path refid="compile.classpath" />
          </classpath>
          <jvmarg value="-Xmx256M" />
          <arg value="com.gwt-example.ModuleName" />
         </java>
        </target>
Dave Paroulek
Hi Dave,What do the following do:<pathelement location="${src.dir}" /><path refid="compile.classpath" />
rafael
Dave,I now get the following:compile: [java] java.lang.NoClassDefFoundError: com/google/gwt/dev/Compiler [java] Exception in thread "main"
rafael
seems like I am missing a reference to the gwt jars. btw, this is all on windows.
rafael
Hi Rafael, it sounds like you're missing the gwt dlls. Ensure that gwt-ll.dll and swt-w32-3235.dll is on your class path. In the example above, the ant script expects those dll's to exist inside war/WEB-INF/lib. <pathelement location="${src.dir}" /> tells ant to include the all source code found under "src/main/java" directory in the classpath when running "java" cmd. ${src.dir} is an ant property defined above as <property name="src.dir" value="src/main/java" />.
Dave Paroulek
<path refid="compile.classpath" /> tells ant to include all the stuff under war/WEB-INF/lib when running the "java" command. In this example, compile.classpath is defined as<path id="compile.classpath"> <fileset dir="${build.dir}/WEB-INF/lib"> <include name="**/*.jar" /> <include name="**/*.xml" /> </fileset> </path>Hope that helps.
Dave Paroulek
Thanks Dave.This also helped:http://code.google.com/webtoolkit/doc/1.6/RefCommandLineTools.html
rafael