[인터돌™] 공부 해보자!! 열심히~~~

퍼포스에서 웹프로젝트 소스를 다운받아서 최종적으로 war 파일을 만드는 ANT 빌드 스크립트 샘플


build4Web.properties

#
target.vm.version=1.5

# 작업 홈 디렉토리
work.home.dir=/home3/testuser/work

# WAS(톰캣)의 홈 디렉토리
was.home=/usr/share/tomcat6

# java 소스의 디렉토리
src.dir=/home3/testuser/work/source

# java 소스의 디렉토리 (appl)
src.appl.dir=/home3/testuser/work/appl

# 설정파일이 존재하는 디렉토리
allconfig.dir=/home3/testuser/work/allconfig

# 컴파일 된 파일, 설정파일 등의 작업이 일어나는 디렉토리
dist.dir=/home3/testuser/work/Mobiledesk

# 최종 생성된 WAR 파일이 저장되는 디렉토리. 허드슨에서 사용하는 deploy 경로로 설정
#deploy.dir=/home3/testuser/deploy
deploy.dir=/home/CTIP/HUDSON/jobs/testProject/workspace

# 최종 생성된 WAR 파일의 파일명
war.name=WebProject.war




build4Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="WebProject" basedir="." default="all">

    <property file="build4Web.properties" />

    <path id="project.classpath">
        <pathelement location="./svnjavahl.jar" />
        <pathelement location="./svnant.jar" />
        <pathelement location="./svnClientAdapter.jar" />
    </path>

    <!-- property define -->
    <property name="work.home" value="${work.home.dir}" />
   
    <property name="dist" value="${dist.dir}" />
    <property name="dist.webinf" value="${dist}/WEB-INF" />
    <property name="dist.webinf.lib" value="${dist}/WEB-INF/lib" />
    <property name="dist.webinf.classes" value="${dist}/WEB-INF/classes" />
    <property name="dist.webinf.resource" value="${dist}/WEB-INF/resouce" />
    <property name="dist.webinf.sync" value="${dist}/WEB-INF/sync" />

    <property name="src" value="${src.dir}" />
    <property name="src.appl" value="${src.appl.dir}" />
    <property name="src.web" value="${src}/webapps" />
    <property name="src.classes" value="${src}/classes" />
    <property name="allconfig" value="${allconfig.dir}" />
   


    <taskdef resource="svntask.properties" classpathref="project.classpath" />

    <!-- ant -f build4Web.xml all -->
    <target name="all" depends="checkout, compile, copyresource , changepermission">
        <war basedir="${dist}" destfile="${deploy.dir}/${war.name}" update="false" />
    </target>

    <!-- 01.Clean Dircctory -->
    <target name="clean">
        <echo message="##### Delete the Build and Dist Directory #####" />

        <delete dir="${work.home}" />
        <mkdir dir="${work.home}" />
        <chmod dir="${work.home}" perm="777"/>
    </target>

    <!-- 02.Latest Source Download from P4 Server  -->
    <target name="checkout" depends="clean">
        <echo message="##### Latest Source Download from Perforce Server #####" />

        <exec executable="/home/perforce/p4v/bin/p4">
            <arg value="-c" />
            <arg value="Perforce_Work_Space" />
            <arg value="-p" />
            <arg value="192.168.111.222:6001" />
            <arg value="-u" />
            <arg value="perforceuser" />
            <arg value="-P" />
            <arg value="perforcepassword" />
            <arg value="sync" />
            <arg value="-f" />
        </exec>
    </target>

    <!-- 03. Make classes directory -->
    <target name="init">
        <echo message="##### Make classes directory #####" />

        <tstamp>
            <format property="buildTime" pattern="yyyyMMddhhmm" />
        </tstamp>

        <mkdir dir="${dist.webinf.classes}" />

    </target>

    <path id="classpath">
        <fileset dir="${dist.webinf.lib}">
            <include name="**/*.jar" />
        </fileset>
        <pathelement location="${was.home}/lib/*.jar" />
    </path>

    <!-- 04. compile java file -->
    <target name="compile" depends="init">
        <echo message="##### compile java file #####" />

        <javac failonerror="true" srcdir="${src}" destdir="${dist.webinf.classes}"
            classpathref="classpath" target="${target.vm.version}" debug="on"
            includeantruntime="false" includejavaruntime="false" encoding="UTF-8" />
        <javac failonerror="true" srcdir="${src.appl}" destdir="${dist.webinf.classes}"
            classpathref="classpath" target="${target.vm.version}" debug="on"
            includeantruntime="false" includejavaruntime="false" encoding="UTF-8" />
    </target>

    <!-- 05. copy resource(config etc.) file -->
    <target name="copyresource" depends="init">
        <echo message="##### copy resource(config etc.) file #####" />

        <copy todir="${dist.webinf.classes}" overwrite="true">
            <fileset dir="${allconfig}">
                <include name="**/*" />
            </fileset>
        </copy>

    </target>


    <!-- 06. Change "work" directory permission -->
    <target name="changepermission">
        <echo message="##### Change work directory permission #####" />

        <chmod perm="777" parallel="true">
            <dirset dir="${work.home}">
                <include name="**/**"/>
            </dirset>
        </chmod>
    </target>
</project>




이 글을 공유합시다

facebook twitter googleplus kakaoTalk kakaostory naver band

본문과 관련 있는 내용으로 댓글을 남겨주시면 감사하겠습니다.

비밀글모드