編寫build.xml的12個原則 (轉)
我不喜歡這個title的翻譯,它的原文應該是“通往build.天堂的12條路”。為了讓讀者更容易理解,我最後還是選擇了這個通俗……俗氣的title。需要注意的是,這篇log來自“e”hani……
1031#12_paths_to_build_xml">12 paths to build.xml nirvana
1 - Always prov launchers for ant. A standalone build.xml is simply too demanding for developers, who are used to luxuries like build.bat and build.sh. Nothing says 'we care about your platform' like shell script launchers.
2 - While you're writing those launchers, make sure you provide specialized ones so users can very easy call various build targets. Build.sh looks naked and sad without its childhood friends, make.sh, compile.sh, docs.sh, and run.sh.
3 - Never place your build.xml file in your top level directory. The deeper in it is, the more likely it is that people will actually look at your stuff in a hopeless effort to find said file.
4 - Never allow for people to customize the build process. Sourcing an external properties file is just cause for confusion and trauma.
5 - If you do want customization, then force users to define env vars. Since every user's environment is unique and specific, why not demand and expect them to define 12 *_HOME type variables first? That way when they do get the build going, they'll feel it's like a personal customized version that is tailored for their own needs and nobody else's.
6 - Never rely on -projecthelp. The default ant target should do nothing but spit out a few pages of useless info explaining all the available targets. Yes, ant does allow for this via the -projecthelp switch, but that assumes users know when they need help. It is obvious to you, almighty developer, that unless they explicitly ask for something else, they want help.
7 - Your default target should try to surprise and amuse users. Why have a target that just builds your project when instead you can have it build a whole distribution? Sure, builders are those who might well poke about the and want quick builds via ant, but screw them. A whole distribution just looks so much more professional.
8 - Ask users to prove their loyalty and dedication to your cause by demanding they add jar files to ANT_HOME/lib. For extra points, do not tell them what these jar files are. It can be a test of the true faithful to see if they can figure it out from an ant stacktrace and find out what jar to from where.
9 - Never shdependent jars. As any true maven asshat knows, jars should be delivered over thework from a central repository. This way you can automatically weed out those pesky enterprise users behind restrictive s who are in all likelihood violently opposed to opensores anyway. Make liberal use of the get task, it's there for a reason you know.
10 - Ensure a fresh start! Every target should depend on the clean target. This way you can be sure that the user will not have any problems with left over cruft from an old build. Sure, their build rate will slow down by a few orders of magnitude, but it's better to be safe than sorry.
11 - build.xml should be your gateway to everything. Don't be fooled by its name, you can and should use it to run your apps too. Why bother with pesky manifests and cumbersome jar files? They're from the evil un-free empire of Sun, so you must shun them. Instead, make liberal use of the task in ant. Real build.xml love will shine through the next time you type ant run.
12 - Consolidation is for the weak. A single buildfile basically screams out 'I'm a girl and like bunnies and wear pink fluffy dresses'. If you're going for a more manly effect, then split your build.xml files into as many pieces as possible. Extra points for bragging about reusability and employing cunning task obfuscation. The casual user must never be able to figure out what is actually going on, or they'll get funny ideas that they could have done it themselves.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-963670/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 正確編寫Designated Initializer的幾個原則
- 專案成功的12個關鍵原則 (轉)
- 專案成功的12個關鍵原則(轉)
- Python寫業務邏輯的幾個編碼原則Python
- 專案管理成功的12個關鍵原則(轉)專案管理
- CPA二十二--三個編制原則(轉載)
- 重寫遵循的原則
- 專案管理成功的12個關鍵原則專案管理
- 最少編碼原則
- 編碼如作文:寫出高可讀 JS 的 7 條原則JS
- Web前端編碼原則Web前端
- 物料編碼原則---by AMT
- 用vue優雅地編寫UI元件的幾條指導原則VueUI元件
- 設計原則-依賴反轉原則
- 專案管理應遵循的幾個原則(1)(轉)專案管理
- 專案管理應遵循的幾個原則(2)(轉)專案管理
- 專案管理應遵循的幾個原則(3)(轉)專案管理
- 專案管理應遵循的幾個原則(4)(轉)專案管理
- 編寫程式碼的若干個基本規則(以Java為例)Java
- 設計原則之【依賴反轉原則】
- MKASH原則(轉載)
- 專案管理成功的10個關鍵原則(轉)專案管理
- 真正需要學習的12個微服務設計原則微服務
- 高效編寫Dockerfile的幾條準則Docker
- 五個簡單的原則,帶你寫出整潔程式碼
- 創業的十個原則創業
- SOA四個原則
- 軟體設計原則—依賴倒轉原則
- Ant 編譯、打包 build.xml 指令碼模板編譯UIXML指令碼
- 【轉】Ant之build.xml詳解UIXML
- 物件導向的編碼設計原則物件
- 實施ERP的原則(轉)
- 敏捷開發流程之Scrum:3個角色、5個會議、12原則敏捷Scrum
- 每個程式設計師都該知道的10大編碼原則程式設計師
- (轉)SQL 優化原則SQL優化
- ECRS分析原則(轉載)
- Web開發的七個原則Web
- 我的10個開發原則