例如: 

<target name="callProjectB">
  <echo message="In projectA calling projectB"/>         
    <ant antfile="subfile/projectB.xml" /> 
</target>

说明:项目A通过ant命令执行项目B

属性:

(1) antfile : 指定要执行的构建文件名称,可以包含路径信息。

(2) dir : 指定构建文件所在的目录,相当于指定了要执行的构建文件的basedir属性,如果dir属性没有设置,会以当前构建文件的根目录作为ant任务的根目录。

(3) Target:指定要执行的构建文件要执行的target。例如

<project name="porjectA" default="callProjectB">   

     <target name="callProjectB">        

          <echo message="In projectA calling projectB"/>                

           <ant antfile="subfile/projectB.xml" target=" target2"/>    

     </target>

</project>
View Code

相关文章: