您的位置:首页 > 其它

初探maven插件机制

2017-05-26 15:41 405 查看
初探maven插件机制

第一部分 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的介绍。可以作为下一部分的热身.

http://plexus.codehaus.org/writing-components-trail/background.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: