`
heipark
  • 浏览: 2077096 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用maven打war包过程中对文件进行copy、rename(move)、delete操作

    博客分类:
  • Java
 
阅读更多
  1. 在pom中声明ant插件:maven-antrun-plugin
  2. 设置ant在maven哪个"phase"和“goal”执行
  3. 编写ant task
  4. 在pom文件声明package类型为war包:<packaging>war</packaging>
  5. 打包:mvn clean  package 或者 mvn clean  package -DskipTests=true

下面是我程序中使用的片段,在打war包同时将线上的jdbc文件替换开发使用的jdbc文件。

 

 

			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<phase>compile</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<tasks>
								<delete file="${project.build.directory}/classes/jdbc.properties" />
								<move file="${project.build.directory}/classes/online_jdbc.properties" tofile="${project.build.directory}/classes/jdbc.properties"/>
							</tasks>
						</configuration>
					</execution>
				</executions>
			</plugin>
 

 

ant task:http://ant.apache.org/manual/tasksoverview.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics