(三)Ant Web Project 针对Web项目

编译Web Project的时候就要多注意文件之间的关系,图片文件不管是flex用到的还是web页面用到的都应该放到WebRoot下避免丢失!
Flex和Java文件的编译先后顺序没有关系,可以自行选择。
由于本人写此blog时早已忘记了在编写Ant脚本遇到的问题,只能是慢慢回忆,非常感慨“好记性不如烂笔头”。


<path id="java.classpath">
<pathelement location="build/WEB-INF/classes" />
<fileset dir="build/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
</path>

<target name="test.compile" depends="clean.bin">
<!-- 编译flex文件 -->
<mxmlc file="/flex_src/test.mxml" output="build/test.swf" actionscript-file-encoding="UTF-8"
optimize="true" debug="false" locale="en_US,zh_CN"
compiler.services="/WebRoot/WEB-INF/flex/services-config.xml"
compiler.context-root="/flex_src">

<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="/flex_src" />
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<library-path dir="test/public_swc" includes="*" append="true"/>
<library-path file="test/public_swc/aTest.swc" append="true"/>
</mxmlc>

<!-- 输出html文件 -->
<html-wrapper output="build/" file="test.html"
swf="test" history="true" express-install="true"
version-detection="true" version-major="10" version-minor="2"
version-revision="0" height="100%" width="100%" title="test"
bgcolor="white" />
<!-- 拷贝flex sdk库文件 -->
<copy file="${FLEX_HOME}/frameworks/rsls/spark_${SDK_VERSION}.swz" tofile="build/spark_${SDK_VERSION}.swz"/>
<copy file="${FLEX_HOME}/frameworks/rsls/sparkskins_${SDK_VERSION}.swz" tofile="build/sparkskins_${SDK_VERSION}.swz"/>
<copy file="${FLEX_HOME}/frameworks/rsls/framework_${SDK_VERSION}.swz" tofile="build/framework_${SDK_VERSION}.swz"/>
<copy file="${FLEX_HOME}/frameworks/rsls/mx_${SDK_VERSION}.swz" tofile="build/mx_${SDK_VERSION}.swz"/>
<copy file="${FLEX_HOME}/frameworks/rsls/textLayout_2.0.0.232.swz" tofile="build/textLayout_2.0.0.232.swz"/>
<copy file="${FLEX_HOME}/frameworks/rsls/advancedgrids_${SDK_VERSION}.swz" tofile="build/advancedgrids_${SDK_VERSION}.swz"/>
<copy file="${FLEX_HOME}/frameworks/rsls/rpc_${SDK_VERSION}.swz" tofile="build/rpc_${SDK_VERSION}.swz"/>

<!-- 拷贝flex文件,除开assets文件夹 -->
<copy todir="build" overwrite="true">
<fileset dir="/flex_src">
<include name="**/assets/**" />
</fileset>
</copy>

<!-- 编译css文件 -->
<mxmlc file="build/assets/css/darkStyle.css"
output="build/assets/css/darkStyle.swf" >
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${workshop.flex.src}"/>
<source-path path-element="build/assets/css"/>
<library-path file="${release.swc}/workshop_darkStyle.swc" append="true"/>
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
</mxmlc>

<!-- 拷贝webroot文件,除开lib文件夹 -->
<copy todir="build" overwrite="true">
<fileset dir="/WebRoot">
<exclude name="**/lib/**" />
</fileset>
</copy>

<delete dir="build/WEB-INF/classes"/>
<mkdir dir="build/WEB-INF/classes" />

<!-- 拷贝java文件 -->
<copy todir="build/WEB-INF/classes" overwrite="true">
<fileset dir="test/src1"></fileset>
<fileset dir="test/src2"></fileset>
</copy>

<!-- 拷贝base文件夹中的lib -->
<copy todir="build/WEB-INF/lib" overwrite="true">
<fileset dir="base_webapps/WEB-INF/lib">
<include name="*.jar" />
</fileset>
</copy>

<!-- 编译java文件 -->
<javac srcdir="build/WEB-INF/classes" destdir="build/WEB-INF/classes"
encoding="UTF-8" debug="true" includeantruntime="on">
<classpath refid="java.classpath"></classpath>
</javac>
<!-- 打成war包发布 -->
<war destfile="test.war" webxml="build/WEB-INF/web.xml">
<fileset dir="build">
<exclude name="**/*.java" />
</fileset>
</war>

<echo message="test.compile --> 发布 test 成功"/>
</target>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值