码迷,mamicode.com
首页 > 其他好文 > 详细

Maven项目中依据条件进行打包war包

时间:2015-03-28 15:47:12      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

<?xml version="1.0"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<properties>
		<mariadb-version>1.1.7</mariadb-version>
		<mysql-version>5.1.25</mysql-version>
		<package.target>notexists</package.target>
		<deploy.include>src/main/deploy</deploy.include>
		<dev.jspath>js/dev</dev.jspath>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
	</properties>
	<profiles>
		<profile>
			<id>nas</id>
			<properties>
				<package.target>nas</package.target>
			</properties>
			<dependencies>
				<dependency>
					<groupId>org.mariadb.jdbc</groupId>
					<artifactId>mariadb-java-client</artifactId>
					<version>${mariadb-version}</version>
					<exclusions>
						<exclusion>
							<groupId>net.java.dev.jna</groupId>
							<artifactId>jna</artifactId>
						</exclusion>
					</exclusions>
				</dependency>
			</dependencies>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-war-plugin</artifactId>
						<version>2.6</version>
						<configuration>
							<packagingExcludes>WEB-INF/lib/mysql-connector-java*.jar</packagingExcludes>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>testCust</id>
			<properties>
				<package.target>testCust</package.target>
			</properties>
		</profile>
	</profiles>

	<build>
		<finalName>webProject</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<warName>${project.build.finalName}-${project.version}-${package.target}-${maven.build.timestamp}</warName>
					<warSourceExcludes>${dev.jspath}/**</warSourceExcludes>
					<webResources>
						<resource>
							<targetPath>WEB-INF</targetPath>
							<directory>${deploy.include}/${package.target}</directory>
							<includes>
								<include>*.xml</include>
							</includes>
						</resource>
					</webResources>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.7</version>
				<executions>
					<execution>
						<id>copy-resources_properties</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.outputDirectory}</outputDirectory>
							<resources>
								<resource>
									<directory>${deploy.include}/${package.target}</directory>
									<includes>
										<include>**/*.properties</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>


maven命令后面添加-P+id 就可以进行触发不同的配置信息

Maven项目中依据条件进行打包war包

标签:

原文地址:http://blog.csdn.net/heardy/article/details/44701699

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!