简体   繁体   中英

GWT can't find .gwt.xml

I'm trying to run GWT through an ant build, because I want to implement it in my java project. My build.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="test-exporter" default="devmode">

<property name="lib" location="war/WEB-INF/lib"/>

<path id="gwt.classpath">
    <fileset dir="${lib}">
        <include name="*.jar"/>
    </fileset>
</path>

<target name="devmode">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
        <classpath refid="gwt.classpath"/>
        <jvmarg value="-Xmx1024M"/>
        <jvmarg value="-XX:MaxPermSize=256m" />
        <jvmarg value="-XX:+UseCompressedOops" />
        <arg value="-startupUrl"/>
        <arg value="Test.html"/>
        <arg line="-bindAddress" />
        <arg line="0.0.0.0" />
        <arg value="com.test.Test"/>
    </java>
</target>

</project>

But when I'm trying to run this, GWT says that it can't find my /com/test/Test.gwt.xml. The Test.gwt.xml file is located in package com.test so it should be able to find it. Do I have to add the .xml to the classpath aswell? Running it with the Eclipse plugin works, but I'm really looking to run it through ant build

You are not specifying <pathelement location="src"/> . Refer below correct build.xml.

 <?xml version="1.0" encoding="UTF-8"?>
    <project name="test-exporter" default="devmode" >

    <property name="lib" location="war/WEB-INF/lib"/>

    <path id="gwt.classpath">
        <fileset dir="${lib}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="devmode">
        <java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
            <classpath>
            <pathelement location="src"/>
            <path refid="gwt.classpath" />
            </classpath> 
            <jvmarg value="-Xmx1024M"/>
            <jvmarg value="-XX:MaxPermSize=256m" />
            <arg value="-startupUrl"/>
            <arg value="Test.html"/>
            <arg line="-bindAddress" />
            <arg line="0.0.0.0" />
            <arg />
            <arg value="com.test.Test"/>
        </java>
    </target>

    </project>

This is a valid devmode target:

  <target name="devmode" depends="javac" description="Run development mode">
   <java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
     <classpath>
       <pathelement location="src"/>
       <path refid="project.class.path"/>
       <pathelement location="../../validation-api-1.0.0.GA.jar" />
       <pathelement location="../../validation-api-1.0.0.GA-sources.jar" />
     </classpath>
     <jvmarg value="-Xmx256M"/>
     <arg value="-startupUrl"/>
     <arg value="Showcase.html"/>
     <arg line="-war"/>
     <arg value="war"/>
     <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
     <arg line="${gwt.args}"/>
     <arg value="com.google.gwt.sample.showcase.Showcase"/>
   </java>
 </target>

You did not specify GWT arguments, you have to modify it according to your project. There are also some good GWT project that config with ant in samples folder in GWT distribution zip file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM