반응형
[build.xml]
<project name="프로젝트명" default="deploy" basedir="." >
<!-- 애플리케이션 이름과 데모서버 war파일 위치 경로등 설정 -->
<property name="app.name" value="애플리케이션 이름" />
<property name="demo.target" value="/war파일 위치경로" />
<property name="build.classpath" value="c:/java/build_lib" />
<!-- 클래스패스를 설정 -->
<path id="classpath">
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<!-- javadoc생성을 위한 추가 클래스 패스 -->
<fileset dir="${build.classpath}">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<tstamp />
</target>
<!-- war파일 생성을 위해 deploy용 디렉토리를 생성한다 -->
<target name="prepare" description="Creates the Web Application's war directory" depends="init">
<echo message="Creating ${app.name}'s war directory ..." />
<mkdir dir="${basedir}/deploy" />
<mkdir dir="${basedir}/deploy" />
<mkdir dir="${basedir}/deploy/WebContent/WEB-INF" />
<mkdir dir="${basedir}/deploy/WebContent/WEB-INF/classes" />
<mkdir dir="${basedir}/deploy/WebContent/apidoc" />
</target>
<target name="build" description="Builds the Web Application" depends="prepare">
<!-- java 소스를 classes 폴더로 컴파일한다. -->
<echo message="Building ${app.name} ..." />
<javac srcdir="${basedir}/src" destdir="${basedir}/deploy/WebContent/WEB-INF/classes" encoding="utf-8">
<include name="**/*.java" />
<classpath refid="classpath" />
</javac>
<!-- class path에 위치해야 하는 resource파일들을 복사한다. -->
<echo message="Resource File Copy .." />
<copy todir="${basedir}/deploy/WebContent/WEB-INF/classes">
<fileset dir="${basedir}/src">
<include name="**/*.properties" />
<include name="**/*.dtd" />
<include name="**/*.xml" />
</fileset>
</copy>
<!-- Web 관련 파일들을 복사한다 -->
<echo message="WebContent Copy .." />
<copy todir="${basedir}/deploy/WebContent">
<fileset dir="${basedir}/WebContent">
<include name="**/*" />
</fileset>
</copy>
<!-- 서버의 설정이 저장된 설정파일로 교체한다.-->
<echo message="Config file replace .." />
<copy file="${basedir}/deploy/WebContent/WEB-INF/config/xxx_dev.xml"
tofile="${basedir}/deploy/WebContent/WEB-INF/config/xxx.xml" overwrite="yes"/>
</target>
<!-- app.name으로 war파일을 생성한다.-->
<target name="package" description="Packages the Web Application's web archive file" depends="build">
<echo message="Packaging ${app.name}'s web archive file ..." />
<delete file="${basedir}/deploy/${app.name}.war" />
<jar jarfile="${basedir}/deploy/${app.name}.war">
<fileset dir="${basedir}/deploy/WebContent" includes="**" />
</jar>
<delete dir="${basedir}/deploy/WebContent" />
</target>
<!-- war파일을 데모서버에 ftp로 업로드하고 deploy디렉토리를 삭제한다.-->
<target name="deploy" description="Deploys the Web Application" depends="package">
<echo message="Deploying Web Application Server ${app.name} ..." />
<ftp server="xxx.xxx.xxx.xxx"
userid="xxx"
password="xxx"
remotedir="${demo.target}" >
<fileset dir="${basedir}/deploy"/>
</ftp>
</target>
<!-- javadoc을 WebContent의 apidoc디렉토리에 생성한다.-->
<target name="javadoc" description="Create Javadoc API documentation">
<echo message="Create ${app.name} Java Doc ..." />
<javadoc sourcepath="./src" destdir="${basedir}/deploy/WebContent/apidoc" encoding="UTF-8"
stylesheetfile="${basedir}/WebContent/css/site.css" docencoding="UTF-8" charset="UTF-8" packagenames="*">
<classpath refid="classpath" />
<doctitle><![CDATA[<h1>xxx API</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright © xxx All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
</project>
728x90
반응형
댓글