标签:ja
1、maven-jar-plugin插件
<build> <plugins> <!-- 排除资源文件中的properties文件,不需要打到jar中,后面通过assembly插件打包到conf目录中 --> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <excludes> <exclude>**/*.properties</exclude> <exclude>**/*.xml</exclude> <exclude>**/*.conf</exclude> </excludes> <fileNameMapping>no-version</fileNameMapping> </configuration> </plugin> </plugins> </build>
这个插件通常不需要手动指定,默认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 的时候就会运行,但是如果想排除某些资源文件,就需要手动指定一下了
本文出自 “小鱼的博客” 博客,谢绝转载!
标签:ja
原文地址:http://395469372.blog.51cto.com/1150982/1787489