maven常用插件配置
1、maven-jar-plugin插件
<!-- 排除资源文件中的properties文件,不需要打到jar中,后面通过assembly插件打包到conf目录中 -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.conf</exclude>
</excludes>
</configuration>
</plugin>
这个插件通常不需要手动指定,默认mvn install 的时候就会运行,但是如果想排除某些资源文件,就需要手动指定一下了
2、maven-dependency-plugin
<plugin>
<!-- maven-dependency-plugin 会拷贝所有依赖的jar包,包括传递依赖的jar包都会拷贝 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
maven默认是不理会项目所依赖的jar包的,但是如果要发布项目,需要通过maven-dependency-plugin将项目所依赖的jar包输出到lib目录;
maven-dependency-plugin 会拷贝所有依赖的jar包,包括传递依赖的jar包都会拷贝,比如项目依赖于a.jar,而a.jar的项目依赖b.jar,c.jar,
那么maven-dependency-plugin会将a.jar,b.jar,c.jar一起拷贝到项目的lib目录
3、如果项目要发布源码,需要用到maven-source-plugin
<!-- Source attach plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
4、maven-release-plugin
<!-- package release plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
这个插件暂时还不知道有什么用
5、maven-Javadoc-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
6、maven-war-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>**/*.jpg</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
这个插件通常不需要手动指定,默认mvn install 的时候就会运行,但是如果想排除某些资源文件,就需要手动指定一下了
tomcat插件
资料: http://iffiffj.iteye.com/blog/1661936<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/</path>
<port>80</port>
<uriEncoding>UTF-8</uriEncoding>
<url>http://localhost/manager/text</url>
<server>tomcat6</server>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<path>/</path>
<port>80</port>
<uriEncoding>UTF-8</uriEncoding>
<url>http://localhost/manager/text</url>
<server>tomcat6</server>
</configuration>
</plugin>代码规范检查插件<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>my_check.xml</configLocation>
</configuration>
</plugin>
my_check.xml : https://git.oschina.net/it-much/dubbo-demo/blob/master/dubbo-parent/my_check.xml?dir=0&filepath=dubbo-parent%2Fmy_check.xml&oid=8c10ce5ce32148fba20c847cbf5baf310f7826f2&sha=57d2861736831834d7d16a3c61c315b6dde14bda
http://zheng12tian.iteye.com/blog/1771040
http://www.cnblogs.com/Binhua-Liu/p/5604841.html