批处理解决Ant自动下载CVS项目并打包

来源:互联网 发布:个体工商户域名备案 编辑:程序博客网 时间:2024/05/22 06:27

预装环境:CVS、Ant

实现功能:批处理传递项目名称进去,自动从 CVS server 获取工程并压缩。

主要代码:

@echo offif "%1"=="-h" goto helpif "%1"=="-p" if "%2" neq "" (set proname=%2goto useage) else (goto help):helpecho checkout project from cvsecho getProjectFromCVS [-p] [-h]echo -p specify the project name which you want to checkoutecho -h help doucumentgoto end:useageset tmpfile1=tmptmpbuild.propertiesset tmpfile2=tmptmpbuild.xmlrem generate prop fileecho cvs.user = build>>%tmpfile1%echo cvs.pass = temp4now>>%tmpfile1%echo cvs.repository = :pserver:${cvs.user}:${cvs.pass}@192.168.42.248:/var/cvs>>%tmpfile1%echo ci.root = ../CodeRepository>>%tmpfile1%echo check.outdir = ${ci.root}/CheckOut>>%tmpfile1%echo build.path = C:/Users/Cui/Desktop>>%tmpfile1%echo project.name = %proname%>>%tmpfile1%rem build xml file echo ^<?xml version="1.0"?^>>>%tmpfile2%echo ^<project name="AntCVS" basedir="." default="clean"^>>>%tmpfile2%echo ^<property file="%tmpfile1%" /^>>>%tmpfile2%echo ^<target name="init"^>>>%tmpfile2%echo ^<mkdir dir="${checkout.dir}" /^>>>%tmpfile2%echo ^<mkdir dir="${build.path}/${project.name}-build" /^>>>%tmpfile2%echo ^</target^>>>%tmpfile2%echo ^<target name="checkOut" depends="init" description="CheckOut sources "^>>>%tmpfile2%echo ^<cvs cvsRoot="${cvs.repository}" package="${project.name}" dest="${checkout.dir}" /^>>>%tmpfile2%echo ^</target^>>>%tmpfile2%echo ^<target name="build" depends="checkOut"^>>>%tmpfile2%echo ^<tstamp^>>>%tmpfile2%echo ^<format property="CurTime" pattern="yyyy-MM-dd-hh-mm" locale="us"/^>>>%tmpfile2%echo ^</tstamp^>>>%tmpfile2%echo ^<tar destfile="${build.path}/${project.name}-build/${project.name}-${CurTime}.tar.gz" basedir="${checkout.dir}"/^>>>%tmpfile2%echo ^</target^>>>%tmpfile2%echo ^<target name="clean" depends="build" description=""^>>>%tmpfile2%echo ^<delete dir="${checkout.dir}" /^>>>%tmpfile2%echo ^</target^>>>%tmpfile2%echo ^</project^>>>%tmpfile2%echo start checkout project %project.name% ...cmd /c ant -buildfile %tmpfile2%echo end checkout project ...echo delete temple file ...del /f %tmpfile1%del /f %tmpfile2%:endpause

黑体的部分可以自行更改。也可以把这些做成配置文件或者参数。Ant 可以直接获取 *.properties 的 “变量名字=变量值” 的 “键值对”。

运行方式:



0 0
原创粉丝点击