maven几个plugins

1、maven-surefire-plugin:单元测试用。用法举例:
Xml代码 复制代码  收藏代码
  1. <plugin>  
  2.                 <groupId>org.apache.maven.plugins</groupId>  
  3.                 <artifactId>maven-surefire-plugin</artifactId>  
  4.                 <version>2.6</version>  
  5.                 <configuration>  
  6.                     <parallel>methods</parallel>  
  7.                     <skipTests>true</skipTests>  
  8.                 </configuration>  
  9.             </plugin>  


2、maven-compiler-plugin:编译插件,方便指定目标JDK版本,以及其他一些编译细节。用法举例:
Xml代码 复制代码  收藏代码
  1. <plugin>  
  2.                     <groupId>org.apache.maven.plugins</groupId>  
  3.                     <artifactId>maven-compiler-plugin</artifactId>  
  4.                     <version>2.3.2</version>  
  5.                     <configuration>  
  6.                         <source>1.6</source>  
  7.                         <target>1.6</target>  
  8.                     </configuration>  
  9.                 </plugin>  



3、maven-antrun-plugin:跑ant脚本的插件,如果原来的ant脚本还有用武之地或者有些工作还是喜欢ant来帮忙的话。用法举例:
Java代码 复制代码  收藏代码
  1. <plugin>   
  2.                 <artifactId>maven-antrun-plugin</artifactId>   
  3.                 <version>1.6</version>   
  4.                 <executions>   
  5.                     <execution>   
  6.                         <phase>generate-sources</phase>   
  7.                         <configuration>   
  8.                             <target name="copy-beans" description="--> copy necessary beans from application">   
  9.                                 <echo message="copy beans from application artifact"/>   
  10.                                 <copy todir="${beans.copy.to.dir}">   
  11.                                     <fileset dir="${beans.copy.from.dir}">   
  12.                                             <include name="**/Resource.java" />   
  13.                                             <exclude name="**/*.xml" />   
  14.                                     </fileset>   
  15.                                 </copy>   
  16.                                    
  17.                             </target>   
  18.                         </configuration>   
  19.                         <goals>   
  20.                             <goal>run</goal>   
  21.                         </goals>   
  22.                     </execution>   
  23.                 </executions>   
  24.             </plugin>  
<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.6</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<configuration>
							<target name="copy-beans" description="--> copy necessary beans from application">
								<echo message="copy beans from application artifact"/>
								<copy todir="${beans.copy.to.dir}">
									<fileset dir="${beans.copy.from.dir}">
											<include name="**/Resource.java" />
											<exclude name="**/*.xml" />
									</fileset>
								</copy>
								
							</target>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

因为我们设计一个applet的子项目,需要拷贝一些资源过来,而不是造成交叉依赖——大家说不定有更好的办法。

4、maven-war-plugin:webapp的必备插件,用来打包war。用法举例:
Xml代码 复制代码  收藏代码
  1. <plugin>  
  2.                 <artifactId>maven-war-plugin</artifactId>  
  3.                 <version>2.1.1</version>  
  4.                 <configuration>  
  5.                     <!-- exclude those which shared lib    
  6.                     <packagingExcludes>  
  7.                         WEB-INF/lib/nric-framework*.jar,   
  8.                         WEB-INF/lib/spring-core*.jar,   
  9.                         WEB-INF/lib/spring-asm*.jar,   
  10.                         WEB-INF/lib/commons-*.jar,   
  11.                         WEB-INF/lib/spring-aop*.jar,   
  12.                         WEB-INF/lib/aopalliance*.jar,   
  13.                         WEB-INF/lib/spring-beans*.jar,   
  14.                         WEB-INF/lib/spring-context*.jar,   
  15.                         WEB-INF/lib/spring-orm*.jar,   
  16.                         WEB-INF/lib/spring-tx*.jar,   
  17.                         WEB-INF/lib/ibatis*.jar,   
  18.                         WEB-INF/lib/oracle*.jar,   
  19.                         WEB-INF/lib/jcl-over-slf4j*.jar,   
  20.                         WEB-INF/lib/slf4j-*.jar,   
  21.                         WEB-INF/lib/javassist*.jar,   
  22.                         WEB-INF/lib/aspectjrt*.jar,   
  23.                         WEB-INF/lib/aspectjweaver*.jar,   
  24.                         WEB-INF/lib/spring-jdbc*.jar,   
  25.                         WEB-INF/lib/log4j*.jar,   
  26.                         WEB-INF/lib/quartz*.jar,   
  27.                         WEB-INF/lib/cglib*.jar,   
  28.                         WEB-INF/lib/asm-*.jar,   
  29.                         WEB-INF/lib/joda-time*.jar   
  30.                     </packagingExcludes>-->  
  31.                     <!-- Use this to include a selection of jars that will be included in the WAR -->  
  32.                     <!--    
  33.                     <packagingIncludes>  
  34.                         **/*.xml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,**/*.jsp,   
  35.                         WEB-INF/lib/spring-web*.jar   
  36.                     </packagingIncludes>  
  37.                     -->  
  38.                     <archive>  
  39.                         <manifest>  
  40.                             <addClasspath>true</addClasspath>  
  41.                             <classpathPrefix>lib/</classpathPrefix>  
  42.                         </manifest>  
  43.                     </archive>  
  44.                 </configuration>  
  45.             </plugin>  

注意:我注释掉的部分一般用来做war减肥用,如果需要打包为ear的话

5、org.mortbay.jetty:jetty调试插件,用来启动web做集成测试、调试用。用法举例:
Xml代码 复制代码  收藏代码
  1. <plugin>  
  2.                 <groupId>org.mortbay.jetty</groupId>  
  3.                 <artifactId>jetty-maven-plugin</artifactId>  
  4.                 <version>7.0.1.v20091125</version>  
  5.                 <configuration>  
  6.                     <scanIntervalSeconds>10</scanIntervalSeconds>  
  7.                     <webAppConfig>  
  8.                         <contextPath>/nric-demo</contextPath>  
  9.                     </webAppConfig>  
  10.                 </configuration>  
  11.             </plugin>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值