使用单个目标和单个命令构建多个环境(Anding -D和属性文件)

时间:2021-07-30 23:11:30

I have to create a single command to create multiple(dev|qa|uat) war/ear. Something like :

我必须创建一个命令来创建多个(dev | qa | uat)war / ear。就像是 :

ant -f build.xml -Denv=dev|qa|uat -propertyfile= devProp|qaProp|uatProp 
  -Dstage.dir=devdir|qadir|uatdir

I already have different properties file, different staging, deploying target for each environment. I also have different .cmd files to build each of them separately.

我已经有不同的属性文件,不同的登台,为每个环境部署目标。我也有不同的.cmd文件来分别构建它们。

What I am stuck at is: How do I build them all in one go?

我坚持的是:我如何一次性构建它们?

1 个解决方案

#1


0  

You can use the <subant /> instruction in your target.

您可以在目标中使用 指令。

Write down a new ant script (namely master.xml), assuming that your original build is in script build.xml, you can have something like:

记下一个新的ant脚本(即master.xml),假设您的原始构建位于脚本build.xml中,您可以使用以下内容:

<target name="build-all">
   <subant target="build-prod">
     <fileset dir="." includes="build.xml"/>
     <propertyset ......../> <!-- properties for the prod build -->
   </subant>
   <subant target="build-dev">
     <fileset dir="." includes="build.xml"/>
     <propertyset ......../> <!-- properties for the dev build -->
   </subant>
</target>

#1


0  

You can use the <subant /> instruction in your target.

您可以在目标中使用 指令。

Write down a new ant script (namely master.xml), assuming that your original build is in script build.xml, you can have something like:

记下一个新的ant脚本(即master.xml),假设您的原始构建位于脚本build.xml中,您可以使用以下内容:

<target name="build-all">
   <subant target="build-prod">
     <fileset dir="." includes="build.xml"/>
     <propertyset ......../> <!-- properties for the prod build -->
   </subant>
   <subant target="build-dev">
     <fileset dir="." includes="build.xml"/>
     <propertyset ......../> <!-- properties for the dev build -->
   </subant>
</target>