??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲国产精品成人AV秋霞,久久国产亚洲精品,色播久久人人爽人人爽人人片aVhttp://www.shnenglu.com/keigoliye/archive/2010/09/13/126511.html暗夜教父暗夜教父Mon, 13 Sep 2010 08:45:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/09/13/126511.htmlhttp://www.shnenglu.com/keigoliye/comments/126511.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/09/13/126511.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/126511.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/126511.html

在AX3+SP3中有一个工具Code ProfilerQ近来发现是非常好用的工P可以查代码运行的轨迹Q以及代码运行的旉Q对于跟t代码是非常有效的?/p>


C++代码度量工具-cccc
软g度量多个指标依赖于代码行l计Q如每千行代码发?/span>bug{,所以代码行是一个基数据。CCCC度量数据可结合测试风险完善测试计划?br>

CodeStatistics
一个小的命令行工具。我主要用它来做两g事情Q一者是代码l计功能Q另一者是删除I白行功能。在某此时候,我觉得对于整理代码和了解代码情况q是有一定的帮助作用的。明天我会将代码的行l束W格式加上的Q当Ӟq有分析代码元素Q如有多个函数Q多个c,也在我确定要d的功能之内。当Ӟ能整理代码就更棒了?br>

静态代码分析工具Cppcheck
Cppcheck是一Ƒּ?/span>c++静态代码分析工?/span>,在检源码时可根据规则就能挖掘出疑似~陷, 帮开源项目发现的bug?/span>:

http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Found_bugs

功能比较强大,使用很简?br>



 



暗夜教父 2010-09-13 16:45 发表评论
]]>
HTML5鲜(让canvas像flash一样工?从而制作复杂的动画)http://www.shnenglu.com/keigoliye/archive/2010/05/20/115870.html暗夜教父暗夜教父Thu, 20 May 2010 01:41:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/05/20/115870.htmlhttp://www.shnenglu.com/keigoliye/comments/115870.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/05/20/115870.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/115870.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/115870.html阅读全文

暗夜教父 2010-05-20 09:41 发表评论
]]>
E序堆栈http://www.shnenglu.com/keigoliye/archive/2010/05/17/115585.html暗夜教父暗夜教父Mon, 17 May 2010 06:53:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/05/17/115585.htmlhttp://www.shnenglu.com/keigoliye/comments/115585.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/05/17/115585.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/115585.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/115585.html
在计机领域Q堆栈是一个不容忽视的概念Q但是很多h甚至是计机专业的h也没有明堆栈其实是两种数据l构?nbsp;
堆栈都是一U数据项按序排列的数据结构,只能在一?UCؓ栈顶(top))Ҏ据项q行插入和删除?nbsp;
要点Q?nbsp;
堆:序随意 
栈:后进先出(Last-In/First-Out) 
~辑本段堆和栈的区别 
一、预备知识—程序的内存分配 
一个由c/C++~译的程序占用的内存分ؓ以下几个部分 
1、栈区(stackQ?q译器自动分配释放 Q存攑և数的参数|局部变量的值等。其操作方式cM于数据结构中的栈?nbsp;
2、堆区(heapQ??一般由E序员分配释放, 若程序员不释放,E序l束时可能由OS回收 。注意它与数据结构中的堆是两回事Q分配方式倒是cM于链表?nbsp;
3、全局区(静态区Q(staticQ—,全局变量和静态变量的存储是放在一块的Q初始化的全局变量和静态变量在一块区域, 未初始化的全局变量和未初始化的静态变量在盔R的另一块区域?- E序l束后由pȝ释放?nbsp;
4、文字常量区 —常量字W串是攑֜q里的?E序l束后由pȝ释放 ?nbsp;
5、程序代码区—存攑ևC的二q制代码?nbsp;
二、例子程?nbsp;
q是一个前辈写的,非常详细 
//main.cpp 
int a = 0; 全局初始化区 
char *p1; 全局未初始化?nbsp;
main() 

int b; ?nbsp;
char s[] = "abc"; ?nbsp;
char *p2; ?nbsp;
char *p3 = "123456"; 123456\0在常量区Qp3在栈上?nbsp;
static int c =0Q?全局Q静态)初始化区 
p1 = (char *)malloc(10); 
p2 = (char *)malloc(20); 

分配得来?0?0字节的区域就在堆区?nbsp;
strcpy(p1, "123456"); 123456\0攑֜帔R区,~译器可能会它与p3所指向?123456"优化成一个地斏V?nbsp;
~辑本段堆和栈的理论知识 
1.甌方式
stack: 
ql自动分配?例如Q声明在函数中一个局部变?int b; pȝ自动在栈中ؓb开辟空?nbsp;
heap: 
需要程序员自己甌Qƈ指明大小Q在c中malloc函数 
如p1 = (char *)malloc(10); 
在C++中用newq算W?nbsp;
如p2 = new char[20];//(char *)malloc(10); 
但是注意p1、p2本n是在栈中的?nbsp;
2.甌后系l的响应 
栈:只要栈的剩余I间大于所甌I间Q系l将为程序提供内存,否则报异常提示栈溢出?nbsp;
堆:首先应该知道操作pȝ有一个记录空闲内存地址的链表,当系l收到程序的甌Ӟ会遍历该链表Q寻扄一个空间大于所甌I间的堆l点Q然后将该结点从I闲l点链表中删除,q将该结点的I间分配l程序,另外Q对于大多数pȝQ会在这块内存空间中的首地址处记录本ơ分配的大小Q这P代码中的delete语句才能正确的释放本内存I间。另外,׃扑ֈ的堆l点的大不一定正好等于申L大小Q系l会自动的将多余的那部分重新攑օI闲链表中?nbsp;
3.甌大小的限?nbsp;
栈:在Windows?栈是向低地址扩展的数据结构,是一块连l的内存的区域。这句话的意思是栈顶的地址和栈的最大容量是pȝ预先规定好的Q在 WINDOWS下,栈的大小?MQ也有的说是1MQM是一个编译时q定的常数Q,如果甌的空间超q栈的剩余空间时Q将提示overflow。因此,能从栈获得的I间较小?nbsp;
堆:堆是向高地址扩展的数据结构,是不q箋的内存区域。这是由于系l是用链表来存储的空闲内存地址的,自然是不q箋的,而链表的遍历方向是由低地址向高地址。堆的大受限于计算机系l中有效的虚拟内存。由此可见,堆获得的I间比较灉|Q也比较大?nbsp;
4.甌效率的比?nbsp;
栈由pȝ自动分配Q速度较快。但E序员是无法控制的?nbsp;
堆是由new分配的内存,一般速度比较慢,而且Ҏ产生内存片,不过用v来最方便. 
另外Q在WINDOWS下,最好的方式是用VirtualAlloc分配内存Q他不是在堆Q也不是在栈,而是直接在进E的地址I间中保留一快内存,虽然用v来最不方ѝ但是速度快,也最灉| 
5.堆和栈中的存储内?nbsp;
栈: 在函数调用时Q第一个进栈的是主函数中函数调用后的下一条指令(函数调用语句的下一条可执行语句Q的地址Q然后是函数的各个参敎ͼ在大多数的C~译器中Q参数是由右往左入栈的Q然后是函数中的局部变量。注意静态变量是不入栈的?nbsp;
当本ơ函数调用结束后Q局部变量先出栈Q然后是参数Q最后栈指针指向最开始存的地址Q也是dC的下一条指令,E序p点l运行?nbsp;
堆:一般是在堆的头部用一个字节存攑֠的大。堆中的具体内容有程序员安排?nbsp;
6.存取效率的比?/div>
char s1[] = "aaaaaaaaaaaaaaa"; 
char *s2 = "bbbbbbbbbbbbbbbbb"; 
aaaaaaaaaaa是在q行时刻赋值的Q?nbsp;
而bbbbbbbbbbb是在~译时就定的; 
但是Q在以后的存取中Q在栈上的数l比指针所指向的字W串(例如?快?nbsp;
比如Q?nbsp;
#include 
void main() 

char a = 1; 
char c[] = "1234567890"; 
char *p ="1234567890"; 
a = c[1]; 
a = p[1]; 
return; 

对应的汇~代?nbsp;
10: a = c[1]; 
00401067 8A 4D F1 mov cl,byte ptr [ebp-0Fh] 
0040106A 88 4D FC mov byte ptr [ebp-4],cl 
11: a = p[1]; 
0040106D 8B 55 EC mov edx,dword ptr [ebp-14h] 
00401070 8A 42 01 mov al,byte ptr [edx+1] 
00401073 88 45 FC mov byte ptr [ebp-4],al 
W一U在d时直接就把字W串中的元素d寄存器cl中,而第二种则要先把指针D到edx中,在根据edxd字符Q显然慢了?nbsp;
7.结Q?nbsp;
堆和栈的区别可以用如下的比喻来看出: 
使用栈就象我们去饭馆里吃饭,只管点菜Q发出申P、付钱、和吃(使用Q,吃饱了就赎ͼ不必理会切菜、洗菜等准备工作和洗、刷锅等扫尾工作Q他的好处是快捷Q但是自由度?nbsp;
使用堆就象是自己动手做喜Ƣ吃的菜_比较ȝQ但是比较符合自q口味Q而且自由度大?nbsp;
~辑本段堆和栈的区别主要分: 
操作pȝ斚w的堆和栈Q如上面说的那些Q不多说了?nbsp;
q有是数据l构斚w的堆和栈Q这些都是不同的概念。这里的堆实际上指的是Q满_性质的)优先队列的一U数据结构,W?个元素有最高的优先权;栈实际上是满先进后出的性质的数学或数据l构?nbsp;
虽然堆栈Q堆栈的说法是连h叫,但是他们q是有很大区别的Q连着叫只是由于历史的原因?/div>
 
×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
接下来主要讲 symbian 中的应用
 不管是在堆栈q是堆,对象都有自己的生命期Q具体如下: 
  1、给对象分配内存Qd栈或者堆Q?nbsp;
  2、初始化Q也是l对象所在的内存赋?nbsp;
  3、用对?nbsp;
    4、清除:释放对象使用的各U资?nbsp;
  5、释攑֯象所占的内存QM堆栈或者堆Q?nbsp;
  对象的生存期是一个基概念。在某些操作pȝQ它是可以忽略的Q因为程序中止的时候,堆栈和堆都会被销毁。但是在Symbianq_Q程序往往需要能q行C月。这是Z么对象在生命期结束的时候就必须马上清除所有内存是那么重要的原因,不管它们分配在堆栈还是堆Q不它们生命期的结束是因ؓ正常处理q是因ؓ错误?nbsp;
Lifetimes in C ?nbsp;
Lifetimes in C++ ?nbsp;
Lifetimes in the Symbian platform


暗夜教父 2010-05-17 14:53 发表评论
]]>PHPUnit袖珍指南-W一??/title><link>http://www.shnenglu.com/keigoliye/archive/2010/04/13/112486.html</link><dc:creator>暗夜教父</dc:creator><author>暗夜教父</author><pubDate>Tue, 13 Apr 2010 11:30:00 GMT</pubDate><guid>http://www.shnenglu.com/keigoliye/archive/2010/04/13/112486.html</guid><wfw:comment>http://www.shnenglu.com/keigoliye/comments/112486.html</wfw:comment><comments>http://www.shnenglu.com/keigoliye/archive/2010/04/13/112486.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/keigoliye/comments/commentRss/112486.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/keigoliye/services/trackbacks/112486.html</trackback:ping><description><![CDATA[     摘要: 转自http://blog.csdn.net/summerfang/archive/2006/05/20/746219.aspx很长旉里,我对“你什么时候会为PHPUnit写一个文?#8221;q个问题的回{是Q?#8220;你不需要PHPUnit文档Q去读读JUnit文档或买一本Junit的书Q试一试用PHP和PHPUnit来重写Java和Junit的例?#8221;。当我和O...  <a href='http://www.shnenglu.com/keigoliye/archive/2010/04/13/112486.html'>阅读全文</a><img src ="http://www.shnenglu.com/keigoliye/aggbug/112486.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/keigoliye/" target="_blank">暗夜教父</a> 2010-04-13 19:30 <a href="http://www.shnenglu.com/keigoliye/archive/2010/04/13/112486.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHPUnit袖珍指南-概述http://www.shnenglu.com/keigoliye/archive/2010/04/13/112485.html暗夜教父暗夜教父Tue, 13 Apr 2010 11:27:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/04/13/112485.htmlhttp://www.shnenglu.com/keigoliye/comments/112485.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/04/13/112485.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/112485.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/112485.html

转自http://blog.csdn.net/summerfang/archive/2006/05/20/746216.aspx

聪明?/span>Web开发h员会告诉你,快扑ֈ代码的错误,你就能越快修正它Q长期而言Q项目成本越低。好了,能最有效的检?/span>PHP代码中的错误的工hPHPUnitQ一个开发源代码的框Ӟ它在你不在的时候,自动q行成套的单元测试。?/span>PHPUnit的好处是显而易见的Q?/span>

l         减少用于试代码的工作量

l         减少M软g~陷

l         增加对代码的信心

l         改善你和开发源代码的团队伙伴的关系

直到现在Q这个流行工具唯一的问题是~Z文档。ؓ了解册个问题,O’Reilly直接扑ֈ了源_PHPUnit口袋书指南的作者,也是PHPUnit的创造者,Sebastian BergmannQ来解决q个问题。这本书把很多难以记忆的信息Q语法,PHPUnit工作的原则,l一C赗它也带来了只有技术创造者才能提供的z察力和睿智忠告。而且Q本书也谈到了敏h法和极限~程中关于测试的内容?/span>

?/span>O’Reilly口袋书指南最q的pd中,q本快速参考书把所有的{案都带C你的指尖。那些对试PHP代码感兴的Web应用E序开发者,会觉得本书是一个无L伴G?/span>

 

--------------------------------------------------------------------------------------------------------------

原文Q?/span>

Overview

Smart web developers will tell you that the sooner you detect your code mistakes, the quicker you can fix them, and the less the project will cost in the long run. Well, the most efficient way to detect your mistakes in PHP is with PHPUnit, an open source framework that automates unit testing by running a battery of tests as you go. The benefits of PHPUnit are significant:

 

a reduction in the effort required to frequently test code

fewer overall defects

added confidence in your code

improved relations with your open source teammates

 

 

 

The only problem with this popular testing tool was its lack of documentation-until now, that is. For this, O'Reilly went right to the source, as Sebastian Bergmann, the author of PHPUnit Pocket Guide, also happens to be PHPUnit's creator. This little book brings together hard-to-remember information, syntax, and rules for working with PHPUnit. It also delivers the insight and sage advice that can only come from the technology's creator. Coverage of testing under agile methodologies and Extreme Programming (XP) is also included.

 

The latest in O'Reilly's series of handy Pocket Guides, this quick-reference book puts all the answers are right at your fingertips. It's an invaluable companion for anyone interested in testing the PHP code they write for web applications.



暗夜教父 2010-04-13 19:27 发表评论
]]>
使用Flex Ant Tasks~译工程文ghttp://www.shnenglu.com/keigoliye/archive/2010/04/12/112325.html暗夜教父暗夜教父Mon, 12 Apr 2010 07:08:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/04/12/112325.htmlhttp://www.shnenglu.com/keigoliye/comments/112325.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/04/12/112325.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/112325.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/112325.html阅读全文

暗夜教父 2010-04-12 15:08 发表评论
]]>
一l天下,使用ANT构徏VS.NET工程http://www.shnenglu.com/keigoliye/archive/2010/04/09/112079.html暗夜教父暗夜教父Fri, 09 Apr 2010 08:39:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112079.htmlhttp://www.shnenglu.com/keigoliye/comments/112079.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112079.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/112079.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/112079.html
对VS.NET工程q行自动构徏工作使用什么?也许大家会异口同声的说是NANT。嗯QNANT无疑是自动构建VS.NET工程最快捷的工P但对于一个拥有多个编E语a环境的项目,使用专用版的ANT工具却ƈ不是一个好的解x案,试想Q如果你的项目拥有多个由不同语言开发的模块Q那么你可能会同时用ANT、WANT、NANT来分别管理特定的模块?/div>
当然Q这不是我们想看到的Q同时维护三个构建工具实在不是什么明Z举(当然Q如果你喜欢Q那无可厚非了Q,其实ANT已经为我们通吃所有语a环境准备好了_օ良驹?/div>
ANT的exec标签是用来执行一个系l命令,q样我们可以用开发工L命o行编译方法来完成相应目的自动构建工作。下面我们只介绍VS.NET工程的命令行~译ҎQ?/div>
VS.NET开发工L命o行编译命令是devenvQ当然前提是VS.NET的IDE目录路径攄到PATH变量中。设|好PATH变量Q在控制C键入devenv /?Q我们可以看到VS.NET的各个参数说明,如下Q?/div>

Microsoft (R) 开发环?/span> 7.10.3077 版?/span>
版权所?/span>(C) Microsoft Corp 1984-2001。保留所有权利?/span>
 
用法:
devenv [solutionfile | projectfile | anyfile.ext] [switches]
 
可以调用 devenvQ用W一个参数指定解x案文件或目文g?/span>
也可以调?/span> devenvQɽW一个参C在编辑器中打开的Q?/span>
其他cd的文件。如果提供项目文ӞIDE 通过在与目文g
相同的目录中查找与项目文件具有相同基名称?/span> .sln 文gQ在
解决Ҏ的上下文中打开该项目文件。如果存?/span> .sln 文gQ则
IDE 查扑ּ用该目的单?/span> .sln 文g。如果不存在q样的单
?/span> .sln 文gQ则 IDE 创Z个具有默?/span> .sln 文g名的未保
存的解决ҎQ而该默认文g名与目文gh相同的基名称?/span>
 
命o行生?/span>:
devenv solutionfile.sln /build solutionconfig [ /project projectnameorfile [ /p
rojectconfig name ] ]
 
可用的命令行开?/span>:
 
/build          生成指定的解x案配|?/span>
/project        指定生成目而不是解x?/span>
                必须指定 /build 才能使用 /project
/projectconfig 指定要生成的目配置
                必须指定 /project 才能使用 /projectconfig
/out            生成结果写入指定的文g
/rebuild        ?/span> /build cMQ但先执行强制清?/span>
/clean          清理生成l果
/deploy         生成指定的解x案配|然后部|它
/run            q行指定的解x案配|?/span>
/runexit        q行指定的解x案配|然后终?/span>
/command        启动后执行指定的内部命o?/span>
/mditabs        使用选项卡式文档界面
/mdi            使用 MDI 界面
/fn             使用指定的字体名U?/span>
/fs             使用指定的字体大?/span>
/LCID           使用指定的语a ID
/noVSIP         用用于 VSIP 试?/span>VSIP 开发h员许可证密钥
/safemode       ZE_性仅加蝲默认的环境和服务
/resetskippkgs 允许曾被标记为加载失败的 VsPackages
                再次加蝲
/migratesettings q移另一个版本中的某些用戯|?/span>
 
产品特定的开?/span>:
 
/debugexe       打开要调试的指定可执行文件?/span>
                命o行的其余部分作ؓ它的参数
                传递到此执行文件?/span>
/useenv         使用 PATH?/span>INCLUDE?/span>LIBPATH ?/span> LIB 环境变量
                而不是?/span> VC++ 生成?/span> IDE 路径?/span>
 
若要从命令行附加调试器,请?/span>:
        vs7jit.exe -p <pid>

可见VS.NET工具为我们提供了诸多支持命o行编译的参数Q那接下来我们就开始动手配|Build.xml文g吧,Z节省幅Q我q里只给出compiled的代码:

1    <target name="compile" depends="init">
2        <mkdir dir="${pdcu}"/>
3        <echo message="Compiling application main source..."/>
4                 <delete file="${infofile}"/>        
5        <exec dir="${pdir}\" executable="devenv" os="${build.os}" >
6             <arg line=" ${pname}.sln
7                                   /rebuild
8                                   release     
9                                   /useenv
10                                 /out ${infofile}
11                                 "/>
12       </exec>
13     <echo message="Compiling application main source complete."/>
14 <loadfile property="compiled-info"
15            srcFile="${infofile}"/>
16        <echo message="${compiled-info}"/>       
17 <condition property="compile-success">
18      <and>
19       <contains string="${compiled-info}" substring="0 已失?/span>"/>
20      </and>
21    </condition>
22 <fail unless="compile-success"
23        message="${compiled-info}"/>
24    </target>

我们来详l分析一下上面的代码?/div>
W?行是d定义Q在此不q多解释?/div>
2Q?行是d定义和准备工作,主要是徏立编译生成目录和清理旧的输出文g?/div>
5Q?2行便是命令行~译的主要代码,我们来逐个解释?/div>
W?行定义了一个exec标签Q用来调用devenv命oQƈ指定了编译所在当前目录dir属性,和操作系l信息os属性?/div>
从第6行开始则为devenv命o的参数部分?/div>
其中W?行指定了要编译的解决Ҏ?/div>
W?行标明该解决Ҏ要进行重新编译?/div>
W?行指定了~译cd为release模式?/div>
W?行指定编译器使用 PATH、INCLUDE、LIBPATH ?LIB 环境变量?/div>
W?0行指定了~译信息输出的文件位|。由于devenv命o执行完毕后,ANT无法从命令行获取~译信息Q所以不能用exec的output属性来指定输出位置Q在调用Delphi~译器的时候,ANT可以正常获取~译信息Q因此output属性有效)Q只能用编译器所h的参数功能将信息输出Q该信息为判断编译成功与否的关键?/div>
14Q?5行读取了上述的编译信息文件的内容Q以便之后判断编译是否成功?/div>
17Q?1行则定义了一个编译结果,用于判断~译是否成功。结果用了contains属性来判断Q如果输出文件中包含字符?#8220;0 已失?#8221;Q则说明~译成功完成?/div>
22Q?3行则是指CZANTQ一旦编译失败,则打印出~译信息?/div>
当然Q这里只介绍了编译VS.NET工程的其中一U方法,在此抛砖引玉。既然ANT为我们提供了如此强大的系l命令执行功能,那么我们便可以在各种~程语言环境中游刃有余了?/div>

暗夜教父 2010-04-09 16:39 发表评论
]]>使用Antq行ssh和scp操作http://www.shnenglu.com/keigoliye/archive/2010/04/09/112076.html暗夜教父暗夜教父Fri, 09 Apr 2010 08:29:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112076.htmlhttp://www.shnenglu.com/keigoliye/comments/112076.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112076.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/112076.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/112076.html

一、简介:
  现在我们安装Linux的时候通常考虑到安全因素(默认情况下)是不打开telnet服务的,而ssh服务是有的,ant很早支持telnetQ但要求我们在Linux下要安装telnet-server,q要启用该服务?/p>

q好自Ant1.60开始支持了SSH 及SCP 操作了,早在Ant之前若要支持SSH、SCP、SFTP{Q务就必须下蝲j2ssh的j2ssh-ant.jar和j2ssh-core.jarQ在http://www.sourceforge.net的j2ssh下有下蝲Q。现在可以用Ant提供的Sshexec和scpdQ由$ANT_HOME/lib/ant-jsch.jar提供支持Q但是同样你也要?a style="text-decoration: underline; color: rgb(0, 68, 182); ">http://www.jcraft.com/jsch/index.html下蝲一个依赖包jsch-0.1.24.jar(文g名因版本而不?Qjsch同样也是http://www.sourceforge.net下的一个项目?/p>

你需要把下蝲的jsch-0.1.24拯?ANT_HOME/lib下,如果是Eclipse下的Ant环境必须在Window->Preferences->Ant->Runtime->Classpath中加入jsch-0.1.24?/p>

JSch是一个SSH2的纯Java实现
JSch允许你连接到sshd serverq用端口映, X11 映射; Scp文g传输{,你可以把集成JSch提供的功能到你自qJava目中,JSch 的授权方式ؓ BSD形式?/p>

二、简单例子:
  下面是用JSch完成Sshexec和scp两个d的最单例子,如果需要更详细的内容,请参考Ant用户手册

[Sshexecd]
<BR><target name="sshexec">
      <sshexec host="192.168.122.180" username="root"  password="123456"
         trust="true" command="cd /;ls"/>
</target>

注意上面的trust属性一般设|ؓtrue, 如果为默认值false?那么p求你所q接的host必须存在于你的knownhosts文g中,q且q个文g也必L存在的,否则会出?com.jcraft.jsch.JSchException: reject HostKey: 192.168.122.180异常。执行Linux下的命o时可以用分号";"把多个命令隔开Q它们将会依ơ执行,而不需要写多个sshexecq行多次q接Q每ơ连接只执行一个命令?/p>

该Q务的执行后输出结果如下:

sshexec:
  [sshexec] Connecting to 192.168.122.180:22
  [
sshexec] backup
  [
sshexec] bin
  [
sshexec] boot
  [
sshexec] dev
  [
sshexecetc
  ...................

[scpd]

1.拯单个文g到远端服务器
<scp file="c:/cmd.txt" todir="root:123456@192.168.122.180:/tmp" trust="true"/>
?/font>
<scp file="c:/cmd.txt" todir="root@192.168.122.180:/tmp" password="123456" trust="true"/>

2.拯q端文g本地
<scp file="root:123456@192.168.122.180:/tmp/cmd.txt" todir="D:/my-app"  trust="true"/>

3.拯q端目录到本圎ͼ以递归形式操作
<scp file="root:123456@192.168.122.180:/tmp/*" todir="d:/my-app" trust="true"/>

4.拯本地目录中的内容到远端,递归形式Q但不在服务器上建立my-app目录
<scp todir="root:123456@192.168.122.180:/tmp/" trust="true">
   
<fileset dir="d:/my-app"/>
</scp>

5.拯一pd的文件到q端Q会建立相应的层ơ目录,不徏立my-app目录
<scp todir="root:123456@192.168.122.180:/tmp" trust="true">
   
<fileset dir="d:/my-app">
      
<include name="**/*.java" />
   
</fileset>
</scp>
?br style="font: normal normal normal 12px/normal song, Verdana; "><scp todir="root:123456@192.168.122.180:/tmp" trust="true">
   
<fileset dir="d:/my-app" excludes="**/*.java"/>
</scp>

最后一个Q务的执行输出l果如下Q其他略Q:

scp:
      [scp]Connecting to 192.168.122.180:22
      [
scp] Sending: cmd.txt : 0
      [
scp] File transfer time: 0.0 Average Rate: ? B/s
      [
scp] Sending: pom.xml : 852
      [
scp] File transfer time: 0.0 Average Rate: ∞ B/s
      [
scp] Sending: application.properties : 142
      [
scp] File transfer time: 0.0 Average Rate: ∞ B/s
      [
scp] Sending: application.properties : 45
      [
scp] File transfer time: 0.0 Average Rate: ∞ B/s
      [
scp] Sending: test.properties : 0
      [
scp] File transfer time: 0.02 Average Rate: 0.0 B/s
      [
scp] Sending: application.properties : 153
      [
scp] File transfer time: 0.0 Average Rate: ∞ B/s
      [
scp] Sending: application.properties : 45
      [
scp] File transfer time: 0.0 Average Rate: ∞ B/s
      [
scp] done.

三、其他例子:

例子1Q?/strong>
<?xml   version= "1.0 "?> 
<project   name= "buildssh "   default= "DEFAULT "   basedir= ". "> 
<target   name= "init "> 
<!--   set   properties,   mkdir,   etc.   --> 
<property   file= "build.properties "   /> 
<property   name= "this.project "   value= "buildssh "   /> 
<echo   message= "init   in   ${this.project} "   /> 
<tstamp   /> 
</target> 

<target   name= "DEFAULT "   depends= "init "> 
<echo   message= "connecting   to   ${build.server} "   /> 
<sshexec   host= "Linux   server   IP   address "   username= "Linux   server     username "   password= "Linux   server   password "   trust= "true "   command= "Command   you   want   to   run   on   the   server "   /> 
</target> 
</project>

例子2Q?/strong>
import   com.jcraft.jsch.Channel;       
import   com.jcraft.jsch.ChannelSftp;       
import   com.jcraft.jsch.JSch;       
import   com.jcraft.jsch.Session;       
import   com.jcraft.jsch.UserInfo;       
    
public   class   ExecSCP   {       
        public   static   final   UserInfo   defaultUserInfo   =   new   UserInfo(){       
                public   String   getPassphrase()   {       
                        return   null;       
                }       
    
                public   String   getPassword()   {       
                        return   null;       
                }       
    
                public   boolean   promptPassword(String   arg0)   {       
                        return   false;       
                }       
    
                public   boolean   promptPassphrase(String   arg0)   {       
                        return   false;       
                }       
    
                public   boolean   promptYesNo(String   arg0)   {       
                        return   true;       
                }       
    
                public   void   showMessage(String   arg0)   {       
                }       
        };       
    
        /**     
          *   @param   args     
          */     
public   static   void   main(String[]   args)   throws   Exception{ 
String   hostname   =   "www.mozat.com "; 
String   username   =   "wiimii "; 
String   password   =   "jtev000 "; 
String   remoteFile   =   "Setup.ini "; 
String   localFile   =   "C:\\ "; 

                JSch   jsch=new   JSch(); 

                Session   session=jsch.getSession(username,   hostname,   990); 
                session.setPassword(password); 
                session.setUserInfo(defaultUserInfo); 
                session.connect(); 

                Channel   channel=session.openChannel( "sftp ");       
                channel.connect();       
                ChannelSftp   c=(ChannelSftp)channel;       
                      
                c.get(remoteFile,   localFile);   
                
                session.disconnect(); 
              } 



暗夜教父 2010-04-09 16:29 发表评论
]]>
linux服务器下用ant实现SVN代码更新Q部|?/title><link>http://www.shnenglu.com/keigoliye/archive/2010/04/09/112045.html</link><dc:creator>暗夜教父</dc:creator><author>暗夜教父</author><pubDate>Fri, 09 Apr 2010 03:23:00 GMT</pubDate><guid>http://www.shnenglu.com/keigoliye/archive/2010/04/09/112045.html</guid><wfw:comment>http://www.shnenglu.com/keigoliye/comments/112045.html</wfw:comment><comments>http://www.shnenglu.com/keigoliye/archive/2010/04/09/112045.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/keigoliye/comments/commentRss/112045.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/keigoliye/services/trackbacks/112045.html</trackback:ping><description><![CDATA[<span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">q段<span id="fvujkqu" class="hilite1" style="background-color: rgb(255, 255, 0); ">ant</span>脚本主要作用是:自动从SVN库拉最新的代码Q编译、ƈ自动部v到测试服务器?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "> </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">其中用到?#8220;antsvn” Q有3个jar包需要配|进?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: monospace; line-height: normal; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); "><?</span><span style="color: rgb(255, 0, 255); ">xml version="1.0" encoding="UTF-8"</span><span style="color: rgb(0, 0, 255); ">?></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); "> wei.songw 2008.3.19 </span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">project </span><span style="color: rgb(255, 0, 0); ">basedir</span><span style="color: rgb(0, 0, 255); ">="."</span><span style="color: rgb(255, 0, 0); "> name</span><span style="color: rgb(0, 0, 255); ">="smmail"</span><span style="color: rgb(255, 0, 0); "> default</span><span style="color: rgb(0, 0, 255); ">="auto"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); "> all properties are in build.properties </span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">property </span><span style="color: rgb(255, 0, 0); ">file</span><span style="color: rgb(0, 0, 255); ">="build.properties"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">svn本n需要的q行?</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">path </span><span style="color: rgb(255, 0, 0); ">id</span><span style="color: rgb(0, 0, 255); ">="svnant.lib"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">pathelement </span><span style="color: rgb(255, 0, 0); ">location</span><span style="color: rgb(0, 0, 255); ">="${svnjavahl.jar}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">pathelement </span><span style="color: rgb(255, 0, 0); ">location</span><span style="color: rgb(0, 0, 255); ">="${svnant.jar}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">pathelement </span><span style="color: rgb(255, 0, 0); ">location</span><span style="color: rgb(0, 0, 255); ">="${svnClientAdapter.jar}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">java EE 1.4 ?</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">path </span><span style="color: rgb(255, 0, 0); ">id</span><span style="color: rgb(0, 0, 255); ">="javaEE1.4"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">fileset </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${javaEE1.4.lib}"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">include </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="**/*.jar"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">fileset</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">目的classpath?</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">path </span><span style="color: rgb(255, 0, 0); ">id</span><span style="color: rgb(0, 0, 255); ">="project.classpath"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">pathelement </span><span style="color: rgb(255, 0, 0); ">location</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">fileset </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${lib.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">清理目d(q掉下蝲目录Qtomcat原来的部|文? </span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="clear"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">delete </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${work.space}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">delete </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${tomcat.home}/work/Catalina/localhost/${ant.project.name}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">delete </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${tomcat.home}/webapps/${ant.project.name}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">delete </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${tomcat.home}/webapps/${ant.project.name}.war"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); "> load the svn task </span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">taskdef </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="svn"</span><span style="color: rgb(255, 0, 0); "> classname</span><span style="color: rgb(0, 0, 255); ">="org.tigris.subversion.svnant.SvnTask"</span><span style="color: rgb(255, 0, 0); "> classpathref</span><span style="color: rgb(0, 0, 255); ">="svnant.lib"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">svn同步d</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="svn"</span><span style="color: rgb(255, 0, 0); "> depends</span><span style="color: rgb(0, 0, 255); ">="clear"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">mkdir </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${work.space}"</span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">svn </span><span style="color: rgb(255, 0, 0); ">username</span><span style="color: rgb(0, 0, 255); ">="SongWei"</span><span style="color: rgb(255, 0, 0); "> password</span><span style="color: rgb(0, 0, 255); ">="Song"</span><span style="color: rgb(255, 0, 0); "> javahl</span><span style="color: rgb(0, 0, 255); ">="false"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">checkout </span><span style="color: rgb(255, 0, 0); ">url</span><span style="color: rgb(0, 0, 255); ">="${urlRepos}"</span><span style="color: rgb(255, 0, 0); "> destPath</span><span style="color: rgb(0, 0, 255); ">="${work.space}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">svn</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">~译</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="compile"</span><span style="color: rgb(255, 0, 0); "> depends</span><span style="color: rgb(0, 0, 255); ">="svn"</span><span style="color: rgb(255, 0, 0); "> description</span><span style="color: rgb(0, 0, 255); ">="======compile project======"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">echo </span><span style="color: rgb(255, 0, 0); ">message</span><span style="color: rgb(0, 0, 255); ">="compile==========>${ant.project.name}: ${ant.file}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">mkdir </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">copy </span><span style="color: rgb(255, 0, 0); ">includeemptydirs</span><span style="color: rgb(0, 0, 255); ">="false"</span><span style="color: rgb(255, 0, 0); "> todir</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">fileset </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${java.source}"</span><span style="color: rgb(255, 0, 0); "> excludes</span><span style="color: rgb(0, 0, 255); ">="**/*.launch, **/*.java, config/*.*"</span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">copy</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">copy </span><span style="color: rgb(255, 0, 0); ">includeemptydirs</span><span style="color: rgb(0, 0, 255); ">="false"</span><span style="color: rgb(255, 0, 0); "> todir</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">fileset </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${java.config}"</span><span style="color: rgb(255, 0, 0); "> excludes</span><span style="color: rgb(0, 0, 255); ">="**/*.launch, **/*.java"</span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">copy</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">javac </span><span style="color: rgb(255, 0, 0); ">includejavaruntime</span><span style="color: rgb(0, 0, 255); ">="true"</span><span style="color: rgb(255, 0, 0); "> debug</span><span style="color: rgb(0, 0, 255); ">="true"</span><span style="color: rgb(255, 0, 0); "> debuglevel</span><span style="color: rgb(0, 0, 255); ">="${debuglevel}"</span><span style="color: rgb(255, 0, 0); "> destdir</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(255, 0, 0); "> source</span><span style="color: rgb(0, 0, 255); ">="${source}"</span><span style="color: rgb(255, 0, 0); "> target</span><span style="color: rgb(0, 0, 255); ">="${target}"</span><span style="color: rgb(255, 0, 0); "> encoding</span><span style="color: rgb(0, 0, 255); ">="utf-8"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">src </span><span style="color: rgb(255, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">="${java.source}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">exclude </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="config/"</span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">classpath</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">path </span><span style="color: rgb(255, 0, 0); ">refid</span><span style="color: rgb(0, 0, 255); ">="project.classpath"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">path </span><span style="color: rgb(255, 0, 0); ">refid</span><span style="color: rgb(0, 0, 255); ">="javaEE1.4"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">classpath</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">javac</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">javac </span><span style="color: rgb(255, 0, 0); ">debug</span><span style="color: rgb(0, 0, 255); ">="true"</span><span style="color: rgb(255, 0, 0); "> debuglevel</span><span style="color: rgb(0, 0, 255); ">="${debuglevel}"</span><span style="color: rgb(255, 0, 0); "> destdir</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(255, 0, 0); "> source</span><span style="color: rgb(0, 0, 255); ">="${source}"</span><span style="color: rgb(255, 0, 0); "> target</span><span style="color: rgb(0, 0, 255); ">="${target}"</span><span style="color: rgb(255, 0, 0); "> encoding</span><span style="color: rgb(0, 0, 255); ">="utf-8"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">src </span><span style="color: rgb(255, 0, 0); ">path</span><span style="color: rgb(0, 0, 255); ">="${java.config}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">javac</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">压羃Q打?/span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="war"</span><span style="color: rgb(255, 0, 0); "> depends</span><span style="color: rgb(0, 0, 255); ">="compile"</span><span style="color: rgb(255, 0, 0); "> description</span><span style="color: rgb(0, 0, 255); ">="======compress j2ee war file======"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">mkdir </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${dist.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">compress j2ee war file</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">war </span><span style="color: rgb(255, 0, 0); ">destfile</span><span style="color: rgb(0, 0, 255); ">="${war.file}"</span><span style="color: rgb(255, 0, 0); "> webxml</span><span style="color: rgb(0, 0, 255); ">="${web.dir}/WEB-INF/web.xml"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">fileset </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${web.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">classes </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${build.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">lib </span><span style="color: rgb(255, 0, 0); ">dir</span><span style="color: rgb(0, 0, 255); ">="${lib.dir}"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">war</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">shutdowntomcat</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="shutdowntomcat"</span><span style="color: rgb(255, 0, 0); "> description</span><span style="color: rgb(0, 0, 255); ">="========shutdowntomcat==========="</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">exec </span><span style="color: rgb(255, 0, 0); ">executable</span><span style="color: rgb(0, 0, 255); ">="${tomcat.home}/bin/shutdown.sh"</span><span style="color: rgb(255, 0, 0); "> failonerror</span><span style="color: rgb(0, 0, 255); ">="false"</span><span style="color: rgb(0, 0, 255); ">></</span><span style="color: rgb(128, 0, 0); ">exec</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">sleep </span><span style="color: rgb(255, 0, 0); ">seconds</span><span style="color: rgb(0, 0, 255); ">="10"</span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">startuptomcat</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="startuptomcat"</span><span style="color: rgb(255, 0, 0); "> description</span><span style="color: rgb(0, 0, 255); ">="========startuptomcat==========="</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">sleep </span><span style="color: rgb(255, 0, 0); ">seconds</span><span style="color: rgb(0, 0, 255); ">="5"</span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">exec </span><span style="color: rgb(255, 0, 0); ">executable</span><span style="color: rgb(0, 0, 255); ">="${tomcat.home}/bin/startup.sh"</span><span style="color: rgb(255, 0, 0); "> failonerror</span><span style="color: rgb(0, 0, 255); ">="false"</span><span style="color: rgb(0, 0, 255); ">></</span><span style="color: rgb(128, 0, 0); ">exec</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">部v到tomcat下面?/span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="deploy"</span><span style="color: rgb(255, 0, 0); "> depends</span><span style="color: rgb(0, 0, 255); ">="war"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">copy </span><span style="color: rgb(255, 0, 0); ">file</span><span style="color: rgb(0, 0, 255); ">="${war.file}"</span><span style="color: rgb(255, 0, 0); "> todir</span><span style="color: rgb(0, 0, 255); ">="${tomcat.home}/webapps"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 128, 0); "><!--</span><span style="color: rgb(0, 128, 0); ">全自动无敌部|Ԍ启动关闭tomcat</span><span style="color: rgb(0, 128, 0); ">--></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">target </span><span style="color: rgb(255, 0, 0); ">name</span><span style="color: rgb(0, 0, 255); ">="auto"</span><span style="color: rgb(255, 0, 0); "> depends</span><span style="color: rgb(0, 0, 255); ">="shutdowntomcat,deploy,startuptomcat"</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "><</span><span style="color: rgb(128, 0, 0); ">echo </span><span style="color: rgb(255, 0, 0); ">message</span><span style="color: rgb(0, 0, 255); ">="DONE!!!!"</span><span style="color: rgb(255, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">/></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">target</span><span style="color: rgb(0, 0, 255); ">></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); "></</span><span style="color: rgb(128, 0, 0); ">project</span><span style="color: rgb(0, 0, 255); ">></span></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: monospace; line-height: normal; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); "><br></span></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: monospace; line-height: normal; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); "><span style="color: rgb(0, 0, 0); font-family: Arial, sans-serif, Helvetica, Tahoma; white-space: normal; font-size: 12px; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">下面是build.xml指定的properties文gQ需要和build.xml攑֜同一个目录下?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">需要指?font color="#ff0000">work.space</font>Qsvn拉下来代码的存放Q已l编译,打包用的临时目录Q?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">tomcat.home</font><font size="3" color="#000000">Q?font size="1">tomcat服务器的根目?如果是其他服务器Q需要修改对应项</font>Q?/font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="3">===============================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">build.version=1.0.0</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">svnant.jar=/usr/java/svn/svnant.jar<br>svnClientAdapter.jar=/usr/java/svn/svnClientAdapter.jar<br>svnjavahl.jar=/usr/java/svn/svnjavahl.jar<br>javaEE1.4.lib=/usr/javaEE-1.4</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">debuglevel=source,lines<br>target=1.6<br>source=1.6</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">work.space=/home/gmail/workspace<br>dist.dir=${work.space}</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">build.dir=${work.space}/WebRoot/WEB-INF/classes<br>lib.dir=${work.space}/WebRoot/WEB-INF/lib</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">java.source=${work.space}/src<br>java.config=${work.space}/src/config</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">web.dir=${work.space}/WebRoot<br>resource.dir=${work.space}/resources</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">tomcat.home=/home/gmail/tomcat6<br>war.file=${dist.dir}/${<span id="eckqmwy" class="hilite1" style="background-color: rgb(255, 255, 0); ">ant</span>.project.name}.war</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font color="#ff0000">urlRepos=svn://192.168.1.100/product/SMMAIL/Develop</font></p></span></span></span></p></span> <img src ="http://www.shnenglu.com/keigoliye/aggbug/112045.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/keigoliye/" target="_blank">暗夜教父</a> 2010-04-09 11:23 <a href="http://www.shnenglu.com/keigoliye/archive/2010/04/09/112045.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Using SVN With Anthttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112044.html暗夜教父暗夜教父Fri, 09 Apr 2010 03:20:00 GMThttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112044.htmlhttp://www.shnenglu.com/keigoliye/comments/112044.htmlhttp://www.shnenglu.com/keigoliye/archive/2010/04/09/112044.html#Feedback0http://www.shnenglu.com/keigoliye/comments/commentRss/112044.htmlhttp://www.shnenglu.com/keigoliye/services/trackbacks/112044.html摘要Q?br>  Subversion是越来越被广泛用的版本理工具Q用Ant脚本从Subversion获取代码Q实现Daily Build?br>  1QSubversion概述
  先引?a rel="nofollow" class="bbs" target="_blank" style="color: rgb(0, 102, 204); text-decoration: none; font: normal normal normal 12px/normal 宋体; font-size: 14px; ">Version Control with Subversion 中开头的话:
  “If C gives you enough rope to hang yourself, think of Subversion as a sort of rope storage facility.” 
   —Brian W. Fitzpatrick
  然后告诉大家CVS是旧爱,Subversion是新Ƣ。列举若qSubversion的特性和优势Q懒得写了,直接看这里:Subversion的老家?br>  关于如何使用Subversion以及相关客户端YӞ|上慢慢看吧Q?a rel="nofollow" class="bbs" target="_blank" style="color: rgb(0, 102, 204); text-decoration: none; font: normal normal normal 12px/normal 宋体; font-size: 14px; ">官方自由图书不错?br>  2Q蚂蚁出?br>  团队最q的目中即使用Subversion作ؓ版本控制工具。Daily Buildq两天就得搭v来了Q上蚂蚁Q?br>  Tigris.org提供了SubclipseQSvnClientAdapter和SvnAnt??a rel="nofollow" class="bbs" target="_blank" style="color: rgb(0, 102, 204); text-decoration: none; font: normal normal normal 12px/normal 宋体; font-size: 14px; ">q里)
  Subclipse是一个Eclipse的插Ӟ实现了IDE与Subversion得集成;
  SvnClientAdapter是Subversion的一套Java APIQ封装了客户端对Subversion的一些访问操作;
  SvnAnt是用于访问Subversion的AntdQ其依赖于SvnClientAdapter?br>  我要用的是SvnAntQ用SVN Check Out一份SvnAnt的代码:
   
   
   
   
   svn co http://subclipse.tigris.org/svn/subclipse/trunk/svnant/ svnant
   
   
   
   
  在这个工E里面还包括svnant的Ant Task使用说明文档Q也可以?a rel="nofollow" class="bbs" target="_blank" style="color: rgb(0, 102, 204); text-decoration: none; font: normal normal normal 12px/normal 宋体; font-size: 14px; ">q里直接查看?br>  使用其中的build.xml~译SvnAnt后,在新生成的build子目录下会生成svnant.jar。按照官Ҏ档的说法Q把q个svnant.jar和SvnAnt工程的lib目录下的svnClientAdapter.jar和svnjavahl.jar拯到Ant的目录下卛_。然后编写如下的Ant脚本q行试Q?br>   
   
   
   
   <?xml version="1.0"?>
   <project name="SVN Ant Test" default="checkout" basedir=".">
   <!-- 1 -->
   <property name="remote.url"
   value="svn://16.157.xxx.xxx/trunk/LNPORTAL/src/P3UIPAdapter/" />
   <property name="local.dir" value="local" /> 
   <!-- 2 -->
   <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" />
   <target name="prepare"
   description="Prepare the dirs for other tasks">
   <delete dir="${local.dir}" />
   <mkdir dir="${local.dir}" />
   </target>
   <!-- 3-->
   <target name="checkout" depends="prepare">
   <svn javahl="true" username="lihq" password="password" >
   <checkout url="${remote.url}" destPath="${local.dir}" />
   </svn>
   </target>
   </project>
   
   
   
   
  试l果暂时不重要?br>  3QJavaSVN出场
  SvnAnt的执行依赖SvnClientAdapterQ而执行访问SVN时又有两UŞ式:其一是通过SVN 命o行程序的形式q行的(我在惻I如果是这Pq不如用Ant的execd呢)Q其二是通过Javahl来执行的?br>  Javahl是一个用于访问Subversion的Java接口Q估计是JNIQ,q需要WindowsZ有svnjavahl.dll才行。团队的Daily Build的ƈ不是WindowsQ于是求助JavaSVNQ这是一个纯Java的SVN解决Ҏ?br>  误问这个GuideQ?a rel="nofollow" class="bbs" target="_blank" style="color: rgb(0, 102, 204); text-decoration: none; font: normal normal normal 12px/normal 宋体; font-size: 14px; ">Making SvnAnt use JavaSVN
  我的实际步骤如下Q?br>  Step 1Q从Ant的lib目录下移除SvnClientAdapter.jarQ我没有发现javahl.jarQ于是便U除了svnjavahl.jarQ其实移不移后者无所谓;
  Step 2Q在刚才那个面下蝲javasvn.jar和javasvn-javahl.jarQ以及JavaSVN的svnClientAdapter-0.9.32.jar。ƈ把这三个jar都拷贝到Ant的lib目录下;
  然后q行上面写的SVN Ant试脚本Q结果如下:
   
   
   
   …
   BUILD FAILED
   java.lang.AbstractMethodError: org.tigris.subversion.svnant.Feedback.logRevision(J)V
   
   Total time: 7 seconds
   
   
   
  虽然SVN的代码都取下来了Q但最后Ant会抛Z个如上的错,q会使得Ant脚本无法q行后面的Q务?br>  4QThanks Open Source
  看来Q大概是JavaSVN用自qsvnClientAdapter-0.9.32.jar改变了SVNAnt本来对调用。SVNAntQby Tigris.orgQ原先是调用svnjavahl.jar来运行SVN命o的。替换svnClientAdapter-0.9.32.jar后,SVNAntQplus JavaSVNQ是调用javasvn-javahl.jar和javasvn.jar来运行SVN命o的。上面那个错误大概就是两套svnClientAdapterҎ个抽象方法的定义不完全一致造成的,估计是API版本对应的问题。解军_下:
  首先查看svnant.jar的源代码Q发现org.tigris.subversion.svnant.Feedback是实现svnClientAdapter.jar中的一个名为ISVNNotifyListener的接口。这个接口中Ҏ错的logRevisionҎ的定义是Q?br>   
   
   
   
   public abstract void logRevision(long revision, String path)
   
   
   
   
  而查看svnClientAdapter-0.9.32.jar中的ISVNNotifyListener的接口中的定义是Q?br>   
   
   
   
   public abstract void logRevision(long revision)
   
   
   
   
  明显不匹配,于是修改svnant.jar的源代码Q修改org.tigris.subversion.svnant.FeedbackQ象其中d一个方法如下:
   
   
   
   
   //This method is added by Beegee
   public void logRevision(long revision) {
   }
   
   //This method is the original one by SVNANT
   public void logRevision(long revision, String path) {
   }
   
   
   
   
  然后重新~译SVNAntQ生成svnant.jarQ拷贝替换Ant 的lib目录下的同名jarQ重新运行以上SVN Ant试脚本Q结果如下:
  

  OKQ?br>  QendQ?/span>

暗夜教父 2010-04-09 11:20 发表评论
]]>
þþþó˾Ʒ | ޾ƷþëƬ| 2021þþƷ| þþƷŮAV| þ99ֻоƷ66| þþƷþһ| 뾫Ʒþþɫ| ۺϾþþþ| þþƷ޸| aѹۿþav| Ʒþþþþù˽| þۺϾɫۺϾ99| ˾þó˳ۺ222| Ʒѿþþ| þþƷA㽶 | þ99Ļþ| þ99Ʒþþþþˮ| ٸŮþۺɫ| Ʒþۺ| þۺһ| ѾþҹƷ| ҹƷþþþþapp| 99þþþƷѹۿ| ɫۺϺϾþۿ| Ʒ޾þþþþ888| ޹Ʒ˾þ| Ʒһþ| ޾ƷŮþþþ99С˵| þøݾƷԴվ| þۺϾɫۺվ| ĻѾþ| ޾Ʒþ| þۺϾþԾ99ëƬ| ԭۺϾþô˾Ʒ| 츾þþ| þҹ³˿ƬҹƷ| þҹɫƷŷ| ˼˼þþƷ| þøƬ| 91Ʒպþò| þþŮ붯ȺëƬ|