初探maven插件机制
·
初探maven插件机制
第一部分 Plexus
第一部分 Plexus
本质上说,
Maven是一个
plugin的框架,所以需要有一个管理者来管理这些
plugin。
Maven选择了
Plexus作为
plugin的管理者。作为初探
maven系列的第一部分,我们先简单的了解以一下
Plexus。
Plexus可以被理解为一个
IOC或者
Dependency Injection的框架。
Component则是
Plexus框架所管理的单元。
Plexus本身内建了多个
component供用户(如,
maven)使用
,用户也可以自定义
component。一个
plexus应用程序可以包含多个
component。可以简单的认为
Plexus有点类似
Spring。
使用
Plexus需要用到两种描述符
(Descriptor),plexus.xml和
component.xml。他们都存在于
META-INF/plexus/中。两者都是用于配置
plexus应用或者
compoenent的配置信息。区别在于一个
plexus应用只能含有一个
plexus.xml,却可以包含多个
component.xml(因为每一个
component都有一个
component.xml)。关于
plexus.xml和
component.xml的详细信息可以参考:
http://plexus.codehaus.org/plexus-containers/plexus-container-default/plexus-configuration.html
使用
Plexus重要步骤就是编写
component。可以参考一个
5-minute的教程,快速学习。
http://plexus.codehaus.org/guides/quick-start/getting-started.html
与
maven相关的东西,还有
plexus的三个
annotation。可以参考此处:
http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html
关于
plexus的简单介绍就到这里,东西不是很多。下一部分将介绍
maven插件 –
mojo.
注:在
plexus主页上,有关于编写
mojo时如何使用
component的介绍。可以作为下一部分的热身
.
转载于:https://blog.51cto.com/daition/265157
更多推荐


所有评论(0)