在ant里使用tfs任务

对一个在tfs上的项目进行自动编译

使用teamprise的ant插件,详见

http://labs.teamprise.com/build/ant.html

  • 安装teamprise的ant插件

  下载teamprise-ant-1.2.zip

  解压,把teamprise-ant-1.2.jar拷贝到ant的lib目录,完成

  • 编写build.xml
<project name="test-teamprise-ant-tasks" basedir="e:/stsworkspace/code" default="deploy">
    <property name="ant.lib.dir" value="e:/program/ant-1.8.2/lib"/>
    <property name="tfs.server" value="http://tfsserver:8080/tfs" />
    <property name="tfs_workspace_name" value="GMARTINCN"/>
    <property name="tfs_project_name" value="$/PROJECT/CODE"/> 
    <typedef resource="com/teamprise/ant/antlib.xml" classpath="${ant.lib.dir}/teamprise-ant-1.2.jar" />
    <!-- 检查ant插件是否安装正确 -->
    <target name="diagnostics">
        <tfstasksdiagnostics />
    </target> 
    <target name="get" description="get the codes">
       <echo message="Get latest source code from tfs..."/>
        <!-- tfsget命令 指定本地路径 会从关联的服务器取代码  -->
        <tfsget localpath="${basedir}/src" force="false" />
        <tfsget localpath="${basedir}/WebRoot" force="false" />
    </target>
    <!-- 执行工程里的ant文件,完成编译布署 -->
    <target name="deploy" depends="get" description=" get the codes,compile,package and deploy the output file">
        <ant antfile="qk.xml"
              dir="${basedir}"
              inheritall="false"
              inheritrefs="false"
              target="war"
        />
    </target>
</project>

 tfs系统任务包括

TaskDescription
tfsRun a generic tfs command
tfsaddAdd files or folders to a workspace
tfscheckinCheck in pending changes
tfscheckoutCheck out files and folders so they can be edited
tfsdeleteDelete files or folders from a workspace
tfsgetGet files and folders from the server
tfshistoryObtain history information on a file or folder
tfslabelManage labels
tfsparsehistoryParse the output from tfshistory
tfstasksdiagnosticsPrint out diagnostic information and tests that the Teamprise TFS Ant tasks are correctly installed
tfsworkfoldManage working folder mappings for a workspace
tfsworkspaceManage workspaces on a TFS server

使用手册详见

http://download.teamprise.com/cs/3.3.1.11648R/docs/ant/manual.html

  • Javac 编译报非法字符 /65279

原因:UE或记事本编辑过的UTF-8的文件头会加入BOM标识,该标识由3char组成。在UTF8的标准里该BOM标识是可有可无的,Sun javac 在编译带有BOMUTF-8的格式的文件时会出现非法字符:/65279”的错误,但是用Eclipse进行编译却没有问题,原因在于Eclipse使用的是自己的JDT,而非javac

可使用eclipse的jdt编译器

步骤:

1.提取eclipse插件目录pluginjdtjar包,包名org.eclipse.jdt.core_3.x.x.v_....jar

eclipse3.7.2里的包是org.eclipse.jdt.core_3.7.2.v_B78_R37x.jar

解压jar包,提取里面的jdtCompilerAdapter.jar

2.把org.eclipse.jdt.core_3.7.2.v_B78_R37x.jar和jdtCompilerAdapter.jar拷到ant的lib目录

3.指定javac任务的compiler属性

 

<javac source="1.5" target="1.5" destdir="${bin.dir}" nowarn="on"  includeAntRuntime="false" compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
            <src path="${src.dir}"/>
            <classpath refid="appClassPath"/>
            <compilerarg line="-encoding GBK "/>
</javac>

 

ps:由于公司网络问题,如果使用ip地址,跨网段使用,取代码过一会会连接出错,换用服务器机器名,能正常获取代码,可能和防火墙有关。同网段没问题

 

 

 

 

 

转载于:https://www.cnblogs.com/cnblue/archive/2012/10/11/2458935.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值