问题描述
我现在已经使用GWT相当长的一段时间了,并只使用Eclipse插件来编译我的项目至今。由于新的要求,我需要使用Ant构建(首次),以建立一个GWT项目。首先,我会说我有2个模块,有一个入口点,只包含Java类(应翻译成JS)2等常用模块和他们坐在不同的项目在我的工作区。
目前我有需要这反过来又要求DAL项目公用工程(当我说我需要意味着它在Eclipse项目的构建路径,以便定义)GWT项目。在我的GWT项目我有,在适当的位置,它定义这些作为模块Common.gwt.xml和DAL.gwt.xml文件和我的ModuleEntryPoint.gwt.xml继承了这两个模块(除其他模块)。当我目前使用的GWT Eclipse插件来编译一切正常。
然而,当我试图用蚂蚁来模拟这种建立我ModuleEntryPoint的编译,因为编译器说,它无法找到属于DAL模块或通用模块类源失败。
Ant构建code是很基本的,因为这是我第一次学尝试。结果
在此先感谢您的帮助视为理所当然。
<路径ID =compile.classpath>
<文件集DIR =$ {build.dir.WEB-INF.lib}>
<包括姓名=** / *罐子。/>
<包括姓名=** / * XML。/>
< /文件集>
<文件集DIR =$ {} ExternalLib.WebServer.dir>
<包括姓名=** / *罐子。/>
<包括姓名=** / * XML。/>
< /文件集> <文件集DIR =$ {} GWT.dir>
<包括姓名=** / *罐子。/>
<包括姓名=** / * DLL。/>
< /文件集>< /路径><目标名称=clear_ previous_war>
<删除DIR =$ {} build.dir/>
< MKDIR DIR =$ {build.dir.WEB-INF.classes}/>
< MKDIR DIR =$ {build.dir.WEB-INF.lib}/>
<目标名称=build_common>
<罐子destfile =$ {build.dir.WEB-INF.lib} / $ {} jar.common
BASEDIR =$ {} common.dir.build
包括=COM / **
排除=** /。SVN
/>
< /目标与GT;<目标名称=build_dal>
<罐子destfile =$ {build.dir.WEB-INF.lib} / $ {} jar.dal
BASEDIR =$ {} dal.dir.build
包括=COM / **
排除=** /。SVN
/>
< /目标与GT;<目标名称=copy_additional_files>
......将所有所需的外部罐子到WEB-INF / lib目录
< /目标与GT;<目标名称=compile_web_classes>
< javac的SRCDIR =SRCclasspathref =compile.classpath
DESTDIR =$ {build.dir.WEB-INF.classes}
来源=1.6/>
< /目标与GT;<目标名称=compile_gwt_button描述=GWT编译成JavaScript>
< java的failonerror =真正的叉=真正的类名=com.google.gwt.dev.Compiler>
<&类路径GT;
< pathelement位置=$ {}对于src.dir/>
<路径REFID =compile.classpath/>
< /类路径>
< jvmarg值= - Xmx256M/>
< ARG值=com.myCompany.web.Button/>
< / JAVA>
< /目标与GT;<目标名称=部署描述=构建Web项目>
< antcall目标=clear_ previous_war/>
< antcall目标=build_common/>
< antcall目标=build_dal/>
< antcall目标=copy_additional_files/>
< antcall目标=compile_web_classes/>
< antcall目标=compile_gwt_button/>
< /目标与GT;
在编译GWT
的任务,我没有给他的路径,共同的来源模块(../Common/src等),所以我已经添加了它和它的作品。
是这样的:
<&类路径GT;
< pathelement位置=SRC/>
< pathelement位置=../通用/ src目录/>
<路径REFID =gwt.compile.classpath/>
< /类路径>
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.
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.
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.
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>
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>
这篇关于问题编译GWT项目与蚂蚁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!