1、maven-surefire-plugin:单元测试用。用法举例:
2、maven-compiler-plugin:编译插件,方便指定目标JDK版本,以及其他一些编译细节。用法举例:
3、maven-antrun-plugin:跑ant脚本的插件,如果原来的ant脚本还有用武之地或者有些工作还是喜欢ant来帮忙的话。用法举例:
因为我们设计一个applet的子项目,需要拷贝一些资源过来,而不是造成交叉依赖——大家说不定有更好的办法。
4、maven-war-plugin:webapp的必备插件,用来打包war。用法举例:
注意:我注释掉的部分一般用来做war减肥用,如果需要打包为ear的话
5、org.mortbay.jetty:jetty调试插件,用来启动web做集成测试、调试用。用法举例:
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <parallel>methods</parallel>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.6</version> <configuration> <parallel>methods</parallel> <skipTests>true</skipTests> </configuration> </plugin>
2、maven-compiler-plugin:编译插件,方便指定目标JDK版本,以及其他一些编译细节。用法举例:
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>
3、maven-antrun-plugin:跑ant脚本的插件,如果原来的ant脚本还有用武之地或者有些工作还是喜欢ant来帮忙的话。用法举例:
- <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>
<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。用法举例:
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
- <configuration>
- <!-- exclude those which shared lib
- <packagingExcludes>
- WEB-INF/lib/nric-framework*.jar,
- WEB-INF/lib/spring-core*.jar,
- WEB-INF/lib/spring-asm*.jar,
- WEB-INF/lib/commons-*.jar,
- WEB-INF/lib/spring-aop*.jar,
- WEB-INF/lib/aopalliance*.jar,
- WEB-INF/lib/spring-beans*.jar,
- WEB-INF/lib/spring-context*.jar,
- WEB-INF/lib/spring-orm*.jar,
- WEB-INF/lib/spring-tx*.jar,
- WEB-INF/lib/ibatis*.jar,
- WEB-INF/lib/oracle*.jar,
- WEB-INF/lib/jcl-over-slf4j*.jar,
- WEB-INF/lib/slf4j-*.jar,
- WEB-INF/lib/javassist*.jar,
- WEB-INF/lib/aspectjrt*.jar,
- WEB-INF/lib/aspectjweaver*.jar,
- WEB-INF/lib/spring-jdbc*.jar,
- WEB-INF/lib/log4j*.jar,
- WEB-INF/lib/quartz*.jar,
- WEB-INF/lib/cglib*.jar,
- WEB-INF/lib/asm-*.jar,
- WEB-INF/lib/joda-time*.jar
- </packagingExcludes>-->
- <!-- Use this to include a selection of jars that will be included in the WAR -->
- <!--
- <packagingIncludes>
- **/*.xml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,**/*.jsp,
- WEB-INF/lib/spring-web*.jar
- </packagingIncludes>
- -->
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <!-- exclude those which shared lib <packagingExcludes> WEB-INF/lib/nric-framework*.jar, WEB-INF/lib/spring-core*.jar, WEB-INF/lib/spring-asm*.jar, WEB-INF/lib/commons-*.jar, WEB-INF/lib/spring-aop*.jar, WEB-INF/lib/aopalliance*.jar, WEB-INF/lib/spring-beans*.jar, WEB-INF/lib/spring-context*.jar, WEB-INF/lib/spring-orm*.jar, WEB-INF/lib/spring-tx*.jar, WEB-INF/lib/ibatis*.jar, WEB-INF/lib/oracle*.jar, WEB-INF/lib/jcl-over-slf4j*.jar, WEB-INF/lib/slf4j-*.jar, WEB-INF/lib/javassist*.jar, WEB-INF/lib/aspectjrt*.jar, WEB-INF/lib/aspectjweaver*.jar, WEB-INF/lib/spring-jdbc*.jar, WEB-INF/lib/log4j*.jar, WEB-INF/lib/quartz*.jar, WEB-INF/lib/cglib*.jar, WEB-INF/lib/asm-*.jar, WEB-INF/lib/joda-time*.jar </packagingExcludes>--> <!-- Use this to include a selection of jars that will be included in the WAR --> <!-- <packagingIncludes> **/*.xml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,**/*.jsp, WEB-INF/lib/spring-web*.jar </packagingIncludes> --> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> </configuration> </plugin>
注意:我注释掉的部分一般用来做war减肥用,如果需要打包为ear的话
5、org.mortbay.jetty:jetty调试插件,用来启动web做集成测试、调试用。用法举例:
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>7.0.1.v20091125</version>
- <configuration>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <webAppConfig>
- <contextPath>/nric-demo</contextPath>
- </webAppConfig>
- </configuration>
- </plugin>
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.0.1.v20091125</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <webAppConfig> <contextPath>/nric-demo</contextPath> </webAppConfig> </configuration> </plugin>