본문 바로가기

Server

서버에 repository 를 통한 배포 및 빌드 방법

1. svn 명령어를 사용해서 repository 생성

 

svn co svn://111.111.111.111/xxxx/trunk /data/repos/xxxx

 

2. config 파일 생성

 

root.dir=/data/repos/Xxx
target.dir=/data/service/Xxx
jsplib.dir=/data/server/www.w.com/lib
jdk.dir=/data/server/jdk1.7.0_07

 

3. build.xml 생성

<project name="examDeploy" default="deploy">
	<target name="init" description="initialize the properties">
        <tstamp>
			<format property="DSTAMP" pattern="yyyyMMdd"/>
		</tstamp>
        <property file="local_config.properties"/>
		
        <property name="src.dir" location="${root.dir}/src"/>
        <property name="build.dir" location="${root.dir}/web/WEB-INF/classes"/>
        <property name="tld.dir" location="${root.dir}/web/WEB-INF/tld"/>
        <property name="lib.dir" location="${root.dir}/web/WEB-INF/lib"/>
        <path id="classpath">
            <fileset dir="${lib.dir}">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="${jsplib.dir}">
                <include name="*.jar"/>
            </fileset>
        </path>

	</target>
    
    <!-- COMPILE -->
    <target name="build" depends="init" description="compile all java sources">
		<echo message="complie wait a minute ...."/>
        <echo message="${build.dir}"/>
		<copy todir="${build.dir}">
			<fileset dir="${src.dir}">
				<include name="**/*.xml"/>
			</fileset>
		</copy>       
        <javac srcdir="${src.dir}" destdir="${build.dir}" 
        	   fork="yes" executable="${jdk.dir}/bin/javac" compiler="javac1.7"
			   deprecation="on" debug="on" includes="**/*.java" encoding="UTF-8" includeantruntime="false">
            <classpath refid="classpath"/>
        </javac>
    </target>

	<target name="deploy" depends="build">
		<copy todir="${target.dir}/WEB-INF/classes">
			<fileset dir="${build.dir}">
				<include name="**/*.class"/>
			</fileset>
		</copy>
		<copy todir="${target.dir}">
			<fileset dir="${root.dir}/web">
				<include name="**/*.jsp"/>
				<include name="**/*.jar"/>
				<include name="**/*.jpg"/>
				<include name="**/*.tld"/>
				<include name="**/*.gif"/>
				<include name="**/*.xml"/>
				<include name="**/*.swf"/>
				<include name="**/*.js"/>
				<include name="**/*.png"/>
				<include name="**/*.css"/>
				<include name="**/*.html"/>
				<include name="**/*.htm"/>
				<include name="**/*.as"/>
				<include name="**/*.fla"/>
				<exclude name="**/*.properties"/> <!-- log4j, local_config exclude-->
			</fileset>
		</copy>
	</target>

</project>

 

4. deploy.sh Shell 파일 생성

 

svn update
if [ "$?" == 0 ]
then
        ant
fi

 

5. 배포시 deploy.sh 실행