ant

Ant 에서 사용하는 build.xml 설정

jeeyong 2007. 11. 13. 19:34

Ant 에서 사용하는 build.xml 설정

==================================================================================


// 기본구조

<?xml version="1.0" encoding="UTF-8"?>
 <project name="web2004-Project" default="all">
    <property environment="env" />                            //
    <property file="${src.dir}/web2004.properties" />  // 환경설정 파일( file은 name=value 형식 )

    <property name="lib.user.dir"  value="/home" />     // 환경설정을 직접 할수도 있다
 </project> 



// classes path 설정할 수 있다

<path id="classpath.compilation" >                            
    <pathelement location="${lib.user.dir}/hello.jar"/>      
</path>  
  


// Ant 컴파일시 all 의 내용을 찾아 실행시킨다 depends 순서대로

<target name="all" depends="Compile, ftpUpload, EJBcomplie" />



// 자바소스를 컴파일 한다.

// 패키지가 c:\test\ 밑에 hello\com\ 으로 되어있고 소스는 hello.java 일경우

// build.xml 이 소스와 같은 폴더에 있을 경우

// src.dir = .   ,  destdir = c:\test\

<target name="Compile" >
     <javac classpathref="classpath.compilation"       // 위에서 지정한 클래스패스
       destdir="${servlet.source.dir}" debug="true"     // 컴파일시 패스 시작 Dir
       deprecation="false" optimize="true">
       <src path="${src.dir}"/>                                // Source Dir
     </javac>
</target>



// ant 에서 별도 추가 패키지를 설치할면 ftp

// ftp 명령어를 사용할 수 있다.

<target name="ftpUpload" >     

    // 폴더를 만들 수 있다. 폴더는 /a/b/c/d 로 지정할 경우 해당 패스에 모든

    // 경로상의 폴더를 만들어준다.
    <ftp server="${server.ip}"
         port="21"
         userid="${server.userid}"
         password="${server.passwd}"
         remotedir="${server.dir}/testdir"
      action="mkdir"
    />

    // ftp 로 파일을 올린다.
    <ftp server="${server.ip}"
         port="21"
         userid="${server.userid}"
         password="${server.passwd}"
         remotedir="${server.dir}/testdir}"
         depends="yes"                // 같은 파일이 있을 경우 덮어씌운다.
         binary="yes"                    // 바이너리 설정
         listing="data/ftp.listing"
    >
      <fileset dir="${source.dir}">  // 소스 디렉토리
        <include name="*.class"/>  // 소스 디렉토리중 전송할 파일 타입

        <exclude name="*.java"/>   // 소스 디렉토리중 전송을 원치 않는 파일 타입
      </fileset>
    </ftp>
</target>


// EJB 컴파일

// 아래 EJB컴파일은 ejb 에서 필요한 class 파일을 jar 로 묶어주는 부분과

// ejbc 컴파일 하는 두부분으로 구성되어 있다.

<target name="EJBcomplie">
        <jar                                            // jar 로 묶어주는 명령어
            jarfile="${build.dir}/temp.jar"     // 임시 jar, ejb 관련 클래스 파일을 jar로 묶는파일
            basedir="${build.dir}"              // 빌드할 디렉토리 위치
            excludes="**/SP*.class"         // 포함될 파일
        />
        <java classpathref="classpath.compilation"     // 클래스패스
          classname="weblogic.ejbc" fork="yes" >      // ejbc 컴파일
           <arg line="                                              
                ${build.dir}/temp.jar                            // 소스 jar
                ${build.dir}/${ejb.ejbname}.jar             // 만들어질 jar
                "
           />
      </java>
</target>  

출처 : Tong - 妙心主님의 JUnit, Ant, Log4J통