springboot官方文档翻译(十二):gradle&ant 13.4 Ant

1
2
To learn about using Spring Boot with Gradle, please refer     
to the documentation for Spring Boot’s Gradle plugin:

学习在Spring Boot中使用Gradle请转到如下Spring Boot的Gradle插件关联文档中:
https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/gradle-plugin/reference/html/)

13.4 Ant

1
2
3
4
5
It is possible to build a Spring Boot project using Apache Ant+Ivy.     
The spring-boot-antlib “AntLib” module is also available to help
Ant create executable jars.
To declare dependencies, a typical ivy.xml file looks something
like the following example:

您同样可以使用Apache的Ant配合Ivy去构建Spring Boot工程。spring-boot-antlib 的“AntLib”模块同样可以帮助Ant创建可执行的jars包。
声明依赖,一个典型的ivy.xml文件如下:

1
2
3
4
5
6
7
8
9
10
11
<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>

1
A typical build.xml looks like the following example:

一个典型的build.xml如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<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.1.0.BUILD-SNAPSHOT" />

<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>
1
2
3
If you do not want to use the spring-boot-antlib module,     
see the Section 86.9, “Build an Executable Archive from
Ant without Using spring-boot-antlib” “How-to” .

如果您不想使用spring-boot-antlib模块,请直接看章节86.9“Build an Executable Archive from Ant without Using spring-boot-antlib”