maven 之 插件收集 之一(helper, war, ant, compiler, *)

Maven插件配置指南
本文介绍了Maven中常用的插件配置方法,包括定义源代码目录、生成WAR包、运行Ant任务、编译Java代码、运行测试用例、定义系统语言、生成Javadoc文档以及处理属性文件编码等。

1. 定义java 源代码目录 

<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>add-source</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>mule/java</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>

2. 生成war 包 

<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
						</manifest>
					</archive>
					<webResources>
						<resource>
							<directory>${additionalWebappFolderName}</directory>
						</resource>
					</webResources>
				</configuration>
			</plugin>

3. 运行ant 的插件

<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<configuration>
							<tasks>
								<ant antfile="support/doclet-build.xml" target="${antrun.target}">
									<property name="runtargets" value="${target}" />
								</ant>
							</tasks>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

4. 编译java 代码的插件

<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>${compile.source}</source>
					<target>${compile.target}</target>
					<encoding>${encoding.source}</encoding>
				</configuration>
			</plugin>

5. 运行 TestCase 的插件

<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<includes>
						<include>**/*Test.java</include>
					</includes>
					<excludes>
						<exclude>**/dao/**/*Test.java</exclude>
					</excludes>
					<skip>true</skip>
					<testFailureIgnore>false</testFailureIgnore>
				</configuration>
				<executions>
					<execution>
						<!-- For dao, "forkMode=pertest" is needed to create schema for every 
							dao test -->
						<id>only_dao</id>
						<phase>test</phase>
						<goals>
							<goal>test</goal>
						</goals>
						<configuration>
							<includes>
								<include>**/dao/**/*Test.java</include>
							</includes>
							<excludes>
								<exclude>none</exclude>
							</excludes>
							<forkMode>pertest</forkMode>
						</configuration>
					</execution>
				</executions>
			</plugin>

6. 定义系统语言的插件

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-site-plugin</artifactId>
				<configuration>
					<locales>ja,en</locales>
					<inputEncoding>${encoding.source}</inputEncoding>
					<outputEncoding>${encoding.output}</outputEncoding>
				</configuration>
			</plugin>

7. 生成javadoc 的插件

<plugin>
				<artifactId>maven-javadoc-plugin</artifactId>
				<configuration>
					<charset>${encoding.output}</charset>
					<encoding>${encoding.source}</encoding>
					<docencoding>${encoding.output}</docencoding>
					<linksource>true</linksource>
					<show>private</show>
				</configuration>
			</plugin>

8.  将properties 进行编码插件

<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>native2ascii-maven-plugin</artifactId>
				<configuration>
					<src>${basedir}/src/main/resources</src>
					<dest>${project.build.outputDirectory}</dest>
					<includes>
						<include>*.properties</include>
					</includes>
					<encoding>${encoding.source}</encoding>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>native2ascii</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

转载于:https://my.oschina.net/frankies/blog/69127

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值