Maven

简介: 完全参考手册 还有谁比Nexus的出品公司sonatype更了解Maven的呢?so 戳下面的连接看reference http://books.sonatype.com/mvnref-book/reference/index.html Maven ArcheType ArcheType is a Maven project templating toolkit -  

完全参考手册

还有谁比Nexus的出品公司sonatype更了解Maven的呢?so 戳下面的连接看reference


Maven ArcheType

ArcheType is a Maven project templating toolkit -  http://maven.apache.org/guides/introduction/introduction-to-archetypes.html

Create project from ArcheType -- http://maven.apache.org/archetype/maven-archetype-plugin/usage.html

Create your own ArcheType -- http://maven.apache.org/guides/mini/guide-creating-archetypes.html

Maven 提供的一些ArcheTypes -- http://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
默认,Maven会搜索apache groupId (repository)去匹配与prefix相符的plugin(用上面提到的规则),如果想把自己开发的plugin或第三方plugin也设置为搜索目标,咋办尼?
很简单,在~/.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




目录
相关文章
|
6月前
|
Java Maven
13Maven - Maven小总结
13Maven - Maven小总结
21 0
|
3月前
|
Java 测试技术 数据库连接
Maven
Maven
39 0
|
14天前
|
存储 XML Java
maven
maven
273 0
|
8月前
|
Java 应用服务中间件 Maven
关于Maven,你真的了解它吗?(上)
关于Maven,你真的了解它吗?(上)
|
8月前
|
Java 程序员 数据库连接
Maven的使用
Maven的使用
62 0
|
9月前
|
Java 项目管理 Maven
|
9月前
|
Java Apache 项目管理
maven
Maven 是一个流行的 Java 项目管理工具,它可以帮助开发人员管理项目依赖、构建项目、运行测试、打包和部署项目等。Maven 的主要功能包括:
165 1
|
10月前
|
Java 应用服务中间件 Apache
零基础快速理解Maven
零基础快速理解Maven
|
10月前
|
存储 安全 IDE
【Maven】初识
【Maven】初识
|
11月前
|
存储 Java 测试技术