在ant里使用tfs任务
2012-10-11 10:12
218 查看
对一个在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
tfs系统任务包括
使用手册详见
http://download.teamprise.com/cs/3.3.1.11648R/docs/ant/manual.html
Javac 编译报非法字符 /65279
原因:用UE或记事本编辑过的UTF-8的文件头会加入BOM标识,该标识由3个char组成。在UTF-8的标准里该BOM标识是可有可无的,Sun 的javac 在编译带有BOM的UTF-8的格式的文件时会出现“非法字符:/65279”的错误,但是用Eclipse进行编译却没有问题,原因在于Eclipse使用的是自己的JDT,而非javac
可使用eclipse的jdt编译器
步骤:
1.提取eclipse插件目录plugin中jdt的jar包,包名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属性
ps:由于公司网络问题,如果使用ip地址,跨网段使用,取代码过一会会连接出错,换用服务器机器名,能正常获取代码,可能和防火墙有关。同网段没问题
使用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系统任务包括
Task | Description |
---|---|
tfs | Run a generic tfs command |
tfsadd | Add files or folders to a workspace |
tfscheckin | Check in pending changes |
tfscheckout | Check out files and folders so they can be edited |
tfsdelete | Delete files or folders from a workspace |
tfsget | Get files and folders from the server |
tfshistory | Obtain history information on a file or folder |
tfslabel | Manage labels |
tfsparsehistory | Parse the output from tfshistory |
tfstasksdiagnostics | Print out diagnostic information and tests that the Teamprise TFS Ant tasks are correctly installed |
tfsworkfold | Manage working folder mappings for a workspace |
tfsworkspace | Manage workspaces on a TFS server |
http://download.teamprise.com/cs/3.3.1.11648R/docs/ant/manual.html
Javac 编译报非法字符 /65279
原因:用UE或记事本编辑过的UTF-8的文件头会加入BOM标识,该标识由3个char组成。在UTF-8的标准里该BOM标识是可有可无的,Sun 的javac 在编译带有BOM的UTF-8的格式的文件时会出现“非法字符:/65279”的错误,但是用Eclipse进行编译却没有问题,原因在于Eclipse使用的是自己的JDT,而非javac
可使用eclipse的jdt编译器
步骤:
1.提取eclipse插件目录plugin中jdt的jar包,包名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地址,跨网段使用,取代码过一会会连接出错,换用服务器机器名,能正常获取代码,可能和防火墙有关。同网段没问题
相关文章推荐
- ANT基本使用(replace替换任务)
- 使用ant的jar任务打jar包
- Ant的使用 - 常用任务标签
- 利用ant的javac任务来编译程序使用ant的java任务来运行程序
- ant跟tfs的集成使用
- java 8 中使用Ant的 wsimport 任务
- Ant中java任务使用命令行传参数
- Ant中java任务使用命令行传参数
- 自动构建工具Ant深入剖析(四) 使用CVS及自定义任务
- 2、Ant目标详解及使用Ant的各种任务
- 使用ant的war任务打包j2ee web项目
- 使用自定义任务扩展Ant
- 自动构建工具Ant深入剖析(三) Ant目标深度详解、使用Ant的各种任务
- ant 的ftp任务使用,实现自动备份等,解决中文问题
- appfuse文档(二)---AppFuse的Ant任务
- 使用ANT打包Android应用
- 在Spring Boot中使用@Scheduled实现定时任务
- spring使用Quartz实现定时任务
- Activiti学习笔记9 — UserTask共有任务的使用
- 在Eclipse中使用tfs