Skip to content

Commit c4fbf40

Browse files
authored
Update and rename 13.3. Ant.md to 13.4. Ant.md
1 parent 6849bd4 commit c4fbf40

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

III. Using Spring Boot/13.3. Ant.md

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### 13.4. Ant
2+
3+
使用Apache Ant+Ivy构建Spring Boot项目是完全可能的。`spring-boot-antlib` AntLib模块能够帮助Ant创建可执行jars,一个传统的用于声明依赖的`ivy.xml`文件可能如下所示:
4+
```xml
5+
<ivy-module version="2.0">
6+
<info organisation="org.springframework.boot" module="spring-boot-sample-ant" />
7+
<configurations>
8+
<conf name="compile" description="everything needed to compile this module" />
9+
<conf name="runtime" extends="compile" description="everything needed to run this module" />
10+
</configurations>
11+
<dependencies>
12+
<dependency org="org.springframework.boot" name="spring-boot-starter"
13+
rev="${spring-boot.version}" conf="compile" />
14+
</dependencies>
15+
</ivy-module>
16+
```
17+
同样,一个传统的`build.xml`可能是这样的:
18+
```xml
19+
<project
20+
xmlns:ivy="antlib:org.apache.ivy.ant"
21+
xmlns:spring-boot="antlib:org.springframework.boot.ant"
22+
name="myapp" default="build">
23+
24+
<property name="spring-boot.version" value="1.3.0.BUILD-SNAPSHOT" />
25+
26+
<target name="resolve" description="--> retrieve dependencies with ivy">
27+
<ivy:retrieve pattern="lib/[conf]/[artifact]-[type]-[revision].[ext]" />
28+
</target>
29+
30+
<target name="classpaths" depends="resolve">
31+
<path id="compile.classpath">
32+
<fileset dir="lib/compile" includes="*.jar" />
33+
</path>
34+
</target>
35+
36+
<target name="init" depends="classpaths">
37+
<mkdir dir="build/classes" />
38+
</target>
39+
40+
<target name="compile" depends="init" description="compile">
41+
<javac srcdir="src/main/java" destdir="build/classes" classpathref="compile.classpath" />
42+
</target>
43+
44+
<target name="build" depends="compile">
45+
<spring-boot:exejar destfile="build/myapp.jar" classes="build/classes">
46+
<spring-boot:lib>
47+
<fileset dir="lib/runtime" />
48+
</spring-boot:lib>
49+
</spring-boot:exejar>
50+
</target>
51+
</project>
52+
```
53+
54+
**** 如果你不想使用`spring-boot-antlib`模块,那查看[Section 81.10, “Build an executable archive from Ant without using spring-boot-antlib”](../IX. ‘How-to’ guides/73.8. Build an executable archive with Ant.md)获取更多指导。

0 commit comments

Comments
 (0)