maven本質上是一個插件框架,幾乎全部的功能都是經過各類各樣的插件來實現的。maven默認會依據項目類型自動把構建時的各階段(Lifecycle和phase)自動綁定(Lifecycle Mapping)到特定插件(plugin)提供的功能點(goals)上。例如java項目編譯階段(compile),其實是調用了maven-compiler-plugin插件提供的compile功能點(goal)來實現的。html
引用地址: http://www.cnblogs.com/pixy/p/4977550.htmljava
<plugin> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> <!--配置資源文件編碼--> </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> <encoding>utf-8</encoding> <compilerArgument>-Xlint:none</compilerArgument> <compilerArguments> <extdirs>libs</extdirs> <!--使用項目中的jar包--> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <testFailureIgnore>true</testFailureIgnore> <!--測試有失敗用例時,是否繼續構建--> <skipTests>true</skipTests> <!--是否跳過測試階段,方式1--> <skip>true</skip> <!--是否跳過測試階段,方式2--> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <excludes> <!--打包時要排除的文件--> <exclude>agent.properties</exclude> </excludes> <archive> <manifest> <addClasspath>true</addClasspath> <!-- <classpathPrefix>lib/</classpathPrefix> --> <mainClass>com.demo.HelloWorld</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <warName>${project.artifactId}</warName> <webResources> <resource> <!--將額外的jar依賴打入war包--> <directory>libs/</directory> <targetPath>WEB-INF/lib</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> </webResources> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.1.2</version> <executions> <execution> <id>attach-sources</id> <phase>verify</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> <excludeTransitive>false</excludeTransitive> <!--是否排除間接依賴的包--> <stripVersion>true</stripVersion> <!--複製的jar文件是否去掉版本信息--> </configuration> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.6</version> <configuration> <contextPath>/</contextPath> <scanIntervalSeconds>3</scanIntervalSeconds> <scanTargetPatterns> <scanTargetPattern> <directory>src/main/webapp/WEB-INF</directory> <excludes> <exclude>**/*.jsp</exclude> </excludes> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> </scanTargetPattern> </scanTargetPatterns> <requestLog implementation="org.mortbay.jetty.NCSARequestLog"> <filename>target/yyyy_mm_dd.request.log</filename> <retainDays>90</retainDays> <append>true</append> <extended>false</extended> <logTimeZone>GMT</logTimeZone> </requestLog> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>80</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> 複製代碼 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.4</version> <executions> <execution> <goals> <goal>javadoc</goal> </goals> <phase>compile</phase> </execution> </executions> <configuration> <encoding>UTF-8</encoding> <verbose>false</verbose> <show>public</show> <subpackages>com.pwrd.mobileqa.assist.resource</subpackages> <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet> <docletPath>${path.separator}${project.build.outputDirectory}</docletPath> <docletArtifacts> <!--解析項目生成javadoc須要的依賴--> <docletArtifact> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.6.1</version> </docletArtifact> ...... </docletArtifacts> <!-- the following option is required as a work around for version 2.5 of the javadoc plugin which will be used by a maven version > 2.0.9--> <useStandardDocletOptions>false</useStandardDocletOptions> <additionalparam>-output ${project.build.outputDirectory}/resourcedoc.xml</additionalparam> </configuration> </plugin>