Maven
完全參考手冊
還有誰比Nexus的出品公司sonatype更了解Maven的呢?so 戳下麵的連接看reference
Maven ArcheType
ArcheType is a Maven project templating toolkit - https://maven.apache.org/guides/introduction/introduction-to-archetypes.html
Create project from ArcheType -- https://maven.apache.org/archetype/maven-archetype-plugin/usage.html
Create your own ArcheType -- https://maven.apache.org/guides/mini/guide-creating-archetypes.html
Maven 提供的一些ArcheTypes -- https://maven.apache.org/archetype/maven-archetype-bundles/
Maven Profile
Profile可以讓我們定義一係列的配置信息,然後指定其激活條件。這樣我們就可以定義多個profile,然後每個profile對應不同的激活條件和配置信息,從而達到不同環境使用不同配置信息的效果。
Maven Plugin
引用Plugin ( Referencing Plugin)
可以通過兩種方式應用Plugin,groupId:artifact:version:goal 或者使用plugin的Prefix,例如下麵的兩個command效果是一樣的。
mvn help:describe -Dplugin=compiler -Dmojo=compile -Dfull
mvn org.apache.maven.plugins:maven-help-plugin:2.2:describe -Dplugin=compiler -Dmojo=compile -Dfull
注意在maven中,一個插件目標(Goal)也被認為是一個Mojo
將Plugin加入你的Lifecycle
For example, let's say you have a goal display:time that
echos the current time to the commandline, and you want it to run in the process-test-resources phase to
indicate when the tests were started. This would be configured like so:
... <plugin> <groupId>com.mycompany.example</groupId> <artifactId>display-maven-plugin</artifactId> <version>1.0</version> <executions> <execution> <phase>process-test-resources</phase> <goals> <goal>time</goal> </goals> </execution> </executions> </plugin> ...
怎樣通過Prefix找到你的Plugin (Plugin Prefix Resolution)
By default, Maven will make a guess at the plugin-prefix to be used, by removing any instances of "maven" or "plugin" surrounded by dashes in the plugin's artifact ID. The conventional artifact ID formats to use are:
- maven-${prefix}-plugin - for official plugins maintained by the Apache Maven team itself (you must not use this naming pattern for your plugin, see this note for more informations)
- ${prefix}-maven-plugin - for plugins from other sources
By default, Maven will search the groupId org.apache.maven.plugins for prefix-to-artifactId mappings
很簡單,在~/.m2/settings.xml中加入pluginGroup即可
<pluginGroups> <pluginGroup>com.alibaba.org.apache.maven.plugins</pluginGroup> <pluginGroup>com.alibaba.maven.plugins</pluginGroup> </pluginGroups>
開發自己的Plugin
注意在Plugin命名時,maven-${prefix}-plugin 是Apache的保留方式,具有知識產權,最好不要做違背知識產權的事(infringement)
用${prefix}-maven-plugin
最後更新:2017-04-03 05:39:27