您的位置:首页 > 运维架构

[maven] Use plugin and develop new plugin

2013-01-10 22:59 381 查看
Maven is a plugin execution platform. At its heart, all work is done by plugins.There are two kinds of plugins: build plugin and reporting plugin.Build plugin will be executed during the build and they should be configured in the <build> element from POM.Here
are the plugin list referred from maven office site: plugin list.In addtion, there are also useful plugins from third party like codehaus: maven
plugin list.

To use a plugin in maven, there are also two ways. One is using the plugin's goal in the command line directly, the other is binding the plugin's goal to life-cycle's phase.I will take Maven Exec Plugin for example to show how to use it in this recipe.

<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
...
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Main</mainClass>
<arguments>
<argument>argument1</argument>
...
</arguments>
<systemProperties>
<systemProperty>
<key>myproperty</key>
<value>myvalue</value>
</systemProperty>
...
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
You can use <phase>clean</phase> inside of <execution> element to run com.example.Main class during clean life-cycle.There is an interesting plugin for Android: https://github.com/jayway/maven-android-plugin. You can use this plugin to build android project if you develop android projects.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: