首要条件:
1.先决条件:Ant 安装(安装ANT的前提是已经安装并配置好了JDK环境),并配置好。
CMD中输入命令ant –version 显示如下为配置好
2.ant本身需要svnant任务插件支持,才能在ant脚本中获取svn中的内容,svnant
是subclipse的组件之一,它的URL 是:http://subclipse.tigris.org/svnant.html
3.这里使用的是svnant-1.2.1 版本,使用前需要将它依赖的类库(网上说的3个或4个库是不对的,
4.实际应该是把svnant lib文件夹下的所有.JAR 复制到 ant的lib文件夹下)放在ant安装目录下面的lib目录
5.要想使用svnant中的任务访问svn的话,首先要定义新的task:
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpath="svnant.jar" />
window下面:
1.下载apache-ant-1.8.3-bin.tar.gz,解压缩到D:\Program Files\apache-ant-1.8.3
2.设置用户变量和系统变量
2.1系统变量:
新建系统
变量名:ANT
变量值:D:\Program Files\apache-ant-1.8.3
在Path后面添加 D:\Program Files\apache-ant-1.8.3\bin
C:\Program Files\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;% SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_10\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\MySQL\MySQL Server 5.0\bin;D:\Program Files\apache-ant- 1.8.3\bin;
2.1用户变量:
在PATH后面添加D:\Program Files\apache-ant-1.8.3\bin
C:\Program Files\SSH Communications Security\SSH Secure Shell;D:\Program Files\apache-ant-1.8.3\bin
3.解压svnant-1.3.1.zip,把里面lib下面所有.jar文件拷贝到D:\Program Files\apache-ant-1.8.3\lib下面.
4.下面两个配置:
build.properties
# change this to your Flex SDK directory path
FLEX_HOME=C:/Program Files/Adobe/Adobe Flash Builder 4.5/sdks/4.5.1
# this points to your project's src directory
# {$basedir} is a default variable that can be used in any Ant script
# and it points to the project's root folder [ Flex_Ant_Tasks ] in this case
SRC_DIR =D:/SVNSanguo/src
# points to the project's libs directory
LIBS_DIR =D:/SVNSanguo/libs
# this is the folder we want to publish the swf to
DEPLOY_DIR = D:/SVNSanguo/DEPLOY
# this is a config of module share objects
CONFIG_DIR = D:/SVNSanguo/Config
build.xml
<project name="Flex Ant Tasks Build Script" default="commit" basedir=".">
<!-- load previously defined configuration properties file -->
<property file="build.properties" />
<!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
<taskdef resource="flexTasks.tasks" classpath="C:/Program Files/Adobe/Adobe Flash Builder 4.5/sdks/4.5.1/ant/lib/flexTasks.jar"/>
<!-- svnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvn-->
<path id="svnant.classpath" >
<pathelement location="D:/Program Files/apache-ant-1.8.3/lib"/>
<fileset dir="D:/Program Files/apache-ant-1.8.3/lib">
<include name="svnant.jar"/>
<include name="svnClientAdapter.jar"/>
<include name="svnkit.jar"/>
<include name="svnjavahl.jar"/>
<include name="ganymed.jar"/>
<include name="jna.jar"/>
</fileset>
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />
<target name="prepare" description="Prepare the dirs for the task">
<delete dir="D:/SVNSanguo" />
<mkdir dir="D:/SVNSanguo" />
</target>
<!-- check out the scource from the svn -->
<target name="checkout" depends="prepare">
<svnSetting username="gandecheng" password="iudpc@9566" javahl="false" svnkit="true" id="svn.settings"/>
<echo>少年,请等待.....</echo>
<svn refid="svn.settings">
<checkout url="https://172.16.17.3/svn/qysg/dev/develop/frontend/SanGuoOnline" revision="HEAD" destPath="D:/SVNSanguo"/>
</svn>
</target>
<!--svnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvnsvn-->
<!-- delete and recreate the DEPLOY dir -->
<target name="init">
<delete dir="${DEPLOY_DIR}" />
<delete dir="${SRC_DIR}/generated" />
<delete dir="${CONFIG_DIR}" />
<mkdir dir="${DEPLOY_DIR}" />
<mkdir dir="${CONFIG_DIR}" />
</target>
<!-- 依赖性 当前的target为 compile flex project 其依赖于 任务init-->
<!-- Build and output the Main.swf-->
<target name="compile" depends="init">
<mxmlc file="${SRC_DIR}/GameMain.as" output="${DEPLOY_DIR}/GameMain.swf" fork="true" maxmemory="1024m">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${FLEX_HOME}/frameworks"/>
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<compiler.library-path dir="${LIBS_DIR}">
<include name="as3corelib.swc" />
<include name="Console.swc" />
<include name="airspark_rb.swc"/>
<include name="airframework_rb.swc"/>
<!--
<include name="advancedgrids_rb.swc" />
<include name="airframework_rb.swc" />
<include name="airspark_rb.swc" />
<include name="automation_a.swf" />
-->
</compiler.library-path>
<compiler.library-path dir="${FLEX_HOME}/frameworks/libs">
<include name="*.swc" />
</compiler.library-path>
</mxmlc>
</target>
<target name="commit" depends="compile">
</target>
</project>
linux下面:
1.解压/usr/soft/apache-ant-1.8.4-bin.tar.gz
使用linux命令:
cd /usr/soft
tar -zxvf apache-ant-1.8.0RC1-bin.tar.gz
rmp -qa|grep ant 查找linux机器上面的所有ant文件。
rmp -e --nodeps ant文件名字 删除以ant文集名字的ant。
2.配置ant环境变量
vi .bash_profile
在最后添加
export ANT_HOME=/usr/soft/apache-ant-1.8.4
export PATH=$PATH:$ANT_HOME/bin
vi /etc/profile
在最后添加
export PATH
export ANT_HOME=/usr/soft/apache-ant-1.8.4
export PATH=$PATH:$ANT_HOME/bin