找不到 MyModule.gwt.xml使用 Ant 编译 GWT 项目



我用这个蚂蚁脚本有错误:

<path id="gwt-client.classpath">
    <fileset dir="${src.dir}">
        <include name="**/*.gwt.xml" />
    </fileset>
    <pathelement location="${gwt.client.dir}" />
    <pathelement location="${gwt.shared.dir}" />
</path>
<path id="gwt-sdk.classpath">
    <fileset dir="${gwt.sdk.dir}">
        <include name="**/*.jar" />
    </fileset>
</path>
<target name="gwt-compile" depends="prepareResources">
    <property name="clientClasspath" refid="gwt-client.classpath" />
    <echo message="==> gwt-client classpath = ${clientClasspath}" />
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
        <classpath>
            <path refid="gwt-sdk.classpath" />
            <path refid="gwt-client.classpath" />
        </classpath>
        <jvmarg value="-Xmx256M" />
        <arg line="${gwt.module.name} -logLevel INFO  -style PRETTY" />
    </java>
</target>

虽然控制台告诉我很棒的事情:

[echo] ==> gwt-client classpath = 
  C:coderepositorycommentssrciorobustaforacommentsComments.gwt.xml;
  C:coderepositorycommentssrciorobustaforacommentsclient;
  C:coderepositorycommentssrciorobustaforacommentsshared

所有这些文件都存在,但我有一个非常经典的错误:

[java] Loading inherited module 'io.robusta.fora.comments.Comments'
     [java]    [ERROR] Unable to find 'io/robusta/fora/comments/Comments.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

倾向于认为我错过了路径、路径元素、refid 之间的蚂蚁术语......或者错误消息应查找src/io/robusta/fora/comments/Comments.gwt.xml而不是io/robusta/fora/comments/Comments.gwt.xml

我认为您误解了类路径的工作原理。类路径中的每个路径元素都是一个,用于解析完全限定名(包 + 类名)。这些路径可以是文件夹或存档(ZIP 或 JAR)。

io.robusta.fora.comments.client包中的类(在您的情况下)位于C:corerepositorycommentssrc文件夹中。这是类路径中应该包含的内容。

资源也是如此:io/robusta/fora/comments/Comments.gwt.xml在类路径中查找,因此,在您的情况下,C:corerepositorycommentssrc应该在类路径中,以便可以将相对路径正确解析为文件。

最新更新