ANT build.xml鏂囦欢璇﹁В锛堜竴锛�
Ant鐨勬蹇�
鍙兘鏈変簺璇昏�呭苟涓嶈繛鎺ヤ粈涔堟槸Ant浠ュ強鍏ュ彲浣跨敤瀹冿紝浣嗗彧瑕佷娇鐢ㄩ�氳繃Linux绯荤粺寰楄鑰咃紝搴旇鐭ラ亾
make杩欎釜鍛戒护銆傚綋缂栬瘧Linux鍐呮牳鍙婁竴浜涜蒋浠剁殑婧愮▼搴忔椂锛岀粡甯歌鐢ㄨ繖涓懡浠ゃ�侻ake鍛戒护鍏跺疄灏�
鏄竴涓」鐩鐞嗗伐鍏凤紝鑰孉nt鎵�瀹炵幇鍔熻兘涓庢绫讳技銆傚儚make锛実numake鍜宯make杩欎簺缂栬瘧宸ュ叿閮芥湁
涓�瀹氱殑缂洪櫡锛屼絾鏄疉nt鍗村厠鏈嶄簡杩欎簺宸ュ叿鐨勭己闄枫�傛渶鍒滱nt寮�鍙戣�呭湪寮�鍙戣法骞冲彴鐨勫簲鐢ㄦ椂锛岀敤鏍蜂篃
鏄熀浜庤繖浜涚己闄峰Ant鍋氫簡鏇村ソ鐨勮璁°��
Ant 涓� makefile
Makefile鏈変竴浜涗笉瓒充箣澶勶紝姣斿寰堝浜洪兘浼氱鍒扮殑鐑︿汉鐨凾ab闂銆傛渶鍒濈殑Ant寮�鍙戣�呭娆″己璋冣��
鍙槸鎴戝湪Tab鍓嶉潰鍔犱簡涓�涓┖鏍硷紝鎵�浠ユ垜鐨勫懡浠ゅ氨涓嶈兘鎵ц鈥濄�傛湁涓�浜涘伐鍏峰湪涓�瀹氱▼搴︿笂瑙e喅浜�
杩欎釜闂锛屼絾杩樻槸鏈夊緢澶氬叾浠栫殑闂銆侫nt鍒欎笌涓�鑸熀浜庡懡浠ょ殑宸ュ叿鏈夋墍涓嶅悓锛屽畠鏄疛ava绫荤殑鎵�
灞曘�侫nt杩愯闇�瑕佺殑XML鏍煎紡鐨勬枃浠朵笉鏄疭hell鍛戒护鏂囦欢銆傚畠鏄敱涓�涓狿roject缁勬垚鐨勶紝鑰屼竴涓�
Project鍙堝彲鍒嗘垚鍙target锛宼arget鍐嶇粏鍒嗗張鍒嗘垚寰堝task锛屾瘡涓�涓猼ask閮芥槸閫氳繃涓�涓疄鐜扮壒
瀹氭帴鍙g殑java绫绘潵瀹屾垚鐨勩��
Ant鐨勪紭鐐�
Ant鏄疉pache杞欢鍩洪噾浼欽AKARTA鐩綍涓殑涓�涓瓙椤圭洰锛屽畠鏈変互涓嬬殑浼樼偣銆�
璺ㄥ钩鍙版�с�侫nt鏄瓨Java璇█缂栧啓鐨勶紝鎵�绀哄叿鏈夊緢濂界殑璺ㄥ钩鍙版�с��
鎿嶄綔绠�鍗曘�侫nt鏄敱涓�涓唴缃换鍔″拰鍙�変换鍔$粍鎴愮殑銆侫nt杩愯鏃堕渶瑕佷竴涓猉ML鏂囦欢(鏋勫缓鏂囦欢)銆�
Ant閫氳繃璋冪敤target鏍戯紝灏卞彲浠ユ墽琛屽悇绉峵ask銆傛瘡涓猼ask瀹炵幇浜嗙壒瀹氭帴鍙e璞°�傜敱浜嶢nt鏋勫缓鏂囦欢
鏃禭ML鏍煎紡鐨勬枃浠讹紝鎵�浠ュ拰瀹规槗缁存姢鍜屼功鍐欙紝鑰屼笖缁撴瀯寰堟竻鏅般��
Ant鍙互闆嗘垚鍒板紑鍙戠幆澧冧腑銆傜敱浜嶢nt鐨勮法骞冲彴鎬у拰鎿嶄綔绠�鍗曠殑鐗圭偣锛屽畠寰堝鏄撻泦鎴愬埌涓�浜涘紑鍙戠幆
澧冧腑鍘汇��
Ant 寮�鍙�
Ant鐨勬瀯寤烘枃浠�
褰撳紑濮嬩竴涓柊鐨勯」鐩椂锛岄鍏堝簲璇ョ紪鍐橝nt鏋勫缓鏂囦欢銆傛瀯寤烘枃浠跺畾涔変簡鏋勫缓杩囩▼锛屽苟琚洟闃熷紑鍙�
涓瘡涓汉浣跨敤銆侫nt鏋勫缓鏂囦欢榛樿鍛藉悕涓篵uild.xml锛屼篃鍙互鍙栧叾浠栫殑鍚嶅瓧銆傚彧涓嶈繃鍦ㄨ繍琛岀殑鏃跺��
鎶婅繖涓懡鍚嶅綋浣滃弬鏁颁紶缁橝nt銆傛瀯寤烘枃浠跺彲浠ユ斁鍦ㄤ换浣曠殑浣嶇疆銆備竴鑸仛娉曟槸鏀惧湪椤圭洰椤跺眰鐩綍涓�
锛岃繖鏍峰彲浠ヤ繚鎸侀」鐩殑绠�娲佸拰娓呮櫚銆備笅闈㈡槸涓�涓吀鍨嬬殑椤圭洰灞傛缁撴瀯銆�
(1) src瀛樻斁鏂囦欢銆�
(2) class瀛樻斁缂栬瘧鍚庣殑鏂囦欢銆�
(3) lib瀛樻斁绗笁鏂笿AR鍖呫��
(4) dist瀛樻斁鎵撳寘锛屽彂甯冧互鍚庣殑浠g爜銆�
Ant鏋勫缓鏂囦欢鏄疿ML鏂囦欢銆傛瘡涓瀯寤烘枃浠跺畾涔変竴涓敮涓�鐨勯」鐩�(Project鍏冪礌)銆傛瘡涓」鐩笅鍙互瀹�
涔夊緢澶氱洰鏍�(target鍏冪礌)锛岃繖浜涚洰鏍囦箣闂村彲浠ユ湁渚濊禆鍏崇郴銆傚綋鎵ц杩欑被鐩爣鏃讹紝闇�瑕佹墽琛屼粬浠墍
渚濊禆鐨勭洰鏍囥��
姣忎釜鐩爣涓彲浠ュ畾涔夊涓换鍔★紝鐩爣涓繕瀹氫箟浜嗘墍瑕佹墽琛岀殑浠诲姟搴忓垪銆侫nt鍦ㄦ瀯寤虹洰鏍囨椂蹇呴』璋�
鐢ㄦ墍瀹氫箟鐨勪换鍔°�備换鍔″畾涔変簡Ant瀹為檯鎵ц鐨勫懡浠ゃ�侫nt涓殑浠诲姟鍙互涓�3绫汇��
锛�1锛� 鏍稿績浠诲姟銆傛牳蹇冧换鍔℃槸Ant鑷甫鐨勪换鍔°��
锛�2锛� 鍙�変换鍔°�傚彲閫変换鍔″疄鏉ヨ嚜绗笁鏂圭殑浠诲姟锛屽洜姝ら渶瑕佷竴涓檮鍔犵殑JAR鏂囦欢銆�
锛�3锛� 鐢ㄦ埛鑷畾涔夌殑浠诲姟銆傜敤鎴疯嚜瀹氫箟鐨勪换鍔″疄鐢ㄦ埛鑷繁寮�鍙戠殑浠诲姟銆�
1.鏍囩
姣忎釜鏋勫缓鏂囦欢瀵瑰簲涓�涓」鐩�傛爣绛炬椂鏋勫缓鏂囦欢鐨勬牴鏍囩銆傚畠鍙互鏈夊涓唴鍦ㄥ睘鎬э紝
灏卞浠g爜涓墍绀猴紝鍏跺悇涓睘鎬х殑鍚箟鍒嗗埆濡備笅銆�
(1) default琛ㄧず榛樿鐨勮繍琛岀洰鏍囷紝杩欎釜灞炴�ф槸蹇呴』鐨勩��
(2) basedir琛ㄧず椤圭洰鐨勫熀鍑嗙洰褰曘��
(3) name琛ㄧず椤圭洰鍚嶃��
(4) description琛ㄧず椤圭洰鐨勬弿杩般��
姣忎釜鏋勫缓鏂囦欢閮藉搴斾簬涓�涓」鐩紝浣嗘槸澶у瀷椤圭洰缁忓父鍖呭惈澶ч噺鐨勫瓙椤圭洰锛屾瘡涓�涓瓙椤圭洰閮藉彲浠ユ湁
鑷繁鐨勬瀯寤烘枃浠躲��
2.鏍囩
涓�涓」鐩爣绛句笅鍙互鏈変竴涓垨澶氫釜target鏍囩銆備竴涓猼arget鏍囩鍙互渚濊禆鍏朵粬鐨則arget鏍囩銆備緥
濡傦紝鏈変竴涓猼arget鐢ㄤ簬缂栬瘧绋嬪簭锛屽彟涓�涓猼arget鐢ㄤ簬澹扮О鍙墽琛屾枃浠躲�傚湪鐢熸垚鍙墽琛屾枃浠朵箣鍓嶅繀
椤诲厛缂栬瘧璇ユ枃浠讹紝鍥犵瓥鍙墽琛屾枃浠剁殑target渚濊禆浜庣紪璇戠▼搴忕殑target銆俆arget鐨勬墍鏈夊睘鎬у涓嬨��
(1).name琛ㄧず鏍囨槑锛岃繖涓睘鎬ф槸蹇呴』鐨勩��
(2).depends琛ㄧず渚濊禆鐨勭洰鏍囥��
(3)if琛ㄧず浠呭綋灞炴�ц缃椂鎵嶆墽琛屻��
(4)unless琛ㄧず褰撳睘鎬ф病鏈夎缃椂鎵嶆墽琛屻��
(5)description琛ㄧず椤圭洰鐨勬弿杩般��
Ant鐨刣epends灞炴�ф寚瀹氫簡target鐨勬墽琛岄『搴忋�侫nt浼氫緷鐓epends灞炴�т腑target鍑虹幇椤哄簭渚濇鎵ц
姣忎釜target銆傚湪鎵ц涔嬪墠锛岄鍏堥渶瑕佹墽琛屽畠鎵�渚濊禆鐨則arget銆傜▼搴忎腑鐨勫悕涓簉un鐨則arget鐨�
depends灞炴�ompile锛岃�屽悕涓篶ompile鐨則arget鐨刣epends灞炴�ф槸prepare锛屾墍浠ヨ繖鍑犱釜target鎵�
琛岀殑椤哄簭鏄痯repare->compile->run銆�
涓�涓猼arget鍙兘琚墽琛屼竴娆★紝鍗充娇鏈夊涓猼arget渚濊禆浜庡畠銆傚鏋滄病鏈塱f鎴杣nless灞炴�э紝target鎬�
浼氳鎵ц銆�
3.鏍囩
璇ユ爣绛剧敤浜庡垱寤轰竴涓洰褰曪紝瀹冩湁涓�涓睘鎬ir鐢ㄦ潵鎸囧畾鎵�鍒涘缓鐨勭洰褰曞悕锛屽叾浠g爜濡備笅锛�
閫氳繃浠ヤ笂浠g爜灏卞垱寤轰簡涓�涓洰褰曪紝杩欎釜鐩綍宸茬粡琚墠闈㈢殑property鏍囩鎵�鎸囧畾銆�
4鏍囩
璇ユ爣绛剧敤鏉ョ敓鎴愪竴涓狫AR鏂囦欢锛屽叾灞炴�у涓嬨��
(1) destfile琛ㄧずJAR鏂囦欢鍚嶃��
(2) basedir琛ㄧず琚綊妗g殑鏂囦欢鍚嶃��
(3) includes琛ㄧず鍒綊妗g殑鏂囦欢妯″紡銆�
(4) exchudes琛ㄧず琚帓闄ょ殑鏂囦欢妯″紡銆�
5锛�
璇ユ爣绛剧敤浜庣紪璇戜竴涓垨涓�缁刯ava鏂囦欢锛屽叾灞炴�у涓嬨��
(1).srcdir琛ㄧず婧愮▼搴忕殑鐩綍銆�
(2).destdir琛ㄧずclass鏂囦欢鐨勮緭鍑虹洰褰曘��
(3).include琛ㄧず琚紪璇戠殑鏂囦欢鐨勬ā寮忋��
(4).excludes琛ㄧず琚帓闄ょ殑鏂囦欢鐨勬ā寮忋��
(5).classpath琛ㄧず鎵�浣跨敤鐨勭被璺緞銆�
(6).debug琛ㄧず鍖呭惈鐨勮皟璇曚俊鎭��
(7).optimize琛ㄧず鏄惁浣跨敤浼樺寲銆�
(8).verbose 琛ㄧず鎻愪緵璇︾粏鐨勮緭鍑轰俊鎭��
(9).fileonerror琛ㄧず褰撶鍒伴敊璇氨鑷姩鍋滄銆�
6锛庢爣绛�
璇ユ爣绛剧敤鏉ユ墽琛岀紪璇戠敓鎴愮殑.class鏂囦欢锛屽叾灞炴�у涓嬨��
(1).classname 琛ㄧず灏嗘墽琛岀殑绫诲悕銆�
(2).jar琛ㄧず鍖呭惈璇ョ被鐨凧AR鏂囦欢鍚嶃��
(3).classpath鎵�琛ㄧず鐢ㄥ埌鐨勭被璺緞銆�
(4).fork琛ㄧず鍦ㄤ竴涓柊鐨勮櫄鎷熸満涓繍琛岃绫汇��
(5).failonerror琛ㄧず褰撳嚭鐜伴敊璇椂鑷姩鍋滄銆�
(6).output 琛ㄧず杈撳嚭鏂囦欢銆�
(7).append琛ㄧず杩藉姞鎴栬�呰鐩栭粯璁ゆ枃浠躲��
7.鏍囩
璇ユ爣绛剧敤浜庡垹闄や竴涓枃浠舵垨涓�缁勬枃浠讹紝鍘诲睘鎬у涓嬨��
(1)/file琛ㄧず瑕佸垹闄ょ殑鏂囦欢銆�
(2).dir琛ㄧず瑕佸垹闄ょ殑鐩綍銆�
(3).includeEmptyDirs 琛ㄧず鎸囧畾鏄惁瑕佸垹闄ょ┖鐩綍锛岄粯璁ゅ�兼槸鍒犻櫎銆�
(4).failonerror 琛ㄧず鎸囧畾褰撶鍒伴敊璇槸鍚﹀仠姝紝榛樿鍊兼槸鑷姩鍋滄銆�
(5).verbose琛ㄧず鎸囧畾鏄惁鍒楀嚭鎵�鍒犻櫎鐨勬枃浠讹紝榛樿鍊间负涓嶅垪鍑恒��
8.鏍囩
璇ユ爣绛剧敤浜庢枃浠舵垨鏂囦欢闆嗙殑鎷疯礉锛屽叾灞炴�у涓嬨��
(1).file 琛ㄧず婧愭枃浠躲��
(2).tofile 琛ㄧず鐩爣鏂囦欢銆�
(3).todir 琛ㄧず鐩爣鐩綍銆�
(4).overwrite 琛ㄧず鎸囧畾鏄惁瑕嗙洊鐩爣鏂囦欢锛岄粯璁ゅ�兼槸涓嶈鐩栥��
(5).includeEmptyDirs 琛ㄧず鍒跺畾鏄惁鎷疯礉绌虹洰褰曪紝榛樿鍊间负鎷疯礉銆�
(6).failonerror 琛ㄧず鎸囧畾濡傜洰鏍囨病鏈夊彂鐜版槸鍚﹁嚜鍔ㄥ仠姝紝榛樿鍊兼槸鍋滄銆�
(7).verbose 琛ㄧず鍒跺畾鏄惁鏄剧ず璇︾粏淇℃伅锛岄粯璁ゅ�间笉鏄剧ず銆�
Ant鐨勬暟鎹被鍨�
鍦ㄦ瀯寤烘枃浠朵腑涓轰簡鏍囪瘑鏂囦欢鎴栨枃浠剁粍锛岀粡甯搁渶瑕佷娇鐢ㄦ暟鎹被鍨嬨�傛暟鎹被鍨嬪寘鍚湪
org.apache.tool.ant.types鍖呬腑銆備笅闈㈤暅绠�鍗曚粙缁嶆瀯寤烘枃浠朵腑涓�浜涘父鐢ㄧ殑鏁版嵁绫诲瀷銆�
1. argument 绫诲瀷
鐢盇nt鏋勫缓鏂囦欢璋冪敤鐨勭▼搴忥紝鍙互閫氳繃鍏冪礌鍚戝叾浼犻�掑懡浠よ鍙傛暟锛屽apply,exec鍜宩ava浠�
鍔″潎鍙帴鍙楀祵濂楀厓绱狅紝鍙互涓哄悇鑷殑杩囩▼璋冪敤鎸囧畾鍙傛暟銆備互涓嬫槸鐨勬墍鏈夊睘鎬с��
(1).values 鏄竴涓懡浠ゅ弬鏁般�傚鏋滃弬鏁扮鏈夌┖鏍硷紝浣嗗張鎯冲皢瀹冧綔涓哄崟鐙竴涓�硷紝鍒欎娇鐢ㄦ灞炴��
銆�
(2).file琛ㄧず涓�涓弬鏁扮殑鏂囦欢鍚嶃�傚湪鏋勫缓鏂囦欢涓紝姝ゆ枃浠跺悕鐩稿浜庡綋鍓嶇殑宸ヤ綔鐩綍銆�
(3).line琛ㄧず鐢ㄧ┖鏍煎垎闅旂殑澶氫釜鍙傛暟鍒楄〃銆�
(4).path琛ㄧず璺緞銆�
2.ervironment 绫诲瀷
鐢盇nt鏋勫缓鏂囦欢璋冪敤鐨勫閮ㄥ懡浠ゆ垨绋嬪簭锛屽厓绱犲埗瀹氫簡鍝簺鐜鍙橀噺瑕佷紶閫掔粰姝e湪鎵ц鐨勭郴
缁熷懡浠わ紝鍏冪礌鍙互鎺ュ彈浠ヤ笅灞炴�с��
(1).file琛ㄧず鐜鍙橀噺鍊煎緱鏂囦欢鍚嶃�傛鏂囦欢鍚嶈琚浆鎹綅涓�涓粷瀵硅矾寰勩��
(2).path琛ㄧず鐜鍙橀噺鐨勮矾寰勩�侫nt浼氬皢瀹冭浆鎹负涓�涓湰鍦扮害瀹氥��
(3).value 琛ㄧず鐜鍙橀噺鐨勪竴涓洿鎺ュ彉閲忋��
(4).key 琛ㄧず鐜鍙橀噺鍚嶃��
娉ㄦ剰聽聽 file path 鎴� value鍙兘鍙栦竴涓��
3.filelist绫诲瀷
Filelist 鏄竴涓敮鎸佸懡鍚嶇殑鏂囦欢鍒楄〃鐨勬暟鎹被鍨嬶紝鍖呭惈鍦ㄤ竴涓猣ilelist绫诲瀷涓殑鏂囦欢涓嶄竴瀹氭槸
瀛樺湪鐨勬枃浠躲�備互涓嬫槸鍏舵墍鏈夌殑灞炴�с��
(1).dir鏄敤浜庤绠楃粷瀵规枃浠跺悕鐨勭洰褰曘��
(2).files 鏄敤閫楀彿鍒嗛殧鐨勬枃浠跺悕鍒楄〃銆�
(3).refid 鏄鏌愬瀹氫箟鐨勪竴涓殑寮曠敤銆�
娉ㄦ剰聽聽 dir 鍜� files 閮芥槸蹇呰鐨勶紝闄ら潪鎸囧畾浜唕efid(杩欑鎯呭喌涓嬶紝dir鍜宖iles閮戒笉鍏佽浣跨敤)銆�
4.fileset绫诲瀷
Fileset 鏁版嵁绫诲瀷瀹氫箟浜嗕竴缁勬枃浠讹紝骞堕�氬父琛ㄧず涓哄厓绱犮�備笉杩囷紝璁稿ant浠诲姟鏋勫缓鎴愪簡
闅愬紡鐨刦ileset,杩欒鏄庝粬浠敮鎸佹墍鏈夌殑fileset灞炴�у拰宓屽鍏冪礌銆備互涓嬩负fileset 鐨勫睘鎬у垪琛ㄣ��
(1).dir琛ㄧずfileset 鐨勫熀鐩綍銆�
(2).casesensitive鐨勫�煎鏋滀负false锛岄偅涔堝尮閰嶆枃浠跺悕鏃讹紝fileset涓嶆槸鍖哄垎澶у皬鍐欑殑锛屽叾榛樿
鍊间负true.
(3).defaultexcludes 鐢ㄦ潵纭畾鏄惁浣跨敤榛樿鐨勬帓闄ゆā寮忥紝榛樿涓簍rue銆�
(4).excludes 鏄敤閫楀彿鍒嗛殧鐨勯渶瑕佹淳鍑虹殑鏂囦欢妯″紡鍒楄〃銆�
(5).excludesfile 琛ㄧず姣忚鍖呭惈涓�涓帓闄ゆā寮忕殑鏂囦欢鐨勬枃浠跺悕銆�
(6).includes 鏄敤閫楀彿鍒嗛殧鐨勶紝闇�瑕佸寘鍚殑鏂囦欢妯″紡鍒楄〃銆�
(7).includesfile 琛ㄧず姣忚鍖呮嫭涓�涓寘鍚ā寮忕殑鏂囦欢鍚嶃��
5.patternset 绫诲瀷
Fileset 鏄鏂囦欢鐨勫垎缁勶紝鑰宲atternset鏄妯″紡鐨勫垎缁勶紝浠栦滑鏄揣瀵嗙浉鍏崇殑姒傚康銆�
鏀寔4涓睘鎬э細includes excludex includexfile 鍜� excludesfile,涓巉ileset鐩�
鍚屻�侾atternset 杩樺厑璁镐互涓嬪祵濂楀厓绱狅細include,exclude,includefile 鍜� excludesfile.
6.filterset 绫诲瀷
Filterset瀹氫箟浜嗕竴缁勮繃婊ゅ櫒锛岃繖浜涜繃婊ゅ櫒灏嗗湪鏂囦欢绉诲姩鎴栧鍒舵椂瀹屾垚鏂囦欢鐨勬枃鏈浛鎹€��
涓昏灞炴�у涓嬶細
(1).begintoken 琛ㄧず宓屽杩囨护鍣ㄦ墍鎼滅储鐨勮鍙凤紝杩欐槸鏍囪瘑鍏跺紑濮嬬殑瀛楃涓层��
(2).endtoken琛ㄧず宓屽杩囨护鍣ㄦ墍鎼滅储鐨勮鍙疯繖鏄爣璇嗗叾缁撴潫鐨勫瓧绗︿覆銆�
(3).id鏄繃婊ゅ櫒鐨勫敮涓�鏍囧織绗︺��
(4).refid鏄鏋勫缓鏂囦欢涓煇澶勫畾涔変竴涓繃婊ゅ櫒鐨勫紩鐢ㄣ��
7.Path绫诲瀷
Path鍏冪礌鐢ㄦ潵琛ㄧず涓�涓被璺緞锛屼笉杩囧畠杩樺彲浠ョ敤浜庤〃绀哄叾浠栫殑璺緞銆傚湪鐢ㄤ綔鎻栦釜灞炴�ф椂锛岃矾缁忎腑
鐨勫悇椤圭敤鍒嗗彿鎴栧啋鍙烽殧寮�銆傚湪鏋勫缓鐨勬椂鍊欙紝姝ゅ垎闅旂灏嗕唬鏇垮綋鍓嶅钩鍙颁腑鎵�鏈夌殑璺緞鍒嗛殧绗︼紝鍏舵嫢
鏈夌殑灞炴�у涓嬨��
(1).location 琛ㄧず涓�涓枃浠舵垨鐩綍銆侫nt鍦ㄥ唴閮ㄥ皢姝ゆ墿灞曚负涓�涓粷瀵硅矾寰勩��
(2).refid 鏄褰撳墠鏋勫缓鏂囦欢涓煇澶勫畾涔夌殑涓�涓猵ath鐨勫紩鐢ㄣ��
(3).path琛ㄧず涓�涓枃浠舵垨璺緞鍚嶅垪琛ㄣ��
8.mapper绫诲瀷
Mapper绫诲瀷瀹氫箟浜嗕竴缁勮緭鍏ユ枃浠跺拰涓�缁勮緭鍑烘枃浠堕棿鐨勫叧绯伙紝鍏跺睘鎬у涓嬨��
(1).classname 琛ㄧず瀹炵幇mapper绫荤殑绫诲悕銆傚綋鍐呯疆mapper涓嶆弧瓒宠姹傛椂锛岀敤浜庡垱寤哄畾鍒秏apper.
(2).classpath琛ㄧず鏌ユ壘涓�涓畾鍒秏apper鏃舵墍鐢ㄧ殑绫诲瀷璺緞銆�
(3).classpathref鏄鏌愬瀹氫箟鐨勪竴涓被璺緞鐨勫紩鐢ㄣ��
(4).from灞炴�х殑鍚箟鍙栧喅浜庢墍鐢ㄧ殑mapper.
(5).to灞炴�х殑鍚箟鍙栧喅浜庢墍鐢ㄧ殑mapper.
(6).type灞炴�х殑鍙栧�间负identity锛宖latten glob merge聽聽 regexp聽聽 鍏朵腑涔嬩竴锛屽畠瀹氫箟浜嗚鏄敤鐨�
鍐呯疆mapper鐨勭被鍨嬨��
Ant 鐨勮繍琛�
瀹夎濂紸nt骞朵笖閰嶇疆濂借矾寰勪箣鍚庯紝鍦ㄥ懡浠よ涓垏鎹㈠埌鏋勫缓鏂囦欢鐨勭洰褰曪紝杈撳叆Ant鍛戒护灏卞彲浠ヨ繍琛�
Ant.鑻ユ病鏈夋寚瀹氫换浣曞弬鏁帮紝Ant浼氬湪褰撳墠鐩綍涓嬫煡璇uild.xml鏂囦欢銆傚鏋滄壘鍒颁簡灏辩敤璇ユ枃浠朵綔涓�
鏋勫缓鏂囦欢銆傚鏋滀娇鐢ㄤ簡 鈥揻ind 閫夐」锛孉nt 灏变細鍦ㄤ笂绾х洰褰曚腑鎵炬瀯寤烘枃浠讹紝鐩磋嚦鍒拌揪鏂囦欢绯荤粺寰�
璺熺洰褰曘�傚鏋滄瀯寤烘枃浠剁殑鍚嶅瓧涓嶆槸build.xml 锛屽垯Ant杩愯鐨勬椂鍊欏氨鍙互浣跨敤 鈥揵uildfile file
,杩欓噷file 鎸囧畾浜嗚浣跨敤鐨勬瀯寤烘枃浠剁殑鍚嶇О锛岀ず渚嬪涓嬶細
Ant
濡備笅璇存槑浜嗚〃绀哄綋鍓嶇洰褰曠殑鏋勫缓鏂囦欢涓篵uild.xml 杩愯 ant 鎵ц榛樿鐨勭洰鏍囥��
Ant 鈥揵uildfile聽聽 test.xml
浣跨敤褰撳墠鐩綍涓嬬殑test.xml 鏂囦欢杩愯Ant ,鎵ц榛樿鐨勭洰鏍�
ant鐨刡uild.xml鏂囦欢璇﹁В锛堜簩锛�
浠uild_for_ejb_templet.xml涓虹ず渚嬶紝璁茶ВAnt涓父鐢ㄧ殑鍏冪礌鍜屼换鍔°��
绾﹀畾锛� "鈥�"琛ㄧず杩欓噷鏈夊緢澶氫唬鐮侊紝鏈垪鍑�
build_for_ejb_templet.xml浠诲姟鐨勫垎涓轰互涓嬪嚑澶ч儴鍒�
i. 寮�濮�
ii. 鍒濆鍖�
iii. 瀹氫箟classpath
iv. 涓虹紪璇戜綔鍑嗗
v. 缂栬瘧EJB閮ㄥ垎
vi. 缂栬瘧WEB閮ㄥ垎
vii. 缂栬瘧J2EE Application
viii. 閮ㄧ讲Application
ix. 鍒涘缓缁勪欢鐨凙PI
x. 纭畾build鐨勭洰鏍�
build_for_ejb_templet.xml鐨勮瑙�
寮�濮嬄�
璁茶В锛歟ncoding="UTF-8"琛ㄧずXML鏂囦欢閲囩敤UTF-8缂栫爜鏍煎紡锛屽鏋滆浣跨敤GBK缂栫爜锛岄渶瀹氫箟涓篹ncodeing="GBK"銆�
Build file for 'componentName'
Creation date : $Date: yyyy-m-d $
Updated date : $Date: yyyy-m-d $
Author:聽聽 developerName
Copyright 2002 CompanyName, Inc. All rights reserved.
-->
璁茶В锛氭閮ㄥ垎涓烘枃浠跺唴瀹圭殑绠�浠嬶紝鍖呮嫭鏂囦欢鍚嶇О銆佸垱寤烘棩鏈熴�佹渶鍚庝慨鏀规棩鏈熴�佸垱寤烘枃浠剁殑浣滆�呫�佺増鏉冦��
componentName 琛ㄧず 鏂囦欢鍚嶇О
yyyy-m-dd 琛ㄧず 鍒涘缓鏃ユ湡銆佹渶鍚庝慨鏀规棩鏈熺殑鏍煎紡锛屽2002-5-1
developerName 琛ㄧず 鍒涘缓鏂囦欢鐨勪綔鑰�
CompanyName 琛ㄧず 鍏徃鍚嶇О鎴朥RL
鈥�
璁茶В锛氭閮ㄥ垎瀹氫箟浜嗕竴涓悕绉颁负componentName鐨勯」鐩厓绱狅紝缂虹渷鐨勪换鍔′负"core"浠诲姟锛屾牴鐩綍涓哄綋鍓嶇洰褰曘�俢omponentName琛ㄧず缁勪欢鐨勫悕绉帮紝杩欓噷鎸嘐JB鐨勫悕绉般��
鍒濆鍖柭�
鈥�
璁茶В锛氭閮ㄥ垎鐢ㄤ簬鍒濆鍖栨墍鏈夌殑鍙橀噺
璁茶В锛氬鍏ラ」鐩牴鐩綍涓媌uild.properties涓殑鍏ㄥ眬鍙橀噺锛屽紑鍙戜汉鍛樹篃鍙互鍦ㄦ鏂囦欢涓噸鏂板畾涔夊叏灞�鍙橀噺銆�
鈥�
鈥�
璁茶В锛氬畾涔夊拰Jboss Application Server鏈夊叧鐨勫彉閲忥紝鍖呮嫭lib鐩綍銆乧lient鐩綍銆�
deploy鐩綍鍜孞2EE Application閮ㄧ讲瑕佺敤鍒扮殑涓�浜涘彉閲忋��
璁茶В锛氬畾涔夌粍浠剁殑鍚嶇О
璁茶В锛氬畾涔夋簮浠g爜鐩綍璺緞
璁茶В锛氬畾涔夎祫婧愮洰褰曡矾寰�
璁茶В锛氬畾涔夊簱鐩綍璺緞
璁茶В锛氬畾涔塨uild鐩綍璺緞
璁茶В锛氬畾涔夋簮浠g爜鐨勪富鐩綍璺緞
璁茶В锛氬畾涔夊瓨鏀綞JB鐨勬簮浠g爜鐩綍璺緞
璁茶В锛氬畾涔夊瓨鏀綣avaBean鐨勬簮浠g爜鐩綍璺緞
璁茶В锛氬畾涔夊瓨鏀維ervlet鐨勬簮浠g爜鐩綍璺緞
璁茶В锛氬畾涔夊瓨鏀網EB閮ㄥ垎鏂囦欢锛堝寘鎷琂SP绋嬪簭銆丠TML鏂囦欢銆佸浘鐗囥�丆SS鏂囦欢銆丣S鑴氭湰绛夛級鐨勭洰褰曡矾寰�
璁茶В锛氬畾涔夊瓨鏀剧粍浠禔PI鐨勫紑鍙戞枃浠剁洰褰曡矾寰�
璁茶В锛氬畾涔夊瓨鏀綞JB鐨勭紪璇戜唬鐮佺洰褰曡矾寰�
璁茶В锛氬畾涔夊瓨鏀綣avaBean鐨勭紪璇戜唬鐮佺洰褰曡矾寰�
璁茶В锛氬畾涔塛EB鐩綍鐨勭被鐩綍璺緞
璁茶В锛氬畾涔塛EB鐩綍鐨勫簱鐩綍鍚嶇О
璁茶В锛氬畾涔夊帇缂╂枃妗g殑鍚嶇О
璁茶В锛氬畾涔夐」鐩殑缁勪欢鐩綍璺緞
璁茶В锛氳繖娈典负娉ㄩ噴锛岃鏄庝互涓嬫槸瀹氫箟褰撳墠缁勪欢鐨勫彉閲�
璁茶В锛氬畾涔夊綋鍓嶇粍浠剁殑鍚嶇О
璁茶В锛氬畾涔夊綋鍓嶇粍浠剁殑鐩綍璺緞
value="${ProjectName.componentName.home}/lib/ejb"/>
璁茶В锛氬畾涔夊綋鍓嶇粍浠剁殑EJB缂栬瘧鐩綍璺緞
value="${ProjectName.componentName.home}/build/componentName-ejb.jar"/>
璁茶В锛氬畾涔夊綋鍓嶇粍浠跺唴鐨凟JB鍖呯殑璺緞
value="${ProjectName.componentName.home}/build/componentName-ejb-client.jar"/>
璁茶В锛氬畾涔夊綋鍓嶇粍浠跺唴鐨凟JB瀹㈡埛绔寘鐨勮矾寰�
璁茶В锛氳繖娈典负娉ㄩ噴锛岃鏄庝互涓嬫槸瀹氫箟寮曞叆鍏跺畠缁勪欢鐨勫彉閲�
value="referencesComponentName"/>
璁茶В锛氬畾涔夋寚瀹氱粍浠剁殑鍚嶇О
value="${ProjectName.components.home}/referencesComponentName"/>
璁茶В锛氬畾涔夋寚瀹氱粍浠剁殑鐩綍璺緞
value="${ProjectName.referencesComponentName.home}/lib/ejb"/>
璁茶В锛氬畾涔夋寚瀹氱粍浠剁殑EJB缂栬瘧鐩綍璺緞
value="${ProjectName.referencesComponentName.home}
/build/referencesComponentName-ejb.jar"/>
璁茶В锛氬畾涔夋寚瀹氱粍浠跺唴鐨凟JB鍖呯殑璺緞
value="${ProjectName.referencesComponentName.home}
/build/referencesComponentName-ejb-client.jar"/>
璁茶В锛氬畾涔夋寚瀹氱粍浠跺唴鐨凟JB瀹㈡埛绔寘鐨勮矾寰�
value="${jboss.client}/jboss-j2ee.jar:${jboss.client}
/jnp-client.jar:${jboss.client}/jnp-client.jar:${jboss.client}
/jbossmq-client.jar:${jboss.client}/jbosssx-client.jar:${jboss.client}
/concurrent.jar:${jboss.client}/jaas.jar:${jboss.lib}
/jboss-jmx.jar:${jboss.home}/server/${jboss.configuration}
/lib/jbosssx.jar:${jboss.home}/server/${jboss.configuration}
/lib/mail.jar:${servlet-lib.path}:${ejb-classes.dest}:
${web-classes.dest}:${ProjectName.componentName.classbindir}:
${ProjectName.componentName.ejbjar.client}:
${ProjectName.referencesComponentName.classbindir}:
${ProjectName.referencesComponentName.ejbjar.client}" />
璁茶В锛氬畾涔塩lasspath锛岀紪璇慴ean鏃惰鐢ㄥ埌銆傝繖鏄畾涔塩lasspath鐨勪竴绉嶆柟娉曪紝涓嬮潰杩樻湁鍙︿竴绉嶆柟娉曘��
瀹氫箟classpath聽
location="${jboss.home}/server/${jboss.configuration}/lib/jbosssx.jar" />
location="${jboss.home}/server/${jboss.configuration}/lib/mail.jar" />
璁茶В锛氭娈靛畾涔夊簲鐢ㄦ湇鍔″櫒涓寘鏂囦欢锛屽鏀寔ejb鐨刯boss-j2ee.jar銆佹敮鎸佸鎴风绋嬪簭鐨刯np-client.jar銆乯bossmq-client.jar銆乯bosssx-client.jar銆佹敮鎸丣avaMail鐨刴ail.jar绛夈��
location="${ProjectName.referencesComponentName.classbindir}"/>
璁茶В锛氭娈靛畾涔夐」鐩腑瑕佺敤鍒扮殑鍖呮枃浠躲��
璁茶В锛氭娈靛畾涔夊湪缂栬瘧servlet鏃剁殑classpath锛�${ servlet-lib.path }鏄郴缁熸寚瀹氱殑Servlet寮曟搸鍖呫��
涓虹紪璇戜綔鍑嗗宸ヤ綔
璁茶В锛氭竻闄uild銆乴ib鐩綍涓嬬殑鎵�鏈夋枃浠跺拰鐩綍銆�
璁茶В锛氬垱寤篵uild涓鐢ㄥ埌鐨勬墍鏈夌洰褰曪紝鏍规嵁闇�瑕佸彲浠ュ姞鍏ヨ嚜瀹氫箟鐨勭洰褰曞锛�
缂栬瘧EJB閮ㄥ垎
destdir="${ejb-classes.dest}"
includes="com/**"
classpathref="base.path" />
璁茶В锛氭灏忔鐢ㄦ潵瀹屾垚缂栬瘧ejb鍜屽叾瀹僪elp classes銆傛牴鎹渶瑕佸彲浠ュ姞鍏ヤ竴涓潪甯告湁鐢ㄧ殑鍏冪礌锛�
encoding="${javac.encoding}"
tofile="${lib.dir}/ejb/META-INF/ejb-jar.xml" />
tofile="${lib.dir}/ejb/META-INF/jaws.xml" />
tofile="${lib.dir}/ejb/META-INF/jboss.xml" />
tofile="${lib.dir}/ejb/META-INF/jbosscmp-jdbc.xml" />
璁茶В锛氭灏忔鐢ㄦ潵鎷疯礉EJB閮ㄧ讲鏂囦欢锛屽湪JAS涓璄JB閮ㄧ讲鏂囦欢鏈塲aws.xml銆乯boss.xml銆乯bosscmp-jdbc.xml銆�
basedir="${lib.dir}/ejb" />
璁茶В锛氭灏忔鐢ㄦ潵鎶奵lass鍜岄儴缃叉枃浠跺帇缂╂垚鍖呮枃浠讹紝杩欎釜鍖呮枃浠跺氨鏄竴涓狤JB缁勪欢銆�
file="${ProjectName.referencesComponentName.home}/build/
${ProjectName.referencesComponentName.name}-ejb-client.jar"
tofile="${build.dir}/${ProjectName.referencesComponentName.name}
-ejb-client.jar" />
basedir="${lib.dir}/ejb"
excludes="com/ProjectName/componentName/ejb/ComponentNameEJB.class" />
璁茶В锛氭灏忔鐢ㄦ潵鎶奵lass鍜岄儴缃叉枃浠跺帇缂╂垚鍖呮枃浠讹紝浠ユ敮鎸佸鎴风杩愯銆�
缂栬瘧WEB閮ㄥ垎
destdir="${lib.dir}/web/WEB-INF/classes"
includes="com/**"
classpath="${build.classpath}" />
璁茶В锛氭灏忔鐢ㄦ潵瀹屾垚缂栬瘧servlet銆�
tofile="${lib.dir}/web/WEB-INF/jboss-web.xml" />
tofile="${lib.dir}/web/WEB-INF/web.xml" />
璁茶В锛氭灏忔鐢ㄦ潵鎷疯礉WEB閮ㄧ讲鏂囦欢锛屽湪JAS涓璚EB閮ㄧ讲鏂囦欢鏈塲boss-web.xml銆�
file="${build.dir}/${ProjectName.referencesComponentName.name}-ejb-client.jar"
tofile="${lib.dir}/web/WEB-INF/lib/${ProjectName.referencesComponentName.name}
-ejb-client.jar" />
basedir="${lib.dir}/web" />
璁茶В锛氭灏忔鐢ㄦ潵鎶婃墍鏈夌殑JSP绋嬪簭銆丠tml銆丆ss銆佸浘鐗囧拰閮ㄧ讲鏂囦欢绛夊帇缂╂垚WAR鏂囦欢銆�
缂栬瘧J2EE Application
tofile="${lib.dir}/j2ee/META-INF/application.xml" />
璁茶В锛氭灏忔鐢ㄦ潵鎷疯礉Application鐨勯儴缃叉枃浠躲��
tofile="${lib.dir}/j2ee/${name}-ejb.jar" />
tofile="${lib.dir}/j2ee/${name}-web.war" />
basedir="${lib.dir}/j2ee" />
璁茶В锛氭灏忔鐢ㄦ潵鎶奅JB缁勪欢銆佹敮鎸佸鎴风杩愯鐨勫寘鍜岄儴缃叉枃浠跺帇缂╂垚EAR鏂囦欢锛屽畠灏辨槸涓�涓狫2EE Application銆傝繖閲岃璇存槑锛屽湪杩涜build鏃讹紝鏍规嵁闇�瑕佸彲浠ヤ笉鐢熸垚EAR鏂囦欢銆�
閮ㄧ讲Application
璁茶В锛氭灏忔鐢ㄦ潵閮ㄧ讲Application锛屽湪JAS3.0涓�${jboss.deploy}鏄疛AS鐨勭儹閮ㄧ讲鐩綍銆�
鍒涘缓缁勪欢鐨凙PI
destdir="${javadoc.dir}"
classpath="${build.classpath}"
encoding="${javadoc.encoding}"
author="${javadoc.author}"
version="${javadoc.version}"
use="${javadoc.usage}"
windowtitle="${project.name} ${name} Component API"
doctitle="${project.name} ${name} Component"
bottom="Copyright ${sign.copyright} ${project.date}
${company.signature}. All Rights Reserved.">
璁茶В锛氭灏忔鐢ㄦ潵鍒涘缓缁勪欢鐨凙PI銆傝繖閲屽己鐑堣姹傜被璁捐浜哄憳鍜岀紪鐮佷汉鍛樻寜鐓avadoc瀹氫箟鐨勬爣绛惧婧愪唬鐮佽繘琛屾敞閲娿��
纭畾build鐨勭洰鏍�
+---------------------------------------+
+聽聽聽聽 Building ${name} Component聽聽聽聽聽聽聽聽 +
+---------------------------------------+
+---------------------------------------+
+聽聽聽聽 Finished ${name} Component聽聽聽聽聽聽聽聽 +
+---------------------------------------+
ejbclientjar,war" />
ejbclientjar,war,ear,deploy-server" />
璁茶В锛氭灏忔鐢ㄦ潵纭畾build鐨勭洰鏍囥�傜己鐪佺洰褰曚负core锛屾墍浠ュ湪build涓嶅姞鍙傛暟鏃讹紝绯荤粺灏嗗彧鐢熸垚jar鏂囦欢鍜寃ar鏂囦欢銆傚鏋� build鏃跺姞涓婂弬鏁帮紝绯荤粺灏嗘牴鎹渶瑕佹潵鐢熸垚鏂囦欢锛屼緥濡傦細鍦ㄥ懡浠よ杈撳叆ant deploy锛岀郴缁熷皢鐢熸垚jar鏂囦欢銆亀ar鏂囦欢銆乪ar鏂囦欢锛屽悓鏃跺皢ear鏂囦欢杩涜閮ㄧ讲銆�
ant build.xml 璇﹁В(涓�)
鍦‥clipse涓娇鐢ˋnt Ant鏄疛ava骞冲彴涓嬮潪甯告鐨勬壒澶勭悊鍛戒护鎵ц绋嬪簭锛岃兘闈炲父鏂逛究鍦拌嚜鍔ㄥ畬鎴愮紪璇戯紝娴嬭瘯锛屾墦鍖咃紝閮ㄧ讲绛夌瓑涓�绯诲垪浠诲姟锛屽ぇ澶ф彁楂樺紑鍙戞晥鐜囥�傚鏋滀綘鐜板湪杩樻病鏈夊紑濮嬩娇鐢ˋnt锛岄偅灏辫璧跺揩寮�濮嬪涔犱娇鐢紝浣胯嚜宸辩殑寮�鍙戞按骞充笂涓�涓柊鍙伴樁銆偮�
Eclipse涓凡缁忛泦鎴愪簡Ant锛屾垜浠彲浠ョ洿鎺ュ湪Eclipse涓繍琛孉nt銆偮�
浠ュ墠闈㈠缓绔嬬殑Hello宸ョ▼涓轰緥锛屽垱寤轰互涓嬬洰褰曠粨鏋勶細聽
鏂板缓涓�涓猙uild.xml锛屾斁鍦ㄥ伐绋嬫牴鐩綍涓嬨�俠uild.xml瀹氫箟浜咥nt瑕佹墽琛岀殑鎵瑰鐞嗗懡浠ゃ�傝櫧鐒禔nt涔熷彲浠ヤ娇鐢ㄥ叾瀹冩枃浠跺悕锛屼絾鏄伒寰爣鍑嗚兘鏇翠娇寮�鍙戞洿瑙勮寖锛屽悓鏃舵槗浜庝笌鍒汉浜ゆ祦銆偮�
閫氬父锛宻rc瀛樻斁Java婧愭枃浠讹紝classes瀛樻斁缂栬瘧鍚庣殑class鏂囦欢锛宭ib瀛樻斁缂栬瘧鍜岃繍琛岀敤鍒扮殑鎵�鏈塲ar鏂囦欢锛寃eb瀛樻斁JSP绛墂eb鏂囦欢锛宒ist瀛樻斁鎵撳寘鍚庣殑jar鏂囦欢锛宒oc瀛樻斁API鏂囨。銆偮�
鐒跺悗鍦ㄦ牴鐩綍涓嬪垱寤篵uild.xml鏂囦欢锛岃緭鍏ヤ互涓嬪唴瀹癸細聽
Xml浠g爜 聽
聽
聽
聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽haltonfailure="false" 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽failureproperty="tests.failed" 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽showoutput="true"> 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽*********************************************************** 聽聽
聽 聽 聽 聽 聽**** 聽 One or more tests failed! 聽 Check the output ... 聽 **** 聽聽
聽 聽 聽 聽 聽*********************************************************** 聽聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽
聽 聽 聽 聽 聽 聽 聽author="true" 聽
聽 聽 聽 聽 聽 聽 聽version="true" 聽
聽 聽 聽 聽 聽 聽 聽use="true" 聽
聽 聽 聽 聽 聽 聽 聽windowtitle="Test API"> 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽Hello, test]]> 聽
聽 聽 聽 聽 聽 聽 聽All Rights Reserved.]]> 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽
聽
浠ヤ笂xml渚濇瀹氫箟浜唅nit锛堝垵濮嬪寲锛夛紝compile锛堢紪璇戯級锛宼est锛堟祴璇曪級锛宒oc锛堢敓鎴愭枃妗o級锛宲ack锛堟墦鍖咃級浠诲姟锛屽彲浠ヤ綔涓烘ā鏉裤�偮�
閫変腑Hello宸ョ▼锛岀劧鍚庨�夋嫨鈥淧roject鈥濓紝鈥淧roperties鈥濓紝鈥淏uilders鈥濓紝鈥淣ew鈥︹�濓紝閫夋嫨鈥淎nt Build鈥濓細聽
濉叆Name锛欰nt_Builder锛汢uildfile锛歜uild.xml锛汢aseDirectory锛�${workspace_loc: /Hello}锛堟寜鈥淏rowseWorkspace鈥濋�夋嫨宸ョ▼鏍圭洰褰曪級锛岀敱浜庣敤鍒颁簡junit.jar鍖咃紝鎼滅储Eclipse鐩綍锛屾壘鍒� junit.jar锛屾妸瀹冨鍒跺埌Hello/lib鐩綍涓嬶紝骞舵坊鍔犲埌Ant鐨凜lasspath涓細聽
鐒跺悗鍦˙uilder闈㈡澘涓挬涓夾nt_Build锛屽幓鎺塉ava Builder锛毬�
鍐嶆缂栬瘧锛屽嵆鍙湪鎺у埗鍙扮湅鍒癆nt鐨勮緭鍑猴細聽
Buildfile: F:\eclipse-projects\Hello\build.xml聽
init:聽
compile:聽
聽 聽 聽 聽 [mkdir] Created dir: F:\eclipse-projects\Hello\classes聽
聽 聽 聽 聽 [javac] Compiling 2 source files to F:\eclipse-projects\Hello\classes聽
test:聽
聽 聽 聽 聽 [mkdir] Created dir: F:\eclipse-projects\Hello\report聽
聽 聽 聽 聽 [junit] Running example.HelloTest聽
聽 聽 聽 聽 [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.02 sec聽
pack:聽
聽 聽 聽 聽 [mkdir] Created dir: F:\eclipse-projects\Hello\dist聽
聽 聽 聽 聽 聽 [jar] Building jar: F:\eclipse-projects\Hello\dist\hello.jar聽
doc:聽
聽 聽 聽 聽 [mkdir] Created dir: F:\eclipse-projects\Hello\doc聽
聽 聽 聽 [javadoc] Generating Javadoc聽
聽 聽 聽 [javadoc] Javadoc execution聽
聽 聽 聽 [javadoc] Loading source files for package example...聽
聽 聽 聽 [javadoc] Constructing Javadoc information...聽
聽 聽 聽 [javadoc] Standard Doclet version 1.4.2_04聽
聽 聽 聽 [javadoc] Building tree for all the packages and classes...聽
聽 聽 聽 [javadoc] Building index for all the packages and classes...聽
聽 聽 聽 [javadoc] Building index for all classes...聽
聽 聽 聽 [javadoc] Generating F:\eclipse-projects\Hello\doc\stylesheet.css...聽
聽 聽 聽 [javadoc] Note: Custom tags that could override future standardtags: 聽 @todo. To avoid potential overrides, use at least one periodcharacter (.) in custom tag names.聽
聽 聽 聽 [javadoc] Note: Custom tags that were not seen: 聽 @todo聽
BUILD SUCCESSFUL聽
Total time: 11 seconds聽
Ant渚濇鎵ц鍒濆鍖栵紝缂栬瘧锛屾祴璇曪紝鎵撳寘锛岀敓鎴怉PI鏂囨。涓�绯诲垪浠诲姟锛屾瀬澶у湴鎻愰珮浜嗗紑鍙戞晥鐜囥�傚皢鏉ュ紑鍙慗2EE椤圭洰鏃讹紝杩樺彲鍔犲叆閮ㄧ讲绛変换鍔°�傚苟涓旓紝鍗充娇鑴辩浜咵clipse鐜锛屽彧瑕佹纭畨瑁呬簡Ant锛岄厤缃ソ鐜鍙橀噺ANT_HOME=
Ant 鐨勬渶瀹屾暣build.xml涔嬫爣绛撅細
Ant 寮�鍙懧�
Ant鐨勬瀯寤烘枃浠堵�
聽聽 褰撳紑濮嬩竴涓柊鐨勯」鐩椂锛岄鍏堝簲璇ョ紪鍐橝nt鏋勫缓鏂囦欢銆傛瀯寤烘枃浠跺畾涔変簡鏋勫缓杩囩▼锛屽苟琚洟闃熷紑鍙戜腑姣忎釜浜轰娇鐢ㄣ�侫nt鏋勫缓鏂囦欢榛樿鍛藉悕涓� build.xml锛屼篃鍙互鍙栧叾浠栫殑鍚嶅瓧銆傚彧涓嶈繃鍦ㄨ繍琛岀殑鏃跺�欐妸杩欎釜鍛藉悕褰撲綔鍙傛暟浼犵粰Ant銆傛瀯寤烘枃浠跺彲浠ユ斁鍦ㄤ换浣曠殑浣嶇疆銆備竴鑸仛娉曟槸鏀惧湪椤圭洰椤跺眰鐩綍涓紝杩欐牱鍙互淇濇寔椤圭洰鐨勭畝娲佸拰娓呮櫚銆備笅闈㈡槸涓�涓吀鍨嬬殑椤圭洰灞傛缁撴瀯銆偮�
(1) src瀛樻斁鏂囦欢銆偮�
(2) class瀛樻斁缂栬瘧鍚庣殑鏂囦欢銆偮�
(3) lib瀛樻斁绗笁鏂笿AR鍖呫�偮�
(4) dist瀛樻斁鎵撳寘锛屽彂甯冧互鍚庣殑浠g爜銆偮�
Ant鏋勫缓鏂囦欢鏄疿ML鏂囦欢銆傛瘡涓瀯寤烘枃浠跺畾涔変竴涓敮涓�鐨勯」鐩�(Project鍏冪礌)銆傛瘡涓」鐩笅鍙互瀹氫箟寰堝鐩爣(target鍏冪礌)锛岃繖浜涚洰鏍囦箣闂村彲浠ユ湁渚濊禆鍏崇郴銆傚綋鎵ц杩欑被鐩爣鏃讹紝闇�瑕佹墽琛屼粬浠墍渚濊禆鐨勭洰鏍囥�傛瘡涓洰鏍囦腑鍙互瀹氫箟澶氫釜浠诲姟锛岀洰鏍囦腑杩樺畾涔変簡鎵�瑕佹墽琛岀殑浠诲姟搴忓垪銆侫nt鍦ㄦ瀯寤虹洰鏍囨椂蹇呴』璋冪敤鎵�瀹氫箟鐨勪换鍔°�備换鍔″畾涔変簡Ant瀹為檯鎵ц鐨勫懡浠ゃ�侫nt涓殑浠诲姟鍙互涓�3绫汇�偮�
锛�1锛� 鏍稿績浠诲姟銆傛牳蹇冧换鍔℃槸Ant鑷甫鐨勪换鍔°�偮�
锛�2锛� 鍙�変换鍔°�傚彲閫変换鍔″疄鏉ヨ嚜绗笁鏂圭殑浠诲姟锛屽洜姝ら渶瑕佷竴涓檮鍔犵殑JAR鏂囦欢銆偮�
锛�3锛� 鐢ㄦ埛鑷畾涔夌殑浠诲姟銆傜敤鎴疯嚜瀹氫箟鐨勪换鍔″疄鐢ㄦ埛鑷繁寮�鍙戠殑浠诲姟銆偮�
1.鏍囩聽
聽 姣忎釜鏋勫缓鏂囦欢瀵瑰簲涓�涓」鐩�傛爣绛炬椂鏋勫缓鏂囦欢鐨勬牴鏍囩銆傚畠鍙互鏈夊涓唴鍦ㄥ睘鎬э紝灏卞浠g爜涓墍绀猴紝鍏跺悇涓睘鎬х殑鍚箟鍒嗗埆濡備笅銆偮�
(1) default琛ㄧず榛樿鐨勮繍琛岀洰鏍囷紝杩欎釜灞炴�ф槸蹇呴』鐨勩�偮�
(2) basedir琛ㄧず椤圭洰鐨勫熀鍑嗙洰褰曘�偮�
(3) name琛ㄧず椤圭洰鍚嶃�偮�
(4) description琛ㄧず椤圭洰鐨勬弿杩般�偮�
姣忎釜鏋勫缓鏂囦欢閮藉搴斾簬涓�涓」鐩紝浣嗘槸澶у瀷椤圭洰缁忓父鍖呭惈澶ч噺鐨勫瓙椤圭洰锛屾瘡涓�涓瓙椤圭洰閮藉彲浠ユ湁鑷繁鐨勬瀯寤烘枃浠躲�偮�
2.鏍囩聽
涓�涓」鐩爣绛鹃┐姊㈡潅骞告榫岃毃鍠�?/span>target鏍囩銆備竴涓猼arget鏍囩鍙互渚濊禆鍏朵粬鐨則arget鏍囩銆備緥濡傦紝鏈変竴涓猼arget鐢ㄤ簬缂栬瘧绋嬪簭锛屽彟涓�涓猼arget鐢ㄤ簬澹扮О鍙墽琛屾枃浠躲�傚湪鐢熸垚鍙墽琛屾枃浠朵箣鍓嶅繀椤诲厛缂栬瘧璇ユ枃浠讹紝鍥犵瓥鍙墽琛屾枃浠剁殑target渚濊禆浜庣紪璇戠▼搴忕殑 target銆俆arget鐨勬墍鏈夊睘鎬у涓嬨�偮�
(1).name琛ㄧず鏍囨槑锛岃繖涓睘鎬ф槸蹇呴』鐨勩�偮�
(2).depends琛ㄧず渚濊禆鐨勭洰鏍囥�偮�
(3)if琛ㄧず浠呭綋灞炴�ц缃椂鎵嶆墽琛屻�偮�
(4)unless琛ㄧず褰撳睘鎬ф病鏈夎缃椂鎵嶆墽琛屻�偮�
(5)description琛ㄧず椤圭洰鐨勬弿杩般�偮�
Ant鐨刣epends灞炴�ф寚瀹氫簡target鐨勬墽琛岄『搴忋�侫nt浼氫緷鐓epends灞炴�т腑target鍑虹幇椤哄簭渚濇鎵ц姣忎釜target銆傚湪鎵ц涔嬪墠锛岄鍏堥渶瑕佹墽琛屽畠鎵�渚濊禆鐨則arget銆傜▼搴忎腑鐨勫悕涓簉un鐨則arget鐨刣epends灞炴�ompile锛岃�屽悕涓篶ompile鐨則arget鐨� depends灞炴�ф槸prepare锛屾墍浠ヨ繖鍑犱釜target鎵ц鐨勯『搴忔槸prepare->compile->run銆備竴涓猼arget鍙兘琚墽琛屼竴娆★紝鍗充娇鏈夊涓猼arget渚濊禆浜庡畠銆傚鏋滄病鏈塱f鎴杣nless灞炴�э紝target鎬讳細琚墽琛屻�偮�
3.鏍囩聽
璇ユ爣绛剧敤浜庡垱寤轰竴涓洰褰曪紝瀹冩湁涓�涓睘鎬ir鐢ㄦ潵鎸囧畾鎵�鍒涘缓鐨勭洰褰曞悕锛屽叾浠g爜濡備笅锛毬�
聽
閫氳繃浠ヤ笂浠g爜灏卞垱寤轰簡涓�涓洰褰曪紝杩欎釜鐩綍宸茬粡琚墠闈㈢殑property鏍囩鎵�鎸囧畾銆偮�
4鏍囩聽
璇ユ爣绛剧敤鏉ョ敓鎴愪竴涓狫AR鏂囦欢锛屽叾灞炴�у涓嬨�偮�
(1) destfile琛ㄧずJAR鏂囦欢鍚嶃�偮�
(2) basedir琛ㄧず琚綊妗g殑鏂囦欢鍚嶃�偮�
(3) includes琛ㄧず鍒綊妗g殑鏂囦欢妯″紡銆偮�
(4) exchudes琛ㄧず琚帓闄ょ殑鏂囦欢妯″紡銆偮�
5锛幝�
璇ユ爣绛剧敤浜庣紪璇戜竴涓垨涓�缁刯ava鏂囦欢锛屽叾灞炴�у涓嬨�偮�
(1).srcdir琛ㄧず婧愮▼搴忕殑鐩綍銆偮�
(2).destdir琛ㄧずclass鏂囦欢鐨勮緭鍑虹洰褰曘�偮�
(3).include琛ㄧず琚紪璇戠殑鏂囦欢鐨勬ā寮忋�偮�
(4).excludes琛ㄧず琚帓闄ょ殑鏂囦欢鐨勬ā寮忋�偮�
(5).classpath琛ㄧず鎵�浣跨敤鐨勭被璺緞銆偮�
(6).debug琛ㄧず鍖呭惈鐨勮皟璇曚俊鎭�偮�
(7).optimize琛ㄧず鏄惁浣跨敤浼樺寲銆偮�
(8).verbose 琛ㄧず鎻愪緵璇︾粏鐨勮緭鍑轰俊鎭�偮�
(9).fileonerror琛ㄧず褰撶鍒伴敊璇氨鑷姩鍋滄銆偮�
6锛庢爣绛韭�
璇ユ爣绛剧敤鏉ユ墽琛岀紪璇戠敓鎴愮殑.class鏂囦欢锛屽叾灞炴�у涓嬨�偮�
(1).classname 琛ㄧず灏嗘墽琛岀殑绫诲悕銆偮�
(2).jar琛ㄧず鍖呭惈璇ョ被鐨凧AR鏂囦欢鍚嶃�偮�
(3).classpath鎵�琛ㄧず鐢ㄥ埌鐨勭被璺緞銆偮�
(4).fork琛ㄧず鍦ㄤ竴涓柊鐨勮櫄鎷熸満涓繍琛岃绫汇�偮�
(5).failonerror琛ㄧず褰撳嚭鐜伴敊璇椂鑷姩鍋滄銆偮�
(6).output 琛ㄧず杈撳嚭鏂囦欢銆偮�
(7).append琛ㄧず杩藉姞鎴栬�呰鐩栭粯璁ゆ枃浠躲�偮�
7.鏍囩聽
璇ユ爣绛剧敤浜庡垹闄や竴涓枃浠舵垨涓�缁勬枃浠讹紝鍘诲睘鎬у涓嬨�偮�
(1)/file琛ㄧず瑕佸垹闄ょ殑鏂囦欢銆偮�
(2).dir琛ㄧず瑕佸垹闄ょ殑鐩綍銆偮�
(3).includeEmptyDirs 琛ㄧず鎸囧畾鏄惁瑕佸垹闄ょ┖鐩綍锛岄粯璁ゅ�兼槸鍒犻櫎銆偮�
(4).failonerror 琛ㄧず鎸囧畾褰撶鍒伴敊璇槸鍚﹀仠姝紝榛樿鍊兼槸鑷姩鍋滄銆偮�
(5).verbose琛ㄧず鎸囧畾鏄惁鍒楀嚭鎵�鍒犻櫎鐨勬枃浠讹紝榛樿鍊间负涓嶅垪鍑恒�偮�
8.鏍囩聽
璇ユ爣绛剧敤浜庢枃浠舵垨鏂囦欢闆嗙殑鎷疯礉锛屽叾灞炴�у涓嬨�偮�
(1).file 琛ㄧず婧愭枃浠躲�偮�
(2).tofile 琛ㄧず鐩爣鏂囦欢銆偮�
(3).todir 琛ㄧず鐩爣鐩綍銆偮�
(4).overwrite 琛ㄧず鎸囧畾鏄惁瑕嗙洊鐩爣鏂囦欢锛岄粯璁ゅ�兼槸涓嶈鐩栥�偮�
(5).includeEmptyDirs 琛ㄧず鍒跺畾鏄惁鎷疯礉绌虹洰褰曪紝榛樿鍊间负鎷疯礉銆偮�
(6).failonerror 琛ㄧず鎸囧畾濡傜洰鏍囨病鏈夊彂鐜版槸鍚﹁嚜鍔ㄥ仠姝紝榛樿鍊兼槸鍋滄銆偮�
(7).verbose 琛ㄧず鍒跺畾鏄惁鏄剧ず璇︾粏淇℃伅锛岄粯璁ゅ�间笉鏄剧ず銆偮�
ant鏁欑▼璇﹁В--javac锛宩ava锛宩ar锛寃ar锛宒elete锛宑opy锛宮kdir锛�
Ant 鏄竴涓� Apache 鍩洪噾浼氫笅鐨勮法骞冲彴鐨勬瀯浠跺伐鍏凤紝瀹冨彲浠ュ疄鐜伴」鐩殑鑷姩鏋勫缓鍜岄儴缃茬瓑鍔熻兘銆傚湪鏈枃涓紝涓昏璁╄鑰呯啛鎮夋�庢牱灏� Ant 搴旂敤鍒� Java 椤圭洰涓紝璁╁畠绠�鍖栨瀯寤哄拰閮ㄧ讲鎿嶄綔銆�
涓�锛幝犅犅犅犅犅犅犅犅犅犅犅犅� 瀹夎涓庨厤缃�
涓嬭浇鍦板潃锛� http://ant.apache.org/ 锛屽湪鏈枃涓笅杞界殑鏄� 1.7.0 鐗堟湰銆傝В鍘嬪埌鏌愪釜鐩綍锛堜緥濡� E:"apache-ant-1.7.0 锛夛紝鍗冲彲浣跨敤銆�
娣诲姞绯荤粺鐜鍙橀噺锛� ANT_HOME 锛岃鍙橀噺鎸囧悜 Ant 瑙e帇鍚庣殑鏍圭洰褰曪紝鍦ㄦ涓� E:"apache-ant-1.7.0 銆�
瀹夎涓庨厤缃畬姣曞悗锛岃鑰呭彲浠ユ祴璇曚竴涓� Ant 鏄惁鍙敤锛岄鍏堣繘鍏� Ant 鐨� bin 鐩綍锛岃繍琛屽懡浠� ant 鈥搗ersion 锛岃嫢瀹夎鍜岄厤缃垚鍔燂紝鍒欎細鏄剧ず Ant 鐗堟湰淇℃伅锛屽涓嬪浘鎵�绀猴細
鐢变笂鍙互鐪嬪嚭锛岃鑰呰繍琛� Ant 鐨勫懡浠ゆ椂锛岄渶瑕佽繘鍏ュ埌 Ant 鐨� bin 鐩綍锛屽浣曟墠鑳借绯荤粺鑷姩鎵惧埌 Ant 鍛紵杩欐椂闇�瑕佽鑰呭湪绯荤粺鐜鍙橀噺 path 涓坊鍔� Ant 鐨� bin 鐩綍銆傝缃畬鎴愬悗锛屾垜浠氨鍙互鍦ㄤ换浣曠洰褰曪紙渚嬪 C:"Documents and Settings"AmigoXie 鐩綍锛夎緭鍏� Ant 鐨勫懡浠わ紝鏉ヨ幏寰楀懡浠ょ殑杩愯缁撴灉銆�
浜岋紟聽聽聽聽聽聽聽聽聽聽聽聽聽 Ant 鐨勫叧閿厓绱�
Ant 鐨勬瀯浠舵枃浠舵槸鍩轰簬 XML 缂栧啓鐨勶紝榛樿鍚嶇О涓� build.xml 銆備负浜嗘洿娓呮鐨勪簡瑙� Ant 锛屽湪杩欓噷缂栧啓涓�涓畝鍗曠殑 Ant 绋嬪簭锛岀敤鏉ュ睍鐜� Ant 鐨勫姛鑳斤紝璁╄鑰呭 Ant 鏈変竴涓垵姝ョ殑浜嗚В銆傞鍏堝湪 E 鐩樹笅寤虹珛涓�涓� build.xml 鏂囦欢锛屽唴瀹瑰涓嬶細
< project聽 name ="helloWorld">
< target聽 name ="sayHelloWorld">
< echo聽 message ="Hello,Amigo"/>
璇昏�呭彲浠ヨ繘鍏� E 鐩橈紝鐒跺悗杩愯 ant sayHelloWorld 锛屽彲浠ョ湅鍒板涓嬬殑杩愯缁撴灉锛�
鍏朵腑 sayHelloWorld 涓洪渶瑕佹墽琛岀殑浠诲姟鐨勫悕绉般�傚鏋滄枃浠跺悕涓嶄负 build.xml 锛岃�屼负 hello.xml 鏃讹紝璇昏�呰繍琛屽悓鏍风殑鍛戒护鏃讹紝鍛戒护绐楀彛浼氬嚭鐜板涓嬮敊璇細
Buildfile: build.xml does not exist!
Build failed
鐢变笂闈㈢殑鍛戒护鐨勯敊璇彁绀哄彲浠ョ湅鍑猴紝 ant 鍛戒护榛樿瀵绘壘 build.xml 鏂囦欢銆傝嫢鏂囦欢鍚嶄负 hello.xml 鏃讹紝璇昏�呰繕闇�瑕佸鍛戒护鍋氬皯璁告敼鍙橈紝鏀逛负锛� ant 鈥揻 hello.xml sayHelloWorld 銆� ant 鈥揵uildfile hello.xml sayHelloWorld 鎴� ant 鈥揻ile hello.xml sayHelloWorld 銆�
鎺ヤ笅鏉ュ紑濮嬪悜璇昏�呰瑙f湰鑺傜殑閲嶇偣锛� Ant 鐨勫叧閿厓绱� project 銆� target 銆� property 鍜� task 銆�
1.聽聽聽聽聽聽聽 project 鍏冪礌
project 鍏冪礌鏄� Ant 鏋勪欢鏂囦欢鐨勬牴鍏冪礌锛� Ant 鏋勪欢鏂囦欢鑷冲皯搴旇鍖呭惈涓�涓� project 鍏冪礌锛屽惁鍒欎細鍙戠敓閿欒銆傚湪姣忎釜 project 鍏冪礌涓嬶紝鍙寘鍚涓� target 鍏冪礌銆傛帴涓嬫潵鍚戣鑰呭睍绀轰竴涓� project 鍏冪礌鐨勫悇灞炴�с��
1 锛� name 灞炴��
鐢ㄤ簬鎸囧畾 project 鍏冪礌鐨勫悕绉般��
2 锛� default 灞炴��
鐢ㄤ簬鎸囧畾 project 榛樿鎵ц鏃舵墍鎵ц鐨� target 鐨勫悕绉般��
3 锛� basedir 灞炴��
鐢ㄤ簬鎸囧畾鍩鸿矾寰勭殑浣嶇疆銆傝灞炴�ф病鏈夋寚瀹氭椂锛屼娇鐢� Ant 鐨勬瀯浠舵枃浠剁殑闄勭洰褰曚綔涓哄熀鍑嗙洰褰曘��
涓嬮潰缁欒鑰呬竴涓畝鍗曠殑渚嬪瓙鏉ュ睍绀� project 鐨勫悇鍏冪礌鐨勪娇鐢ㄣ�備慨鏀� E:"build.xml 鏂囦欢锛屼慨鏀瑰悗鐨勫唴瀹瑰涓嬶細
< project聽 name ="projectStudy"聽 default ="sayBaseDir"聽 basedir ="E:" apache-ant-1.7.0" >
< target聽 name ="sayBaseDir">
< echo聽 message ="The base dir is: ${basedir}"/>
浠庝笂闈㈢殑鍐呭鎴戜滑鍙互鐪嬪嚭锛屽湪杩欓噷瀹氫箟浜� default 灞炴�х殑鍊间负 sayBaseDir 锛屽嵆褰撹繍琛� ant 鍛戒护鏃讹紝鑻ユ湭鎸囨槑鎵ц鐨� target 鏃讹紝榛樿鎵ц鐨� target 鐨� sayBaseDir 锛屽悓鏃惰繕瀹氫箟浜� basedir 灞炴�х殑鍊间负 E:"apache-ant-1.7.0 锛岃繘鍏� E 鐩樺悗杩愯 ant 鍛戒护锛屽彲鐪嬪埌杩愯鐨勭粨鏋滐紝濡備笅鍥炬墍绀猴細
鍥犱负璁惧畾浜� basedir 鐨勫�硷紝鎵�浠� basedir 灞炴�х殑鍊煎彉鎴愪簡璇昏�呰缃殑鍊笺�傝鑰呭彲浠ヨ嚜琛屽皢 project 鍏冪礌鐨� basedir 灞炴�у幓鎺夊悗杩愯 ant 鐪嬬湅杩愯缁撴灉锛屾鏃� basedir 鐨勫�煎彉鎴愪簡 E:" 锛屽嵆涓� Ant 鏋勪欢鏂囦欢鐨勭埗鐩綍銆�
鏈夌殑鏃跺�欙紝璇昏�呭彲鑳芥湁杩欑闇�姹傦紝鍗虫兂寰楀埌鏌愪釜 project 涓嬫墍鏈夌殑 target 鐨勫悕绉帮紝璇昏�呭彲浠ラ�氳繃鍦� ant 鍛戒护閲屽姞涓� -proecthelp 鏉ヨ揪鍒拌鐩殑銆備緥濡傞拡瀵逛笂杩扮殑渚嬪瓙鎴戜滑杩愯 ant 鈥損rojecthelp 锛岃緭鍑虹粨鏋滃涓嬶細
Buildfile: build.xml
Main targets:
Other targets:
sayBaseDir
Default target: sayBaseDir
2.聽聽聽聽聽聽聽 target 鍏冪礌
瀹冧负 Ant 鐨勫熀鏈墽琛屽崟鍏冿紝瀹冨彲浠ュ寘鍚竴涓垨澶氫釜鍏蜂綋鐨勪换鍔°�傚涓� target 鍙互瀛樺湪鐩镐簰渚濊禆鍏崇郴銆傚畠鏈夊涓嬪睘鎬э細
1 锛� name 灞炴��
鎸囧畾 target 鍏冪礌鐨勫悕绉帮紝杩欎釜灞炴�у湪涓�涓� project 鍏冪礌涓槸鍞竴鐨勩�傛垜浠彲浠ラ�氳繃鎸囧畾 target 鍏冪礌鐨勫悕绉版潵鎸囧畾鏌愪釜 target 銆�
2 锛� depends 灞炴��
鐢ㄤ簬鎻忚堪 target 涔嬮棿鐨勪緷璧栧叧绯伙紝鑻ヤ笌澶氫釜 target 瀛樺湪渚濊禆鍏崇郴鏃讹紝闇�瑕佷互鈥� , 鈥濋棿闅斻�� Ant 浼氫緷鐓� depends 灞炴�т腑 target 鍑虹幇鐨勯『搴忎緷娆℃墽琛屾瘡涓� target 銆傝渚濊禆鐨� target 浼氬厛鎵ц銆�
3 锛� if 灞炴��
鐢ㄤ簬楠岃瘉鎸囧畾鐨勫睘鎬ф槸鍚﹀瓨鍦紝鑻ヤ笉瀛樺湪锛屾墍鍦� target 灏嗕笉浼氳鎵ц銆�
4 锛� unless 灞炴��
璇ュ睘鎬х殑鍔熻兘涓� if 灞炴�х殑鍔熻兘姝eソ鐩稿弽锛屽畠涔熺敤浜庨獙璇佹寚瀹氱殑灞炴�ф槸鍚﹀瓨鍦紝鑻ヤ笉瀛樺湪锛屾墍鍦� target 灏嗕細琚墽琛屻��
5 锛� description 灞炴��
璇ュ睘鎬ф槸鍏充簬 target 鍔熻兘鐨勭畝鐭弿杩板拰璇存槑銆�
涓嬮潰甯﹂璇昏�呮潵鐪嬩竴涓悇灞炴�х患鍚堜娇鐢ㄧ殑渚嬪瓙銆備慨鏀� E:"build.xml 鏂囦欢锛屼慨鏀瑰悗鐨勫唴瀹瑰涓嬶細
< project聽 name ="targetStudy">
< target聽 name ="targetA"聽 if ="ant.java.version">
< echo聽 message ="Java Version: ${ant.java.version}"/>
< target聽 name ="targetB"聽 depends ="targetA"聽 unless ="amigo">
< description >
a depend example!
< echo聽 message ="The base dir is: ${basedir}"/>
杩涘叆 E 鐩樺悗杩愯 ant targetB 锛屽彲鐪嬪埌濡備笅鍥炬墍绀虹殑杩愯缁撴灉锛�
璇昏�呭垎鏋愮粨鏋滃悗鍙互鐪嬪埌锛屾垜浠繍琛岀殑鏄悕涓� targetB 鐨� target 锛屽洜璇� target 渚濊禆浜� targetA 锛屾墍浠� targetA 灏嗛鍏堣鎵ц锛屽悓鏃跺洜涓虹郴缁熷畨瑁呬簡 java 鐜锛屾墍浠� ant.java.version 灞炴�у瓨鍦紝鎵ц浜� targetA 杩欎釜 target 锛岃緭鍑轰俊鎭細 [echo] Java Version: 1.5 锛� targetA 鎵ц瀹屾瘯鍚庯紝鎺ョ潃鎵ц targetB 锛屽洜涓� amigo 涓嶅瓨鍦紝鑰� unless 灞炴�ф槸鍦ㄤ笉瀛樺湪鏃惰繘鍏ユ墍鍦ㄧ殑 target 鐨勶紝鐢辨鍙煡 targetB 寰椾互鎵ц锛岃緭鍑轰俊鎭細 The base dir is: E:" 銆�
3.聽聽聽聽聽聽聽 property 鍏冪礌
璇ュ厓绱犲彲鐪嬩綔鍙傞噺鎴栬�呭弬鏁扮殑瀹氫箟锛� project 鐨勫睘鎬у彲浠ラ�氳繃 property 鍏冪礌鏉ヨ瀹氾紝涔熷彲鍦� Ant 涔嬪璁惧畾銆傝嫢瑕佸湪澶栭儴寮曞叆鏌愭枃浠讹紝渚嬪 build.properties 鏂囦欢锛屽彲浠ラ�氳繃濡備笅鍐呭灏嗗叾寮曞叆锛�
property 鍏冪礌鍙敤浣� task 鐨勫睘鎬у�笺�傚湪 task 涓槸閫氳繃灏嗗睘鎬у悕鏀惧湪鈥� ${ 鈥濆拰鈥� } 鈥濅箣闂达紝骞舵斁鍦� task 灞炴�у�肩殑浣嶇疆鏉ュ疄鐜扮殑銆�
Ant 鎻愪緵浜嗕竴浜涘唴缃殑灞炴�э紝瀹冭兘寰楀埌鐨勭郴缁熷睘鎬х殑鍒楄〃涓� Java 鏂囨。涓� System.getPropertis() 鏂规硶寰楀埌鐨勫睘鎬т竴鑷达紝杩欎簺绯荤粺灞炴�у彲鍙傝�� sun 缃戠珯鐨勮鏄庛��
鍚屾椂锛� Ant 杩樻彁渚涗簡涓�浜涘畠鑷繁鐨勫唴缃睘鎬э紝濡備笅锛�
basedir 锛� project 鍩虹洰褰曠殑缁濆璺緞锛岃灞炴�у湪璁茶В project 鍏冪礌鏃舵湁璇︾粏璇存槑锛屼笉鍐嶈禈杩帮紱
ant.file 锛� buildfile 鐨勭粷瀵硅矾寰勶紝濡備笂闈㈢殑鍚勪緥瀛愪腑锛� ant.file 鐨勫�间负 E:"build.xml 锛�
ant.version 锛� Ant 鐨勭増鏈紝鍦ㄦ湰鏂囦腑锛屽�间负 1.7.0 锛�
ant.project.name 锛氬綋鍓嶆寚瀹氱殑 project 鐨勫悕瀛楋紝鍗冲墠鏂囪鍒扮殑 project 鐨� name 灞炴�х殑鍊硷紱
ant.java.version 锛� Ant 妫�娴嬪埌鐨� JDK 鐨勭増鏈紝鍦ㄤ笂渚嬭繍琛岀粨鏋滀腑鍙湅鍒颁负 1.5 銆�
涓嬮潰璁╄鑰呮潵鐪嬩竴涓� property 鍏冪礌浣跨敤鐨勭畝鍗曚緥瀛愩�備慨鏀� E:"build.xml 鏂囦欢锛屽唴瀹瑰涓嬶細
< project聽 name ="propertyStudy"聽 default ="example">
< property聽 name ="name"聽 value ="amigo"/>
< property聽 name ="age"聽 value ="25"/>
< target聽 name ="example">
< echo聽 message ="name: ${name}, age: ${age}"/>
璇ヤ緥鐨勮繍琛岀粨鏋滃涓嬪浘鎵�绀猴細
鐢辨璇昏�呭彲浠ョ湅鍑猴紝閫氳繃濡備笅涓や釜璇彞锛�
鎴戜滑璁剧疆浜嗗悕涓� name 鍜� age 鐨勪袱涓睘鎬э紝杩欎袱涓睘鎬ц缃悗锛岃鑰呭湪涓嬫枃涓彲浠ラ�氳繃 ${name} 鍜� ${age} 鍒嗗埆鍙栧緱杩欎袱涓睘鎬х殑鍊笺��
涓夛紟聽聽聽聽聽聽聽聽聽聽聽聽聽 Ant 鐨勫父鐢ㄤ换鍔�
鍦� Ant 宸ュ叿涓瘡涓�涓换鍔″皝瑁呬簡鍏蜂綋瑕佹墽琛岀殑鍔熻兘锛屾槸 Ant 宸ュ叿鐨勫熀鏈墽琛屽崟浣嶃�傚湪鏈皬鑺備腑锛屼富瑕佸紩瀵艰鑰呮潵鐪嬩笅 Ant 鐨勫父鐢ㄤ换鍔″強鍏朵娇鐢ㄤ妇渚嬨��
1.聽聽聽聽聽聽聽 copy 浠诲姟
璇ヤ换鍔′富瑕佺敤鏉ュ鏂囦欢鍜岀洰褰曠殑澶嶅埗鍔熻兘銆備妇渚嬪涓嬶細
Eg1. 澶嶅埗鍗曚釜鏂囦欢锛�
Eg2. 瀵规枃浠剁洰褰曡繘琛屽鍒讹細
Eg3. 灏嗘枃浠跺鍒跺埌鍙﹀鐨勭洰褰曪細
2.聽聽聽聽聽聽聽 delete 浠诲姟
瀵规枃浠舵垨鐩綍杩涜鍒犻櫎锛屼妇渚嬪涓嬶細
Eg1. 鍒犻櫎鏌愪釜鏂囦欢锛�
Eg2. 鍒犻櫎鏌愪釜鐩綍锛�
Eg3. 鍒犻櫎鎵�鏈夌殑澶囦唤鐩綍鎴栫┖鐩綍锛�
3.聽聽聽聽聽聽聽 mkdir 浠诲姟
鍒涘缓鐩綍銆� eg 锛�
4.聽聽聽聽聽聽聽 move 浠诲姟
绉诲姩鏂囦欢鎴栫洰褰曪紝涓句緥濡備笅锛�
Eg1. 绉诲姩鍗曚釜鏂囦欢锛�
Eg2. 绉诲姩鍗曚釜鏂囦欢鍒板彟涓�涓洰褰曪細
Eg3. 绉诲姩鏌愪釜鐩綍鍒板彟涓�涓洰褰曪細
5.聽聽聽聽聽聽聽 echo 浠诲姟
璇ヤ换鍔$殑浣滅敤鏄牴鎹棩蹇楁垨鐩戞帶鍣ㄧ殑绾у埆杈撳嚭淇℃伅銆傚畠鍖呮嫭 message 銆� file 銆� append 鍜� level 鍥涗釜灞炴�э紝涓句緥濡備笅锛�
鍥涳紟聽聽聽聽聽聽聽聽聽聽聽聽聽 鍒╃敤 Ant 鏋勫缓鍜岄儴缃� Java 宸ョ▼
Ant 鍙互浠f浛浣跨敤 javac 銆� java 鍜� jar 绛夊懡浠ゆ潵鎵ц java 鎿嶄綔锛屼粠鑰岃揪鍒拌交鏉剧殑鏋勫缓鍜岄儴缃� Java 宸ョ▼鐨勭洰鐨勩�備笅闈㈡潵鐪嬪嚑涓煡璇嗙偣銆�
1.聽聽聽聽聽聽聽 鍒╃敤 Ant 鐨� javac 浠诲姟鏉ョ紪璇� java 绋嬪簭
Ant 鐨� javac 浠诲姟鐢ㄤ簬瀹炵幇缂栬瘧 Java 绋嬪簭鐨勫姛鑳姐�備笅闈㈡潵鐪嬩竴涓畝鍗曠殑渚嬪瓙锛�
棣栧厛鎴戜滑寤虹珛鍚嶄负 antstudy 鐨� Java 宸ョ▼锛屽缓绔� src 鐩綍涓烘簮浠g爜鐩綍锛屽湪 src 鐩綍涓嬪缓绔� HelloWorld.java 杩欎釜绫绘枃浠躲�傝绫绘枃浠剁殑鍐呭濡備笅锛�
public聽聽 class聽 HelloWorld聽 {
public聽聽 static聽聽 void聽 main(String[] args)聽 {
System.out.println("Hello,Amigo");
}
}
鍚屾椂鍦� antstudy 宸ョ▼鐨勬牴鐩綍涓嬪缓绔� build.xml 鏂囦欢锛屽湪璇ユ枃浠朵腑缂栬瘧 src 鐩綍涓嬬殑 java 鏂囦欢锛屽苟灏嗙紪璇戝悗鐨� class 鏂囦欢鏀惧叆 build/classes 鐩綍涓紝鍦ㄧ紪璇戝墠锛岄渶娓呴櫎 classes 鐩綍锛岃鏂囦欢鐨勫唴瀹瑰涓嬶細
< project聽 name ="javacTest" default ="compile"聽 basedir =".">
< target聽 name ="clean">
< delete聽 dir ="build"/>
< target聽 name ="compile"聽 depends ="clean">
< mkdir聽 dir ="build/classes"/>
< javac聽 srcdir ="src"聽 destdir ="build/classes"/>
杩愯璇� build.xml 鏂囦欢锛屽彲鍦ㄥ伐绋嬩腑鐪嬪埌鏂板浜� build/classes 鐩綍锛屽苟鍦ㄨ鐩綍涓敓鎴愪簡缂栬瘧鍚庣殑 HelloWorld.class 鏂囦欢銆�
2.聽聽聽聽聽聽聽 浣跨敤 Ant 鐨� java 浠诲姟杩愯 Java 绋嬪簭
Ant 涓彲浠ヤ娇鐢� java 浠诲姟瀹炵幇杩愯 Java 绋嬪簭鐨勫姛鑳姐�備笅闈㈠湪 1 鐨勪緥瀛愪腑杩涜濡備笅鐨勪慨鏀癸紝淇敼鍚庣殑 build.xml 鏂囦欢鐨勫唴瀹瑰涓嬶細
< project聽 name ="javaTest"聽 default ="jar"聽 basedir =".">
< target聽 name ="clean">
< delete聽 dir ="build"/>
< target聽 name ="compile"聽 depends ="clean">
< mkdir聽 dir ="build/classes"/>
< javac聽 srcdir ="src"聽 destdir ="build/classes"/>
< target聽 name ="run"聽 depends ="compile">
< java聽 classname ="HelloWorld">
< classpath >
< pathelement聽 path ="build/classes"/>
杩愯璇� build.xml 鏂囦欢锛屽彲鍦ㄦ帶鍒跺彴鐪嬪埌 HelloWorld 鐨� main 鏂规硶鐨勮緭鍑恒��
3.聽聽聽聽聽聽聽 浣跨敤 Ant 鐨� jar 浠诲姟鐢熸垚 jar 鏂囦欢
璇昏�呭彲浠ュ湪涓婁緥鐨勫熀纭�涓婃洿杩涗竴姝ワ紝鏉ョ敓鎴� jar 鍖咃紝鍙湪 run 杩欎釜 target 涓嬪啀鍔犱笂濡備笅 target 锛�
< target聽 name ="jar"聽 depends ="run">
< jar聽 destfile ="helloworld.jar"聽 basedir ="build/classes">
< manifest >
< attribute聽 name ="Main-class"聽 value ="HelloWorld"/>
姝ゆ椂灏� ant 鐨� project 鐨� default 灞炴�ц缃负 jar 锛屽悓鏃惰繍琛岃 build.xml 鏂囦欢锛岃繍琛屽畬姣曞悗锛屽彲鐪嬪埌鍦ㄥ伐绋嬬洰褰曚笅鐢熸垚浜嗕竴涓� jar 鍖� HelloWorld.jar 銆�
4.聽聽聽聽聽聽聽 浣跨敤 Ant 鐨� war 浠诲姟鎵撳寘 J2EE Web 椤圭洰
寤虹珛涓�涓� J2EE Web 宸ョ▼锛屽叾鐩綍缁撴瀯濡備笅鍥炬墍绀猴細
鍏朵腑 src 涓烘簮浠g爜鐩綍锛� WebRoot 涓哄悇 jsp 瀛樻斁鐩綍锛� lib 涓哄伐绋嬬殑鍖呯洰褰曘�傚湪 antwebproject 宸ョ▼鐩綍涓嬪缓绔嬩簡 build.xml 鏂囦欢锛岃鏂囦欢涓鸿宸ョ▼鐨� Ant 鏋勪欢鏂囦欢銆傝鑰呭彲浠� src 鐩綍涓嬫斁鍏ュ湪鍓嶇画渚嬪瓙涓紑鍙戠殑 HelloWorld.java 鏂囦欢锛屽苟鍦� WebRoot 涓嬪缓绔� index.jsp 鏂囦欢锛屽叾鍐呭寰堢畝鍗曪紝灏辨槸杈撳嚭 Hello 淇℃伅锛屼唬鐮佸涓嬫墍绀猴細
<% @ page language="java" contentType="text/html; charset="UTF-8" pageEncoding="UTF-8" %>
< html >
< head >
< meta聽 http-equiv ="Content-Type"聽 content ="text/html; charset=ISO-8859-1">
< title > ant 鎵撳寘娴嬭瘯
< body >
Hello,Ant
鎺ヤ笅鏉ョ紪鍐� build.xml 鏂囦欢锛屽叾鍐呭濡備笅锛�
< project聽 name ="antwebproject"聽聽 default ="war" basedir =".">
< property聽 name ="classes"聽 value ="build/classes"/>
< property聽 name ="build" value ="build"/>
< property聽 name ="lib" value ="WebRoot/WEB-INF/lib"/>
< target聽 name ="clean">
< delete聽 dir ="build"/>
< target聽 name ="compile"聽 depends ="clean">
< mkdir聽 dir ="${classes}"/>
< javac聽 srcdir ="src"聽 destdir ="${classes}"/>
< target聽 name ="war"聽 depends ="compile">
< war聽 destfile ="${build}/antwebproject.war"聽 webxml ="WebRoot/WEB-INF/web.xml">
< fileset聽 dir ="WebRoot"聽 includes ="**/*.jsp"/>
< lib聽 dir ="${lib}"/>
< classesdir ="${classes}"/>
鍚� target 鐨勪綔鐢ㄥ湪鍐呭涓凡缁忚繘琛岃鏄庯紝鍦ㄦ涓嶅啀璧樿堪銆傝繍琛岃 build 鏂囦欢锛屾洿鏂扮洰褰曞悗锛屽彲鐪嬪埌鍦� build 鐩綍涓嬬敓鎴愪簡 antwebproject.war 鏂囦欢锛岃В寮�鍚庡彲鐪嬪埌鍏剁洰褰曠粨鏋勫涓嬶細
--META-INF
--MANIFEST.MF
--index.jsp
--WEB-INF
--lib
--log4j-1.2.9.jar
--classes
--HelloWorld.class
--web.xml
璇昏�呭彲浠ュ皢璇� war 鍖呮嫹璐濆埌 Tomcat 鐨勭洰褰曚笅鐪嬩竴涓嬭繍琛岀粨鏋溿��
浜旓紟聽聽聽聽聽聽聽聽聽聽聽聽聽 鎬荤粨
鍦ㄦ湰鏂囦腑锛岀瑪鑰呯敱娴呰嚦娣辫缁嗘弿杩颁簡 Ant 鐨勫畨瑁呬笌閰嶇疆銆佸叧閿厓绱犲拰甯哥敤浠诲姟銆傚苟閫氳繃瀹炰緥璁茶堪浜� Ant 鍦ㄦ垜浠� Java 椤圭洰涓殑搴旂敤锛岃杩颁簡缂栬瘧銆佽繍琛� java 绋嬪簭锛屼互鍙婃墦 jar 鍖呫�� war 鍖呯瓑鐭ヨ瘑锛屽紩棰嗚鑰呰繘鍏� Ant 鐨勫濡欎笘鐣屻�傚湪鏈枃涓彲浠ョ湅鍒帮紝 Ant 鍦ㄨ嚜鍔ㄦ瀯寤哄拰閮ㄧ讲 Java 绋嬪簭鏂归潰鏂逛究鏄撶敤锛岃�屼笖闈炲父鐏垫椿锛屼笉澶变负鎴戜滑 Java 寮�鍙戣�呯殑缁濅匠甯墜
http://blog.csdn.net/user4570/archive/2009/05/27/4221101.aspx