달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'팁'에 해당되는 글 1건

  1. 2008.12.26 [Ant] Ant로 SVN 작업 처리하기

업무상 프로젝트 간의 의존성이 있을 경우 다른 SVN에 등록된 프로젝트의 소스를 가져와서 사용해야할 필요가 있었는데, Ant로 SVN작업을 처리하는 방법이 있네요.

먼저 svnant가 필요합니다. svnant는 subclipse 프로젝트에서 제공하고 있습니다. 다운로드는 다음 URL에서 하시면 됩니다.
http://subclipse.tigris.org/svnant.html

# build.properties파일
# -----------------------------------------------------------------------------
# build.properties
# 이 파일은 svnant에서 제공하는 기본 build.xml 파일을 참고해서 다시 만든것입니다.
# -----------------------------------------------------------------------------
svnant.version=1.2.1

# -----------------------------------------------------------------------------
# 필요한 모든 jar파일
# -----------------------------------------------------------------------------
lib.dir=lib

####실제로 필요한 SVN 프로퍼티들 ####
svn.repository.url=https://ksug.googlecode.com/svn/trunk/
svn.project.base.path=SpringReference
svn.username=fromm0
svn.password=1111
# 태그명, 빌드전에 반드시 수정되어야 하는 값
# export하기 위해 사용됨
tag.name=SOME_TAG_NAME_12222008
# 새로운 브랜치명
# 브랜치를 새롭게 생성할 때만 사용됨
new.branch.name=NEW_BRANCH_12222008
####실제로 필요한 SVN 프로퍼티들 ####

# build.xml파일
<?xml version="1.0"?>
<!-- Sample build file used to retrieve svnant's sources -->
<project name="svnant" basedir="." default="checkoutLatest">

    <!--  all properties are in build.properties -->
    <property file="build.properties" />

    <!-- SVN and SVN-ANT Tasks properties -->
    <property name="svn.repository.url" value="${svn.repository.url}" />
    <property name="svn.project.base.path" value="${svn.project.base.path}" />
    <property name="svn.base.url" value="${svn.repository.url}/${svn.project.base.path}" />
    <property name="svnant.javahl" value="false" />
    <property name="svnant.svnkit" value="true" />
    <!-- SVN and SVN-ANT Tasks properties -->


    <!-- path to the svnant libraries. Usually they will be located in ANT_HOME/lib -->
    <path id="svnant.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>

    <!-- load the svn task -->
    <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />

    <target name="clean">
        <delete dir="src_latest" />
    </target>

    <target name="checkoutLatest">
        <svn username="${svn.username}" password="${svn.password}">
            <checkout url="${svn.base.url}" revision="HEAD" destPath="src_latest" />
        </svn>
    </target>

    <!-- *************************************************************** -->
    <!-- tool-availability: Determine if SVN-ANT is available.           -->
    <!-- *************************************************************** -->
    <target name="tool-availability">
        <available resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" property="available.svnant" />
        <echo message="SVN-ANT is available = ${available.svnant}" />
    </target>


    <!-- **************************************************************** -->
    <!-- does-svnant-exist: depends on tool-availablility and     -->
    <!--                    displays error message                                   -->
    <!-- ***************************************************************** -->
    <target name="does-svnant-exist" depends="tool-availability">
        <fail unless="available.svnant">
      SVN-ANT is not available, cannot perform tagging or checkout/export svn ant task.
     </fail>
    </target>


    <!-- ****************************************************************** -->
    <!-- svntag: performs tagging using properties from                              -->
    <!--         build.properties and uses SVNANT tasks                              -->
    <!-- ******************************************************************* -->
    <target name="svntag" description="tags individual project using svnant task">
        <property name="svn.tag.message" value="Tagging Project ${project.name} with tag name ${tag.name} from trunk " />
        <property name="src.url" value="${svn.base.url}/${project.name}/trunk/" />
        <property name="dest.url" value="${svn.base.url}/${project.name}/tags/${tag.name}" />

        <echo message="${svn.tag.message}" />
        <echo message="${src.url}" />
        <echo message="${dest.url}" />

        <svn javahl="${svnant.javahl}" svnkit="${svnant.svnkit}" username="${svn.username}" password="${svn.password}">
            <copy srcUrl="${src.url}" destUrl="${dest.url}" message="${svn.tag.message}" />
        </svn>
    </target>


    <!-- ****************************************************************** -->
    <!-- svnexport: performs export using properties from                            -->
    <!--            build.properties and uses SVNANT tasks                           -->
    <!-- ****************************************************************** -->
    <target name="svnexport" description="exports individual project using svnant task">
        <property name="svn.tag.message" value="Exporting Project ${project.name} with tag name ${tag.name}" />
        <property name="src.url" value="${svn.base.url}/${project.name}/tags/${tag.name}" />
        <property name="destPath" value="${dest.path}" />
        <echo message="${svn.tag.message}" />
        <svn javahl="${svnant.javahl}" svnkit="${svnant.svnkit}" username="${svn.username}" password="${svn.password}">
            <export srcUrl="${src.url}" destPath="${destPath}/${project.name}" />
        </svn>
    </target>

    <!-- ****************************************************************** -->
    <!-- svnbranch: creates a new branch using properties from                       -->
    <!--            build.properties and uses SVNANT tasks                           -->
    <!-- ****************************************************************** -->
    <target name="svnbranch" description="creates a new branch for individual project using svnant task">

        <property name="svn.branch.message" value="Creating new branch for
    Project ${project.name} with new branch name ${new.branch.name} from
    trunk" />
        <property name="src.url" value="${svn.base.url}/${project.name}/trunk/" />
        <property name="dest.url" value="${svn.base.url}/${project.name}/branches/${new.branch.name}" />

        <echo message="${svn.branch.message}" />
        <echo message="${src.url}" />
        <echo message="${dest.url}" />

        <svn javahl="${svnant.javahl}" svnkit="${svnant.svnkit}" username="${svn.username}" password="${svn.password}">
            <copy srcUrl="${src.url}" destUrl="${dest.url}" message="${svn.branch.message}" />
        </svn>
    </target>
</project>

현재 필요한 기능은 실제 최신 버전의 체크아웃이라 checkoutLatest만 해봤는데 잘됩니다. ^^
Posted by fromm0
|