13.4 Ant

Apache Ant + Ivy를 사용하여 Spring Boot 프로젝트를 빌드하는 것이 가능합니다. spring-boot-antlib"AntLib"모듈은 Ant가 실행 가능한 jar를 생성하는 것을 돕기 위해 사용할 수 있습니다. Gradle에서 Spring Boot를 사용하는 방법을 배우려면 Spring Boot의 Gradle 플러그인 설명서를 참조하십시오.

  • Apache Ant : 자바 기반의 빌드 도구. (플랫폼이 상이하더라도 동일한 빌드 환경 제공 / 빌드 환경을 XML 형태로 작성하도록 하여 계층적으로 보기 쉽게 구성되어 있음)

의존성을 선언하기 위해 전형적인 ivy.xml 파일은 다음 예제와 유사합니다.

<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 는 다음 예제와 유사합니다.

<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.4.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 모듈을 사용하고 싶지 않으면, Section 91.9, “Build an Executable Archive from Ant without Using spring-boot-antlib “How-to”을 참조하십시오.

Last updated