Better Builds with Maven

這本書可以在 http://maestrodev.com/support 免費下載,同時這本書還有持續更新,現在是 1.7 版
Chapter 1
convention over configuration(慣例優先原則)
There are three primary conventions that Maven employs to promote a familiar development environment:
- Standard directory layout for projects
- The concept of a single Maven project producing a single output
- Standard naming conventions
補充
竹林七賢: Convention Over Configuration
這個概念簡單來講就是用一些簡單的常規、慣例(convention)來取代繁雜的設定(configuration)。這在很多先進的framework廣泛地被應用,目的就是要簡化開發者的工作,免除一些複雜的設定。我個人認為它是一個潮流。
Convention over configuration - Wikipedia
Separation of concerns(關注點分離)
Maven 很強調這一點,除了本身的設計之外(Maven 把一個專案 build life cycle 切成數個 phase),也建議專案可以適當的切割,讓功能(模組)可以重複利用。
補充
Separation of concerns - Wikipedia
軟件工程入門(三) - 天藍工作室
重點分離(Separation of concerns)讓我們可分別專注處理問題的不同重點。在開發大型軟件時這是十分重要的處理手法,我們可以將相關不大的事情分開處理,而分離後就只管集中精神處理相關的東西。
Maven 命名慣例
<artifactId>-<version>.<extension>
例如 commons-logging-1.2.jar
這樣就可以很輕易的瞭解軟體與版本
範例 POM 檔
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
完整的 tag 以及 tag 的描述可以參見 http://maven.apache.org/ref/2.2.1/ma...del/maven.html