잘되는지는 확인해 보지 않았음. 크게 다를꺼라고 생각하진 않음.
- TSTAMP : 날짜,시간을 위한 TASK
- COPY : 파일 복사를 위한 TASK
- MKDIR : 폴더 생성을 위한 TASK
- JAR : JAR 생성을 위한 TASK
- DELETE : 폴더및 소스 삭제를 위한 TASK
- JAVAC : 컴파일을 위한 TASK
ant_sample.properties
// server info.
server.userid=test
server.pwd=test
server.ip=192.168.10.1
server.port=22
server.dir=/test
// dir info.
dir.webcontent=./WebContent/
dir.lib=./WebContent/WEB-INF/lib/
dir.src=./src/
dir.class=./WebContent/WEB-INF/classes/
dir.build=./build/
dir.dist=./dist/
dir.last=./last/
dir.config=./WebContent/build/WEB-INF/classes/properties/
ant_sample.xml
<!-- default : 기본 선택되어질 target -->
<project default="target5" basedir="." name="ant_sample">
<!-- 설명 -->
<description>
ant full sample
</description>
<!-- property 파일 로딩 -->
<property file="ant_sample.properties" />
<!-- property 세팅 -->
<property name="project_name" location="test" />
<!-- 경로 정보 저장 -->
<path id="compile.classpath">
<fileset dir="${dir.lib}">
<include name="*.jar" />
<include name="*.zip" />
</fileset>
</path>
<!-- 현재 시간과 체크할 시간을 세팅한다 -->
<tstamp>
<!-- now_date에 현재 날짜가 저장된다 -->
<format property="now_date" pattern="yyyy-MM-dd" locale="en,US"/>
<!-- check_date_time에 -100시간이 계산된 날짜와 시간이 저장된다(체크용) -->
<format property="check_date_time" pattern="MM/dd/yyyy hh:mm aaa" locale="en,US" offset="-100" unit="hour"/>
</tstamp>
<!-- target -->
<target name="target1" description="각 폴더 생성">
<echo>target1 start!! - makedir!</echo>
<mkdir dir="${dir.dist}" />
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.last}" />
</target>
<target name="target2" depends="target1" description="컴파일">
<echo>target2 start!! - 컴파일!</echo>
<javac destdir="${dir.class}" encoding="euc-kr" debug="on" >
<src path="${dir.src}"/>
<!-- library loadding -->
<classpath refid="compile.classpath" />
</javac>
</target>
<target name="target3" depends="target2" description="빌드">
<echo>target3 start!! - 빌드!</echo>
<copy todir="${dir.build}">
<fileset dir="${dir.webcontent}">
<include name="/*.*"/>
<include name="css/**"/>
<include name="WEB-INF/**"/>
<exclude name="WEB-INF/classes/properties/application.properties"/>
</fileset>
</copy>
</target>
<target name="target4" depends="target3" description="war 생성">
<echo>target4 start!! - war 생성!</echo>
<war destfile="${dir.dist}/${project_name}.war" webxml="${dir.webcontent}/WEB-INF/web.xml">
<fileset dir="${dir.build}" />
</war>
</target>
<target name="target5" depends="target4" description="최신 변경 파일 정리">
<echo>target5 start!! - 최신 변경 파일 정리!</echo>
<copy todir="${dir.last}" overwrite="false" includeEmptyDirs="false">
<fileset dir="${dir.webcontent}">
<include name="**/*.*"/>
<date datetime="${check_date_time}" when="after"/>
</fileset>
</copy>
</target>
<target name="target6" depends="target5" description="개발 서버 업로드">
<echo>target6 start!! - 서버 업로드</echo>
<move file="${dir.last}WEB-INF/classes/properties/application_dev.properties"
tofile="${dist.last}WEB-INF/classes/properties/application.properties" failonerror="false" verbose="true"/>
<ftp action="put" depends="yes" userid="${server.userid}" password="${server.pwd}" server="${server.ip}" remotedir="${server.dir}">
<fileset dir="${dir.last}">
<include name="**/*.*"/>
<exclude name="WEB-INF/classes/properties/application_real.properties"/>
</fileset>
</ftp>
<echo>FTP Upload Success.</echo>
</target>
<taskdef name="ssh" classname="com.sshtools.ant.Ssh" />
<target name="target7" depends="target6" description="개발 서버 restart!">
<echo>target6 start!! - 서버 restart!</echo>
<ssh host="${server.ip}" port="${server.port}" username="${server.userid}" password="${server.pwd}" version="2">
<exec cmd="cd /server/test" />
<exec cmd="./stop.sh" />
<exec cmd="./start.sh" />
</ssh>
</target>
<target name="target8" description="clean">
<echo>target8 start!! - clean!</echo>
<delete dir="${dir.dist}" />
<delete dir="${dir.build}" />
<delete dir="${dir.last}" />
</target>
'Project' 카테고리의 다른 글
도로명 주소 관련 처리내용 (4) | 2012.05.14 |
---|---|
sql injection tool (1) | 2011.09.21 |
Eclipse Plugin url list (8) | 2011.05.19 |
TOW (Trac On Windows) (2) | 2011.04.05 |
erwin report builder - 테이블 정의서 (3) | 2011.03.17 |