> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iii.-using-spring-boot/13.-build-systems/13.4.-ant.md).

# 13.4. Ant

使用Apache Ant+Ivy构建Spring Boot项目是完全可能的。`spring-boot-antlib` AntLib模块能够帮助Ant创建可执行jars，一个传统的用于声明依赖的`ivy.xml`文件可能如下所示：

```markup
<ivy-module version="2.0">
    <info organisation="org.springframework.boot" module="spring-boot-sample-ant" />
    <configurations>
        <conf name="compile" description="everything needed to compile this module" />
        <conf name="runtime" extends="compile" description="everything needed to run this module" />
    </configurations>
    <dependencies>
        <dependency org="org.springframework.boot" name="spring-boot-starter"
            rev="${spring-boot.version}" conf="compile" />
    </dependencies>
</ivy-module>
```

同样，一个传统的`build.xml`可能是这样的：

```markup
<project
    xmlns:ivy="antlib:org.apache.ivy.ant"
    xmlns:spring-boot="antlib:org.springframework.boot.ant"
    name="myapp" default="build">

    <property name="spring-boot.version" value="2.0.0.RELEASE" />

    <target name="resolve" description="--> retrieve dependencies with ivy">
        <ivy:retrieve pattern="lib/[conf]/[artifact]-[type]-[revision].[ext]" />
    </target>

    <target name="classpaths" depends="resolve">
        <path id="compile.classpath">
            <fileset dir="lib/compile" includes="*.jar" />
        </path>
    </target>

    <target name="init" depends="classpaths">
        <mkdir dir="build/classes" />
    </target>

    <target name="compile" depends="init" description="compile">
        <javac srcdir="src/main/java" destdir="build/classes" classpathref="compile.classpath" />
    </target>

    <target name="build" depends="compile">
        <spring-boot:exejar destfile="build/myapp.jar" classes="build/classes">
            <spring-boot:lib>
                <fileset dir="lib/runtime" />
            </spring-boot:lib>
        </spring-boot:exejar>
    </target>
</project>
```

**注** 如果你不想使用`spring-boot-antlib`模块，那查看[章节 86.9，使用Ant构建可执行存档（不使用spring-boot-antlib）](https://github.com/jack80342/spring-boot/tree/25350df33f8edd68b50ff6f6e1258c9df4f67d67/IX.%20‘How-to’%20guides/86.9%20Build%20an%20Executable%20Archive%20from%20Ant%20without%20Using%20spring-boot-antlib.md)获取更多指导。
