maven 创建版本文件

需要每次打包的时候新建一个版本文件(eg:build.jsp)

1.创建模板版本文件:buildVersion.txt

@VERSIONID@.@PACKTIME@

2.追加maven-antrun-plugin组件:pom.xml

<plugin>
	<groupId>org.eclipse.m2e</groupId>
	<artifactId>lifecycle-mapping</artifactId>
	<version>1.0.0</version>
	<configuration>
		<lifecycleMappingMetadata>
			<pluginExecutions>
				<pluginExecution>
					<pluginExecutionFilter>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<versionRange>[1.8,)</versionRange>
						<goals>
							<goal>compile</goal>
							<goal>run</goal>
						</goals>
					</pluginExecutionFilter>
					<action>
						<ignore />
					</action>
				</pluginExecution>
			</pluginExecutions>
		</lifecycleMappingMetadata>
	</configuration>
</plugin>

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-antrun-plugin</artifactId>
	<version>1.8</version>
	<executions>
		<execution>
			<phase>compile</phase>
			<goals>
				<goal>run</goal>
			</goals>
			<configuration>
				<target>
					<echo message="******update version.jsp******" />
					<tstamp>
						<format property="TimeSign" pattern="yyMMddHHmmss" />
					</tstamp>
					<copy file="src/main/resources/buildVersion.txt"
						tofile="src/main/webapp/WEB-INF/view/build.jsp"
						overwrite="true" />
					<replace file="src/main/webapp/WEB-INF/view/build.jsp"
						summary="true" token="@PACKTIME@" value="${TimeSign}" />
					<replace file="src/main/webapp/WEB-INF/view/build.jsp"
						summary="true" token="@VERSIONID@" value="1.1" />
				</target>
			</configuration>
		</execution>
	</executions>
</plugin>

这里如果没有指定版本号,eclipse出现以下报错 但并不影响正常执行:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.8:run (execution: default, phase: compile)    pom.xml   Maven Project Build Lifecycle Mapping Problem
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值