本文介绍了用ant编译gwt项目的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我已经使用 GWT 有一段时间了,到目前为止只使用了 eclipse 插件来编译我的项目.由于新需求,我需要使用 ant build(第一次)来构建 gwt 项目.首先,我会说我有 2 个模块,它们有一个入口点和 2 个其他通用模块,它们只包含 java 类(应该转换为 js),它们位于我工作区的不同项目中.

I've been using GWT for quite some time now and have only used the eclipse plugin to compile my projects so far. Due to a new requirement I need to use an ant build (for the first time) to build a gwt project. First I'll say that I have 2 modules which have an entry point and 2 other common modules which only contain java classes (which should be translated to js) and they sit in a different project in my workspace.

目前我有 GWT 项目,它需要 Common 项目,而后者又需要 DAL 项目(当我说 require 时,我的意思是它在 eclipse 项目构建路径中如此定义).在我的 GWT 项目中,我在适当的位置有一个 Common.gwt.xml 和 DAL.gwt.xml 文件,它们将这些文件定义为模块,而我的 ModuleEntryPoint.gwt.xml 继承了这两个模块(除了其他模块).当我目前使用 gwt eclipse 插件编译时一切正常.

Currently I have the GWT project which requires the Common project which in turn requires the DAL project (when I say require I mean that it is so defined in the eclipse project build path). In my GWT project I have, in an appropriate location, a Common.gwt.xml and DAL.gwt.xml files which define those as modules and my ModuleEntryPoint.gwt.xml inherits those two modules (in addition to other modules). When I currently use the gwt eclipse plugin to compile everything works well.

但是,当我尝试使用 ant build 来模拟这一点时,我的 ModuleEntryPoint 的编译失败了,因为编译器说它找不到属于 DAL 模块或 Common 模块的类的源.

However when I tried to simulate this with the ant build the compilation of my ModuleEntryPoint fails as the compiler says it cannot find sources for classes which belong to DAL module or Common module.

ant 构建代码非常基础,因为这是我的第一次尝试.
在此先感谢您提供的任何帮助.

The ant build code is very basic as this is my first attemp.
Thanks in advance for any help granted.

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

    <fileset dir="${GWT.dir}">
            <include name="**/*.jar" />
            <include name="**/*.dll" />
    </fileset>

</path>

<target name="clear_previous_war">
<delete dir="${build.dir}" />
<mkdir dir="${build.dir.WEB-INF.classes}"/>
<mkdir dir="${build.dir.WEB-INF.lib}"/>
<target name="build_common" >
    <jar destfile="${build.dir.WEB-INF.lib}/${jar.common}"
        basedir="${common.dir.build}"
        includes="com/**"
        excludes="**/.svn"
      />
</target>

<target name="build_dal" >
    <jar destfile="${build.dir.WEB-INF.lib}/${jar.dal}"
        basedir="${dal.dir.build}"
        includes="com/**"
        excludes="**/.svn"
      />
</target>

<target name="copy_additional_files" >
    ... Copies all required external jars to web-inf/lib
</target>

<target name="compile_web_classes" >
    <javac srcdir="src" classpathref="compile.classpath"
    destdir="${build.dir.WEB-INF.classes}"
            source="1.6"/>
</target>

<target name="compile_gwt_button"  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.myCompany.web.Button" />
                </java>
 </target>

<target name="deploy" description="Build web project">
    <antcall target="clear_previous_war" />
    <antcall target="build_common" />
    <antcall target="build_dal" />
    <antcall target="copy_additional_files" />
    <antcall target="compile_web_classes" />
    <antcall target="compile_gwt_button" />
</target>

推荐答案

compile-gwt 任务中,我没有给他公共模块的源路径 (../Common/src 等),所以我添加了它并且它可以工作.类似的东西:

In the compile-gwt task I didn't give him the path to the sources of the common modules (../Common/src etc) so I've added it and it works.Something like:

<classpath>
    <pathelement location="src"/>
    <pathelement location="../Common/src"/>
    <path refid="gwt.compile.classpath"/>
  </classpath>

这篇关于用ant编译gwt项目的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 17:24