ant 简单例子

发布时间 2023-06-01 17:12:49作者: zno2

和Maven类似,ant有一个 build.xml 文件

一个 pom.xml 代表一个 Maven项目

一个build.xml 代表一个ant项目

<project name="MyProject" default="clean" basedir=".">
  <description>
    simple example build file
  </description>
  <!-- set global properties for this build -->
  <property name="target" location="target"/>

  <target name="clean" description="clean up">
    <delete dir="${target}"/>
  </target>
</project>

这个location 是basedir 的相对路径

test/build.xml

test/target

cd 到 test 执行 ant 

会删除target 文件夹

执行结果:

F:\test>ant
Buildfile: F:\test\build.xml

clean:
   [delete] Deleting directory F:\test\target

BUILD SUCCESSFUL
Total time: 0 seconds

 

 

https://ant.apache.org/manual/tasklist.html

https://ant.apache.org/manual/Tasks/delete.html