分享
 
 
 

readAppfuse-Ant任务续

王朝java/jsp·作者佚名  2006-01-31
窄屏简体版  字體: |||超大  

v db-load: 把示例数据加载到数据库中

Ø 任务定义:

<target name="db-load" depends="prepare"

description="Loads the database with sample data">

<property name="operation" value="CLEAN_INSERT"/>

<property name="file" value="metadata/sql/sample-data.xml"/>

<dbunit driver="${database.driver_class}"

supportBatchStatement="false"

url="${database.url}"

userid="${database.username}"

password="${database.password}">

<operation type="${operation}" src="${file}" format="xml"/>

</dbunit>

</target>

Ø 运行结果:

[dbunit] Executing operation: CLEAN_INSERT

[dbunit] on file: E:\app\appfuse\metadata\sql\sample-data.xml

[dbunit] with format: xml

(connection.DriverManagerConnectionProvider 143 ) cleaning up connection pool: jdbc:mysql://localhost/appfuse?autoReconnect=true&useUnicode=true&characterEncoding=utf-8

v setup-tomcat: copies jdbc driver and context.xml to tomcat

Ø 运行结果:

[echo] Detected Tomcat 5...

[echo] Copying appfuse.xml...

[copy] Copying 1 file to E:\tomcat\conf\Catalina\localhost

[echo] Copying mysql JDBC Driver...

[copy] Copying 1 file to E:\tomcat\common\lib

[echo] Copying jta.jar...

v compile-service:编译service下的类

Ø 运行结果:

compile-module:

[echo] Compiling service...

[mkdir] Created dir: E:\app\appfuse\build\service\classes

[mkdir] Created dir: E:\app\appfuse\build\test\service\classes

[javac] Compiling 16 source files to E:\app\appfuse\build\service\classes

[javac] Note: Some input files use unchecked or unsafe operations.

[javac] Note: Recompile with -Xlint:unchecked for details.

[javac] Compiling 7 source files to E:\app\appfuse\build\test\service\classes

[javac] Note: Some input files use unchecked or unsafe operations.

[javac] Note: Recompile with -Xlint:unchecked for details.

v package-service:打包service

Ø 运行结果:

[jar] Building jar: E:\app\appfuse\dist\appfuse-service.jar

v copy-resources: 拷贝应用需要的各种配置文件到build\web\classes和

build\appfuse\WEB-INF,而且在此任务中会进行中文转换码工作,借助JDK的native2ascii工具将资源文件ApplicationResources_zh_CN.properties中的内容进行转码。

Ø 任务定义:

<target name="copy-resources" depends="prepare"

description="Copy .properties and .xml files from source directory">

<copy todir="${build.dir}/web/classes" includeEmptyDirs="no">

<fileset dir="web/WEB-INF/classes">

<exclude name="ApplicationResources_zh_CN.properties"/>

<include name="*.properties"/>

<include name="*.xml"/>

<include name="*.vm"/>

</fileset>

<filterset refid="variables.to.replace"/>

</copy>

<native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"

includes="ApplicationResources_zh_CN.properties" encoding="UTF-8"/>

<!-- Copy Spring configuration files -->

<copy overwrite="true"

tofile="${webapp.target}/WEB-INF/applicationContext-${dao.type}.xml">

<fileset dir="src/dao" includes="**/*-${dao.type}.xml"/>

<filterset refid="variables.to.replace"/>

</copy>

<copy

tofile="${webapp.target}/WEB-INF/applicationContext-service.xml">

<fileset dir="src/service" includes="**/*-service.xml"/>

</copy>

<antcall target="generate.database.properties"/>

<copy todir="${build.dir}/web/classes" file="database.properties"/>

</target>

Ø 运行结果:

[copy] Copying 10 files to E:\app\appfuse\build\web\classes

[native2ascii] Converting 1 file from E:\app\appfuse\web\WEB-INF\classes to E:\app\appfuse\build\web\classes

[copy] Copying 1 file to E:\app\appfuse\build\appfuse\WEB-INF

[copy] Copying 1 file to E:\app\appfuse\build\appfuse\WEB-INF

v copy-web-files:

Ø 任务定义:

<target name="copy-web-files" depends="prepare"

description="Copy static files">

<echo message="Copying static files"/>

<copy todir="${webapp.target}" includeEmptyDirs="no">

<fileset dir="${basedir}/web">

<include name="**"/>

<exclude name="common/footer.jsp"/>

<exclude name="pages/**"/>

<exclude name="**/classes/**"/>

<exclude name="**/*-resources.xml"/>

</fileset>

</copy>

<!-- Remove the copy block below if you're not displaying

version/copyright in the footer -->

<copy todir="${webapp.target}">

<fileset dir="web" includes="common/footer.jsp"/>

<filterset>

<filter token="APPVERSION" value="${webapp.version}"/>

<filter token="COPYRIGHT-YEAR" value="${copyright.year}"/>

</filterset>

</copy>

<!-- Copy JSP Pages under WEB-INF/pages -->

<copy todir="${webapp.target}/WEB-INF">

<fileset dir="${basedir}/web">

<include name="pages/**/*.jsp"/>

</fileset>

</copy>

<!-- Copy *.txt files so they can be included in release notes -->

<copy todir="${webapp.target}">

<fileset dir="${basedir}">

<include name="*.txt"/>

<exclude name="README-new.txt"/>

</fileset>

</copy>

</target>

Ø 运行结果:

[echo] Copying static files

[copy] Copying 64 files to E:\app\appfuse\build\appfuse

[copy] Copying 1 file to E:\app\appfuse\build\appfuse

[copy] Copying 12 files to E:\app\appfuse\build\appfuse\WEB-INF

[copy] Copying 2 files to E:\app\appfuse\build\appfuse

v gen-forms: 利用xdoclet 和struts_form.xdt,根据module目录中的POJO生成

Struts的ActionFrom

Ø 任务定义:

<!-- Generate ActionForms from POJOs -->

<target name="gen-forms" depends="prepare" unless="webdoclet.uptodate"

description="Generates ActionForms from POJOs">

<taskdef name="xdoclet" classname="xdoclet.DocletTask"

classpathref="xdoclet.classpath"/>

<!-- generate struts forms -->

<xdoclet destdir="${build.dir}/web/gen"

excludedtags="@version,@author"

addedtags="@xdoclet-generated at ${TODAY}"

force="${xdoclet.force}"

mergedir="metadata/web">

<fileset dir="src/dao"/>

<!-- generate struts forms -->

<actionform templateFile="metadata/templates/struts_form.xdt">

<packageSubstitution packages="model"

substituteWith="webapp.form"/>

</actionform>

</xdoclet>

</target>

Ø 运行结果:

[xdoclet] (XDocletMain.start 47 ) Running <actionform/>

[xdoclet] --> UserForm

[xdoclet] --> RoleForm

[xdoclet] --> AddressForm

v compile-web:编译web目录中的类,appfuse中的web服务类是不被打包成jar文件的,

直接放在WEB-INF/class目录下调用。

Ø 运行结果:

compile-module:

[echo] Compiling web...

[mkdir] Created dir: E:\app\appfuse\build\test\web\classes

[javac] Compiling 28 source files to E:\app\appfuse\build\web\classes

v webdoclet:利用xdoclet.modules.web.WebDocletTask工具,生成了web.xml、

appfuse.tld、struts-config.xml 、struts_config_xml.xdt 、validation.xml 、

validation_xml.xdt等文件

Ø 任务定义:

<!-- =================================================================== -->

<!-- The "webdoclet" target generates web and struts deployment -->

<!-- descriptors. -->

<!-- =================================================================== -->

<target name="webdoclet" depends="compile-web"

unless="webdoclet.unnecessary"

description="Generate web and Struts descriptors">

<taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask">

<classpath>

<path refid="xdoclet.classpath"/>

<path refid="web.compile.classpath"/>

</classpath>

</taskdef>

<webdoclet destdir="${webapp.target}/WEB-INF"

force="${xdoclet.force}"

mergedir="metadata/web"

excludedtags="@version,@author"

verbose="true">

<fileset dir="src/web"/>

<fileset dir="${build.dir}/web/gen"/>

<deploymentdescriptor validateXML="true"

servletspec="2.3" sessiontimeout="10"

destdir="${webapp.target}/WEB-INF" distributable="false"

displayname="${ant.project.name}">

<configParam name="httpPort" value="${http.port}"/>

<configParam name="httpsPort" value="${https.port}"/>

<configParam name="daoType" value="${dao.type}"/>

<configParam name="security" value="${security.mode}"/>

</deploymentdescriptor>

<jsptaglib validateXML="true"

description="Custom tag library for this application"

shortName="${webapp.name}" filename="${webapp.name}.tld"/>

<strutsconfigxml validateXML="true" version="1.2"/>

<strutsvalidationxml/>

</webdoclet>

</target>

Ø 运行结果:

[webdoclet] (XDocletMain.start 47 ) Running <deploymentdescriptor/>

[webdoclet] Generating web.xml.

[webdoclet] (XDocletMain.start 47 ) Running <jsptaglib/>

[webdoclet] Generating appfuse.tld.

[webdoclet] (XDocletMain.start 47 ) Running <strutsconfigxml/>

[webdoclet] (TemplateSubTask.engineStarted 805 ) Generating output 'struts-config.xml' using template file 'jar:file:E:\app\appfuse\lib\xdoclet-1.2.2\lib\xdoclet-apache-module-1.2.2.jar!/xdoclet/modules/apache/struts/resources/struts_config_xml.xdt'.

[webdoclet] (XDocletMain.start 47 ) Running <strutsvalidationxml/>

[webdoclet] (TemplateSubTask.engineStarted 805 ) Generating output 'validation.xml' using template file 'jar:file:E:\app\appfuse\lib\xdoclet-1.2.2\lib\xdoclet-apache-module-1.2.2.jar!/xdoclet/modules/apache/struts/resources/validation_xml.xdt'.

v package-web:打包部署文件war

Ø 任务定义:

<target name="package-web" depends="compile-web,jsp-2"

description="Package WAR">

<propertyfile comment="Build Information"

file="${build.dir}/web/classes/build.properties">

<entry key="build.date" type="date" pattern="EEEE MMM dd, yyyy"

value="now"/>

<entry key="build.time" type="date" pattern="hh:mm:ss a zz"

value="now"/>

<entry key="build.username" value="${user.name}"/>

<entry key="build.computer" value="${env.COMPUTERNAME}"/>

<entry key="build.dao.type" value="${dao.type}"/>

<entry key="webapp.version" value="${webapp.version}"/>

</propertyfile>

<!-- If Tomcat 5, uncomment the <dispatcher> elements in

filter-mappings -->

<if>

<or>

<isset property="tomcat5"/>

<isset property="tomcat5.5"/>

</or>

<then>

<replaceregexp flags="g"

file="${webapp.target}/WEB-INF/web.xml"

match='&lt;!--dispatcher&gt;'

replace='&lt;dispatcher&gt;'/>

<replaceregexp flags="g"

file="${webapp.target}/WEB-INF/web.xml"

match='&lt;/dispatcher--&gt;'

replace='&lt;/dispatcher&gt;'/>

</then>

</if>

<echo>Preparing tomcat-context.xml for inclusion in war</echo>

<!-- Copy tomcat-context.xml file to context.xml -->

<if>

<and>

<isset property="tomcat5"/>

<not><isset property="tomcat5.5"/></not>

</and>

<then>

<copy tofile="${webapp.dist}/context.xml"

file="metadata/conf/tomcat-context.xml" overwrite="true">

<filterset refid="db.variables"/>

</copy>

</then>

<elseif>

<isset property="tomcat5.5"/>

<then>

<copy tofile="${webapp.dist}/context.xml"

file="metadata/conf/tomcat-context-5.5.xml" overwrite="true">

<filterset refid="db.variables"/>

</copy>

</then>

</elseif>

</if>

<!-- Change the path so webapp can find .hbm in appfuse-dao.jar -->

<replace file="${webapp.target}/WEB-INF/applicationContext-${dao.type}.xml">

<replacetoken>file:dist</replacetoken>

<replacevalue>WEB-INF/lib</replacevalue>

</replace>

<!-- Copy .properties files in src tree to build/web/classes -->

<copy todir="${build.dir}/web/classes">

<fileset dir="src/web">

<include name="**/*.properties"/>

<include name="**/*.xml"/>

</fileset>

</copy>

<war destfile="${webapp.dist}/${webapp.war}"

webxml="${webapp.target}/WEB-INF/web.xml" compress="true">

<fileset dir="${webapp.target}" excludes="**/web.xml,**/*-resources.xml"/>

<metainf dir="${webapp.dist}" includes="context.xml"/>

<classes dir="${build.dir}/web/classes">

<exclude name="**/database.properties"/>

</classes>

<lib file="${dist.dir}/${webapp.name}-dao.jar"/>

<lib file="${dist.dir}/${webapp.name}-service.jar"/>

<webinf dir="${struts.dir}" includes="*.xml"/>

<webinf dir="web/WEB-INF" includes="*-resources.xml"/>

<lib file="${clickstream.jar}"/>

<lib dir="${struts.dir}" includes="*.jar"/>

<lib dir="${jstl.dir}/lib">

<include name="jstl.jar"/>

<include name="standard.jar"/>

</lib>

<lib dir="${javamail.dir}" includes="*.jar"/>

<lib file="${log4j.jar}"/>

<lib file="${strutsmenu.jar}"/>

<lib dir="${displaytag.dir}" includes="*.jar"/>

<lib file="${hibernate.jar}"/>

<lib dir="${hibernate.dir}/lib">

<include name="odmg*.jar"/>

<include name="dom4j*.jar"/>

<include name="cglib*.jar"/>

<include name="ehcache*.jar"/>

<include name="oscache*.jar"/>

</lib>

<lib dir="${spring.dir}" includes="*.jar"/>

<lib file="${sitemesh.jar}"/>

<lib dir="${velocity.dir}" includes="*.jar"/>

<lib file="${urlrewrite.jar}"/>

</war>

</target>

Ø 运行结果:

[propertyfile] Creating new property file: E:\app\appfuse\build\web\classes\build.properties

[echo] Preparing tomcat-context.xml for inclusion in war

[copy] Copying 1 file to E:\app\appfuse\dist\webapps

[copy] Copying 1 file to E:\app\appfuse\build\web\classes

[war] Building war: E:\app\appfuse\dist\webapps\appfuse.war

v deploy:部署应用

Ø 运行结果:

[unwar] Expanding: E:\app\appfuse\dist\webapps\appfuse.war into E:\tomcat\webapps\appfuse

setup:

BUILD SUCCESSFUL

Total time: 10 minutes 38 seconds

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有