aping_server/build.xml
2022-09-10 20:45:14 +08:00

50 lines
2.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="app-build" default="start" basedir=".">
<!--默认是dev-->
<property name="spring.profiles.active" value="dev"/>
<target name="start" description="入口" depends="jvm_option"></target>
<target name="jvm_option" description="在jvm.option文件中指定环境参数" depends="check">
<echo>===>jvm.options 修改 -Dspring.profiles.active=${spring.profiles.active}</echo>
<replace file="cicd/k8s/docker/app/jvm.options" token="spring.profiles.active=dev" value="spring.profiles.active=${spring.profiles.active}"/>
<replace file="cicd/k8s/docker/app/jvm.options" token="spring.profiles.active=test" value="spring.profiles.active=${spring.profiles.active}"/>
<replace file="cicd/k8s/docker/app/jvm.options" token="spring.profiles.active=prod" value="spring.profiles.active=${spring.profiles.active}"/>
<echo>===>jvm.options 修改 -Djasypt.encryptor.password=${jasypt.encryptor.password}</echo>
<replace file="cicd/k8s/docker/app/jvm.options" token="jasypt.encryptor.password=dev" value="jasypt.encryptor.password=${jasypt.encryptor.password}"/>
<replace file="cicd/k8s/docker/app/jvm.options" token="jasypt.encryptor.password=test" value="jasypt.encryptor.password=${jasypt.encryptor.password}"/>
<replace file="cicd/k8s/docker/app/jvm.options" token="jasypt.encryptor.password=prod" value="jasypt.encryptor.password=${jasypt.encryptor.password}"/>
</target>
<target name="check" description="检查war文件是否存在" depends="maven_build">
<available file="cicd/k8s/docker/app/apps/app.war" property="app.exist" description="检查app war包是否存在"/>
<echo>cicd/k8s/docker/app/apps war file exists:${app.exist}</echo>
</target>
<target name="maven_build" description="通过源码构建应用包" unless="nocompile">
<condition property="isWindows">
<os family="windows"/>
</condition>
<antcall target="windows_build"></antcall>
<antcall target="linux_build"></antcall>
</target>
<target name="windows_build" if="isWindows">
<echo>===>当前执行mvn的操作系统:Windows</echo>
<property name="maven.executor" value="cmd.exe"/>
<exec executable="${maven.executor}">
<arg line="/c mvn clean package -Dmaven.test.skip=true -P${spring.profiles.active} --settings- settings-${spring.profiles.active}.xml"/>
</exec>
</target>
<target name="linux_build" unless="isWindows">
<echo>===>当前执行mvn的操作系统:Linux</echo>
<property name="maven.executor" value="/bin/bash"/>
<echo>===>mvn构建</echo>
<exec executable="${maven.executor}">
<arg line="-c &quot; mvn -f pom.xml package -Dmaven.test.skip=true -P${spring.profiles.active} --settings settings-${spring.profiles.active}.xml &quot;"/>
</exec>
</target>
</project>