上面是厂里给的项目中的一个build.xml配置文件,一共11个target,在ant中加载后如下显示
右击ant,选择run build,编译
在这个项目的子文件夹下的build文件夹下生成了这三个文件夹,如下图
此后运行tomcat,项目中的对应功能即可运行。
ant的功能就是构建和部署web项目下面贴一下build.xml的源码
<!DOCTYPE project [ <!ENTITY properties SYSTEM "file:./properties.xml"> ]> <project name="calendar" basedir="." default="oracle-prepare"> <taskdef resource="jst-task.properties" classpath="../../web/script/src/jsa.jar"/> &properties; <target name="compile"> <echo level="info">Compiling ...</echo> <mkdir dir="${build.dir}/classes"/> <property name="excludes" value=""/> <property name="additional.src.dirs" value=""/> <javac srcdir="src;${additional.src.dirs}" destdir="${build.dir}/classes" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" classpathref="compile.classpath"/> </target> <target name="jar" depends="compile" description="Package JAR"> <jar destfile="${dist.dir}/${webapp.name}-${dist.version}.jar"> <manifest> <attribute name="Class-Path" value="${webapp.name}-${dist.version}.jar"/> </manifest> <fileset dir="${build.dir}/classes"/> </jar> </target> <target name="navtiveresource" description="native to ascii"> <delete dir="${build.dir}/i18n"/> <mkdir dir="${build.dir}/i18n"/> <native2ascii src="../../deploy" dest="${build.dir}/i18n" includes="env.properties" encoding="GB2312"/> <native2ascii src="${config.dir}" dest="${build.dir}/i18n" includes="messages.properties" encoding="GB2312"/> </target> <target name="pack-script" description="pack javascript"> <jscompress destDir="${script.dir}/src/build" charset="utf-8" allInOneFileName="calendar-all.js" syntaxcompression="false" textcompression="false" compatible="true"> <fileset dir="${script.dir}/src"> <include name="common/lang/en.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/lang/cn.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/namespaces.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/overrides.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/windows/AboutDialog.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/windows/LoginDialog.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/data/Connection.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/data/JsonStore.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/grids/GridPanel.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/grids/SimpleSelectList.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/grids/CheckColumn.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/common.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/state/HttpProvider.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/plugins/DataView.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/plugins/HtmlEditorImageInsert.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/panels/DisplayPanel.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/panels/IframeComponent.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/windows/SelectGroups.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/windows/SelectUsers.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/windows/SelectEmail.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/SearchField.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/Combo.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/ColorField.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/ComboReset.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/ComboBoxMulti.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/UploadFile.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/PlainField.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/SelectUser.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/SelectCountry.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/FileUploadField.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/HtmlComponent.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/form/NumberField.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/panels/PermissionsPanel.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/ModuleManager.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/NewMenuButton.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinkFolderWindow.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/SelectLink.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinksTree.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinksGrid.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinksDialog.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinksPanel.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinksTemplate.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinksContextMenu.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinkBrowser.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/links/LinkViewWindow.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/panels/SearchPanel.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/panels/miframe.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="common/checker.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="lang/en.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="lang/cn.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="EventDialog.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="CalendarGrid.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="MonthGrid.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="ListGrid.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="ViewGrid.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="CalendarDialog.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="ViewDialog.js"/> </fileset> <fileset dir="${script.dir}/src"> <include name="Calendar.js"/> </fileset> </jscompress> <copy overwrite="true" todir="${script.dir}"> <fileset dir="${script.dir}/src/build"> <include name="calendar-all.js"/> </fileset> </copy> </target> <target name="oracle-prepare" depends="jar,navtiveresource" description="prepare WAR"> <!-- <delete includeEmptyDirs="true"> <fileset dir="${build.dir}/${webapp.name}"/> </delete>--> <mkdir dir="${build.dir}/${webapp.name}"/> <copy overwrite="true" todir="${build.dir}/${webapp.name}"> <fileset dir="web"> <include name="**/*.*"/> </fileset> </copy> <filter filtersfile="${build.dir}/i18n/env.properties"/> <copy overwrite="true" todir="${build.dir}/${webapp.name}/WEB-INF/classes" filtering="true"> <fileset dir="${config.dir}"> <include name="*.properties"/> <exclude name="messages.properties"/> </fileset> <fileset dir="${build.dir}/i18n"> <include name="messages.properties"/> </fileset> </copy> <copy overwrite="true" todir="${build.dir}/${webapp.name}/WEB-INF"> <fileset dir="${config.dir}"> <include name="*.xml"/> </fileset> </copy> <copy overwrite="true" todir="${build.dir}/${webapp.name}/WEB-INF/tags"> <fileset dir="../../config"> <include name="*.tld"/> </fileset> </copy> <copy overwrite="true" todir="${build.dir}/${webapp.name}/WEB-INF/lib"> <fileset dir="${dist.dir}"> <include name="${webapp.name}-${dist.version}.jar"/> </fileset> <fileset dir="${lib.dir}"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/aopalliance"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/jakarta-taglibs"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/jakarta-commons"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/xpp3-1.1.2"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/spring-2.0"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/log4j-1.2"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/prize-2.6.3"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/quartz-1.6.0"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/json"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/concurrent-1.3.2"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/jdom-1.0"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/xfire-1.2.6"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/jug"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/jaxen"> <include name="*.jar"/> </fileset> <fileset dir="../../lib/rome"> <include name="*.jar"/> </fileset> <fileset dir="../../dist"> <include name="cmstar-common*.jar"/> </fileset> </copy> </target> <target name="db2-prepare" depends="oracle-prepare" description="Package WAR"> <copy overwrite="true" todir="${build.dir}/${webapp.name}/WEB-INF"> <fileset dir="${db2Config.dir}"> <include name="environment.xml"/> </fileset> </copy> </target> <target name="test-prepare" depends="oracle-prepare" description="Package WAR"> <copy overwrite="true" todir="${build.dir}/${webapp.name}/WEB-INF"> <fileset dir="${testConfig.dir}"> <include name="environment.xml"/> </fileset> </copy> </target> <target name="oracle-war" depends="oracle-prepare" description="Package WAR"> <war destfile="${dist.dir}/${webapp.name}.war" webxml="${build.dir}/${webapp.name}/WEB-INF/web.xml" compress="true"> <fileset dir="${build.dir}/${webapp.name}" includes="**/*.*" excludes="**/web.xml"/> <manifest> <attribute name="Class-Path" value="cmstar-global-1.0.jar portlet-api-1.0.jar" /> </manifest> </war> </target> <target name="db2-war" depends="db2-prepare" description="Package WAR"> <war destfile="${dist.dir}/${webapp.name}.war" webxml="${build.dir}/${webapp.name}/WEB-INF/web.xml" compress="true"> <fileset dir="${build.dir}/${webapp.name}" includes="**/*.*" excludes="**/web.xml"/> </war> </target> <target name="test-war" depends="test-prepare" description="Package WAR"> <war destfile="${dist.dir}/${webapp.name}.war" webxml="${build.dir}/${webapp.name}/WEB-INF/web.xml" compress="true"> <fileset dir="${build.dir}/${webapp.name}" includes="**/*.*" excludes="**/web.xml"/> </war> </target> <target name="test" description="Runs all tests" depends="oracle-prepare"> <taskdef name="jtestr" classname="org.jtestr.ant.JtestRAntRunner" classpath="lib/jtestr-0.3.1.jar"/> <jtestr/> </target> </project>