ant 사용법

|
아래 내용은 
고수로 가는 지름길! Jakarta Project
이클립스 기반 프로젝트 필수 유틸리티: CVS, Ant, JUnit
두 책의 ant 부분을 보고 정리하였습니다.

# build.xml 파일의 기본구조
<?xml version="1.0" encoding="euc-kr"?>
<project name="projectName" default="defaultTargetName" basedir=".">
 <property name="" location=""/>
 <target name="">...</target>
 <target name="" depends="">...</target>
 <target name="" depends="">...</target>  
 <target name="" depends="" if="">...</target> 
 <target name="" depends="" unless="">...</target>  
</project>

# project 태그 
 1) name : 프로젝트의 이름 
 2) default : Ant를 실행할때 target을 지정하지 않은 경우 기본적으로 사용할 target (필수)
 3) basedir : 경로 계산할때의 기준 디렉토리. 지정하지 않은 경우 현재 디렉토리가 basedir로 사용된다. basedir 프로퍼티의 값으로도 사용된다.

# target 태그
 1) name : 타켓의 이름 (필수)
 2) depends : 이 타겟이 의존하고 있는 타겟의 목록. 각 타켓의 이름은 ,(콤마) 로 구분한다.
 3) if : 지정한 프로퍼티가 설정되어 있는 경우 이 타겟을 수행한다.
 4) unless : 지정한 프로퍼티가 설정되어 있지 않은 경우 이 타겟을 수행한다.
 5) description : 타겟이 수행하는 기능에 대한 설명
 
# ant 경로 규칙 
 1) * : 0개 또는 그이상의 글자가 매칭
 2) ? : 한글자와 매칭 
 3) ** : 다계층을 나타냄  예) dir/**/A => dir/dir1/A, dir/dir2/A, dir/dir1/dirA/A 다 포함.
 4) / 또는 \ 으로 끝날 경우  : /** 또는 \** 과 동일
 
# includes 속성 : 포함시킬 파일의 목록 (include 태그, includesfile 속성으로 사용 가능)

# excludes 속성 : 제외시킬 파일의 목록 (exclude 태그, excludesfile 속성으로 사용 가능)

# excludes 속성 명시 여부에 상관없이 제외 되는 것들 : 제외 시키고 싶지 않을 경우 defaulteexcludes = "no" 설정
 - **/*~, **/#*#, **/.#*, **/%*%, **/._*
 - **/CVS, **/CVS/**, **/.cvsignore
 - **/SCCS, **/SCCS/**
 - **/vssver.scc
 - **/.svn, **/.svn/**
 - **/.DS_Store

# fileset 태그 : 파일 집합
 1) dir : 파일 집합을 표시할 때의 루트 디렉토리 (dir 또는 file 중 한개 반드시 명시)
 2) file : 한 개의 파일을 명시할 때 사용하는 속성  (dir 또는 file 중 한개 반드시 명시)
 3) casesensitive : 대소분자 구분 여부 (true/false) 기본값 true
 4) followsymlinks : 심볼릭 링크를 따라갈지의 여부 (true/false) 기본값 true)
  사용 예)
 <fileset dir="${basedir}/src" defaultexcludes="no">
  <include name="**/*.java"/>
  <include name="**/*.properties"/>
  <exclude name="**/*.bak"/>
 </fileset>

# dir 태그 : 디렉토리 집합
 1) dir : 디렉토리 집합을 표시할 때의 루트 디렉토리 (필수)
 2) casesensitive : 대소분자 구분 여부 (true/false) 기본값 true
 3) followsymlinks : 심볼릭 링크를 따라갈지의 여부 (true/false) 기본값 true)
  사용 예)
 <dirset dir="" includes="" excludes=""/>
 
# patternset 태그 : 재사용 가능한 파일 집합
 사용 예)
 <patternset id="commonJar">
  <include name="servlet.jar"/>
  <include name="mail.jar"/>
  <include name="activation.jar"/>    
 </patternset>
 
 <fileset dir="j2eelib">
  <patternset refid="commonJar"/>
 </fileset>
 
# path 태그 : 재사용 가능한 경로 목록의 집합
 사용 예)
 <path id="project.class.path">
  <pathelement location="fileupload/WEB-INF/classes"/>
  <pathelement path="lib/servlet.jar;lib/commons-fileupload-1.0.jar"/>
 </path>
 
 <classpath refid="project.class.path"/>
 
 - location : 하나의 파일 또는 디렉토리 지정
 - path : 여러 경로를 지정 (; 또는 : 으로 구분)


# 아래의 build.xml 파일에서 ant makeZip 을 할경우 complie 은 두번이 아닌 한번만 실행되게 된다.
 <project name="build" default="makeZip" basedir=".">
  <target name="compile"/>
   <target name="srcCopy" depends="compile"/>
   <target name="classCopy" depends="compile"/>
   <target name="makeZip" depends="srcCopy, classCopy"/>
 </project>

# property 태그 : property 지정
 1) name : 프로퍼티의 이름
 2) value : 프로퍼티의 값을 지정 (name 속성 지정시 value 또는 location 둘중 하나 반드시 사용)
 3) location : 지정한 경로명의 절대 경로명을 값으로 지정 (name 속성 지정시 value 또는 location 둘중 하나 반드시 사용)
 4) resource : 프로퍼티 파일을 읽어 올 때 사용할 자원명을 지정 (name 속성 사용않는 경우 resource, file, environment 중 하나 반드시 사용)
 5) file : 지정한 파일로부터 프로퍼티 목록을 읽어 온다 (name 속성 사용않는 경우 resource, file, environment 중 하나 반드시 사용)
 6) environment : 환경 변수를 읽어 올때 사용할 접두어를 지정 (name 속성 사용않는 경우 resource, file, environment 중 하나 반드시 사용)
 7) classpath : 자원으로부터 프로퍼티 파일을 읽어 올 때 사용할 클래스 패스
 8) classpathref : 클래스패스로 사용할 경로를 path 태그 로 부터 가져온다.
 9) prefix : resource 또는 file 속성을 사용하여 읽어 온 프로퍼티를 참조할 때 사용할 접두어를 지정한다. 만약 접두어 맨뒤에 "." 가 포함되어 있지 않을 경우, 자동으로 "."이 접두어 뒤에 붙는다.
 사용 예)
 <property file="${basedir}/buildprop/global.properties"/>
 
 <property environment="env"/>
 <echo message="JAVA_HOME ${env.JAVA_HOME}"/>

# 기본 프로퍼티 : property 태그 사용하지 않아도 사용 가능한 프로퍼티
 - 모든 자바의 시스템 프로퍼티
 - basedir : 프로젝트의 기본 디렉토리의 절대 경로. project 태그의 basedir 속성에 명시된 값
 - ant.file : 빌드 파일의 절대 경로
 - ant.version : Ant 버전
 - ant.project.name : 현재 실행주인 프로젝트의 이름. project 태그의 name 속성에 명시된 값
 - ant.java.version : Ant 가 발견한 자바 버전.
 
# javac
 1) srcdir : 소스가 위치한 디렉토리 (src 태그로 지정가능. 둘 중 하나 필수)
 2) descdir : 생성된 클래스가 위치할 디렉토리를 지정. javac -d 옵션과 동일
 3) classpath : 컴파일할 때 사용할 클래스패스 (class 태그로 지정 가능)
 4) classapathref : path 태그로 지정한 경로를 클래스패스로 참조
 5) encoding : 소스파일의 인코딩을 지정. javac -encoding 옵션과 동일
 6) nowarn : 컴파일시 -nowarn 옵션 추가 (on) 기본값은 off
 7) deprection : 컴파일시 -deprecation 옵션 추가 (on) 기본값은 off
 사용 예)
 <javac srcdir="" descdir="">
  <classpath>
   <fileset>
    <patternset refid=""/>
   </fileset>
  </classpath>
 </javac>
 
# jar
 1) destfile : 생성할 jar 파일 지정
 2) basedir : jar 파일로 압축할 기본 디렉토리 지정

 사용 예)
  <jar destfile="${disc}/lib/app.jar" basedir="${build}/classes"/>
  
  <jar destfile="${disc}/lib/app.jar">
   <fileset dir="${build}/classes" exclude="**/test*.class"/>
   <fileset dir="${src}/resources"/>
  </jar>

# zip
 - 기본적으로 jar 사용법와 같이 사용 가능.
 - zipfileset 태그를 사용하여 압축되는 파일의 경로명을 변경할 수 있음.
 - zipfileset 의 속성
  1) prefix : ZIP 파일에 압축될 때 변경되어 들어갈 경로명
  2) fullpath : 특정 파일의 변경될 경로를 지정
  3) filemode : 유닉스 기반의 시스템에서 압축되는 파일의 모드를 지정. 기본값은 644
  4) dirmode : 유닉스 기반의 시스템에서 압축되는 디렉토리의 모드를 지정. 기본값은 775
 사용 예)
 <zip destfile="${dist}/example.zip">
  <zipfileset dir="build/api" prefix="docs/api"/>
  <zipfileset dir="${basedir}"
includes="chang.log.20031227" fullpath="docs/chagelog.txt"/>
  <zipfileset dir="build/classes" prefix="classes"/>
  <zipfileset dir="build/src" prefix="src"/>
 </zip>

# war
  사용 예)
  <war destfile="main.war" webxml="src/metadata/web.xml">
   <fileset dir="src/mainapp/html"/>
   <fileset dir="src/mainapp/jsp"/>
   <lib dir="lib">
    <exclude name="logging2.jar"/>
   </lib>
   <classes dir="build/main/classes"/>
   <zipfileset dir="src/imagefile/images" prefix="images"/>
  </war>

# tar
 - 기본 사용 법 : <tar destfile="" basedir=""/>
 - tarfileset 태그
 - targileset 의 속성
  1) mode : 3자리 8진수값. 775 등의 값을 갖는다.
  2) username : 파일에 대한 사용자 이름을 지정한다. UID와는 다르다.
  3) group : 파일에 대한 그룹 이름을 지정한다. GID와는 다르다.
  4) prifix : tar 파일에 압축될 때 변경되어 들어갈 경로명
  5) fullpath : 특정 파일의 변경될 경로를 지정
  6) preserveLeadingSlashes : 맨 앞의 '/'를 유지할지의 여부를 지정. 기본값 : false
 사용 예)
 <tar destfile="${dist}/example.tar">
  <tarfileset dir="build/api" prefix="docs/api"/>
  <tarfileset dir="${basedir}" includes="chage.log.20031227" fullpath="docs/chagelog.txt"/>
  <tarfileset dir="build/classes" prefix="classes"/>
  <tarfileset dir="build/src" prefix="src"/>
 </tar>
 <gzip zipfile="${dist}/example.tar.gz" src="${dist}/example.tar"/>
 
 <tar destfile="${dist}/example.tar.gz" basedir="${build}" compression="gzip"/>

# javadoc
 1) sourcepath : 소스 파일의 경로 지정. 하위 디렉토리까지 모두 처리 (sourcepath, sourcepathref, sourcefiles 중 하나는 필수)
 2) sourcepathref : path 에서 지정한 경로를 소스 파일의 경로로 사용 (sourcepath, sourcepathref, sourcefiles 중 하나는 필수)
 3) sourcefiles : 소스 파일의 목록을 지정. 각 파일은 콤마(,)로 구분 (sourcepath, sourcepathref, sourcefiles 중 하나는 필수)
 4) destdir : 결과 파일이 생성될 디렉토리
 5) packagenames : 콤마로 구분된 패키지 파일의 목록. 패키지명이 *로 끝날 경우 그 하위 패키지까지 모두 처리한다.
 6) excludepackagenames : 문서를 생성하지 않을 패키지의 목록을 지정. 각 패키지는 콤마(,)로 구분. 패키지명이 *으로 끝날 경우 그 하위 패키지까지 모두 제외
 7) access : 접근 모드를 지정. public, protected, package, private 중 한 가지 값. 기본값 : protected
 8) public : 생성되는 API 문서에 public 클래스와 멤버만 보여준다.
 9) protected : 생성되는 API 문서에 protected/public 클래스와 멤버만 보여준다.
 10) package : 생성되는 API 문서에 package/protected/public 클래스와 멤버만 보여준다.
 11) private : 생성되는 API 문서에 private/package/protected/public 클래스와 멤버만 보여준다.
 12) encoding : 소스 파일의 인코딩을 명시.
 13) locale : ko_KR과 같이 사용할 로케일을 지정.
 14) charset : 생성된 문서를 보여줄 때 사용할 케릭터셋을 지정.
 15) version : @version 주석을 포함.
 16) author : @author 주석을 포함.
 17) nodeprecated : deprecated 정보를 포함하지 않는다.
 18) nodeprecatedlist : deprecated 목록을 생성하지 않는다.
 19) windowtitle : 문서를 위한 제목을 텍스트로 입력.
 20) overview : HTML 문서로부터 개략 문서를 읽어 온다.
 21) helpfile : 도움말로 사용할 HTML 파일을 지정.
 22) stylesheetfile : 스타일 시트로 사용할 파일을 지정.
 23) header : 생성될 HTML 파일의 헤더로 사용될 HTML 코드를 명시
 24) footer : 생성될 HTML 파일의 풋터로 사용될 HTML 코드를 명시 
 
 사용 예)
 <javadoc destdir="{build}/api"
  sourcepath="src"
  packagenames="javacan.main.*"
  excludepackagenames="javacna.main.test.*"
  windowtitle="Main 웹 어플리케이션"
  encoding="euc-kr" />
  
 <javadoc destdir="{build}/api"
  windowtitle="Main 웹 어플리케이션"
  encoding="euc-kr">
  <packageset dir="src" defaultexcludes="yes">
   <include name="javacan/main/**"/>
   <exclude name="javacan/main/test/**"/>   
  </packageset>
 </javadoc>
 
# copy
 1) file : 복사할 파일을 지정 (fileset으로 복사할 파일 목록을 지정하지 않는 경우 필수)
 2) tofile : 복사될 파일을 지정
 3) todir : 원본을 복사할 디렉토리를 지정
 4) overwrite : 기존 파일 덮어쓰기 여부 (true/false) 기본값 : false
 5) preservelastmodified : 원본의 최종 수정 날짜 유지 여부(true/false) 기본값 : false
 6) includeEmptyDirs : 텅빈 디렉토리도 복사할지의 여부(true/false) 기본값 : true
 사용 예)
 <copy file="${workspace}/readme.txt.200312" tofile="${build}/readme.txt"/>
 <copy file="${workspace}/readme.txt.200312" todir="${build}"/>
 <copy todir="${build}/src">
  <fileset dir="${workspace}/src"/>
 </copy>
 
# mkdir
 사용 예)
 <mkdir dir="${build}/webapp/WEB-INF/classes"/>
 webapp/WEB-INF 또한 존재 하지 않는 경우 생성

# delete 
 사용 예)
 <delete>
  <fileset dir="${build}"/>
 </delete>
 
 위의 경우 ${build} 와 그 하위 디렉토리의 모든 파일을 삭제. 그러나 디렉토리는 남아있음.(fileset 은 파일의 집합)
 아래와 같이 해주면 디렉토리도 전부 삭제
 
 <delete includeEmptyDirs="true">
  <fileset dir="${build}"/>
 </delete>
 
# ant : 또 다른 빌드 파일의 실행. 여러개의 서브 프로젝트로 구성되어 있을 경우 유용
 1) antfile : 사용할 빌드 파일을 지정. 명시하지 않을 경우 build.xml. dir 속성에 주어진 디렉토리에 대해 상대경로
 2) idr : 새로운 Ant 프로젝트의 basedir을 지정.
 3) target : 수행할 타켓을 지정
 4) output : 새로운 Ant 프로젝트의 수행 결과를 저장할 파일을 명시
 5) inheritAll : 새로운 Ant 프로젝트에 현재 Ant 프로젝트의 모든 프로퍼티 전달 여부(true/false). 기본값 : true
 6) inheritRefs : 새로운 Ant 프로젝트에 현재 Ant 프로젝트의 모든 참조 전달 여부(true/false). 기본값 : true
 사용예)
 <target name="makeSubProject">
  <ant dir="subproject/logging" target="prepare">
   <property name="module1.4" value="jdk1.4"/>
  </ant>
  <ant dir="subproject/common" target="prepare"/>
 </target>

# java
 1) classname : 실행할 클래스 이름 (classname, jar 둘중 하나 필수)
 2) jar : 실행할 jar 파일의 위치 (classname, jar 둘중 하나 필수)
 3) classpath : 사용할 클래스패스를 지정
 4) classpathref : 미리 지정한 path 태그를 참조
 5) fork : 세러은 가상머신에서 클래스 수행 여부 (true/false). 기본값 : false
 6) maxmemory : 포크된 가상 머신에 할당할 메모리의 최대 크기를 지정 (fork가 false인 경우 무시)
 7) dir : 가상 머신을 호출할 디렉토리 (fork가 false인 경우 무시)
 사용 예)
 <java classname="javacan.main.prepare.TableInitilizer">
  <classpath>
   <pathelement path="${java.class.path}"/>
  </classpath>
  <sysproperty key="module" value="test"/>
  <arg value="-init -d"/>
 </java>
 
# native2ascii : 유니코드로의 변환
 1) src : 변환할 파일들이 위치한 기준 디렉토리
 2) dest : 변환한 결과를 저장할 디렉토리
 3) encoding : 변환할 파일의 인코딩 (기본으로 JVM의 기본 인코딩 사용)
 4) reverse : 이스케이프된 유니코드를 지정한 인코딩을 사용하는 문자열로 변환.
 사용 예)
 <native2ascii src="${config}"
  dest="${build}/config"
  includes="**/*.properties"
  excludes="**/test/*.properties"
  encoding="EUC-KR"/>

사용 예제 ) 

[출처] ANT 사용법|작성자 용쓰

----------------------------------

 

<<Ant의 주요 태스크>>

http://ant.apacne.org/manual/index.html

하나의 target내에 있는 태스크는 순차적으로 수행되며, 오직 그 타겟이 수행될 때에만 실행된다.

 

1. javac: 자바 소스 코드 컴파일

<javac srcdir=소스 코드가 위치한 디렉토리

       destdir=컴파일한 클래스가 위치한 디렉토리

       classpath=클래스패스>

…….

</javac>

 

[javac 태스크가 제공하는 속성]

속성

설명

필수

srcdir

소스가 위치한 디렉토리를 지정

<src>요소가 사용되지 않은 경우 필수

destdir

생성된 클래스가 위치할 디렉토리를 지정

 

includes

컴파일할 파일의 패턴 목록, 기본값 *.java

 

classpath

컴파일할 때 사용할 클래스패스.

,<classpath>태그를 사용하여 지정가능

 

classpathref

<path>로 지정한 경로를 클래스패스로 참조

 

debug

디버그 정보 포함, 기본값 false

 

optimize

최적화 사용, 기본값 false

 

verbose

긴 결과 제공

 

failonerror

오류가 발생하면 빌드 중지, 기본값 true

 

encoding

소스 파일의 인코딩을 지정

javac의 encoding 옵션과 동일

 

nowarn

on을 값으로 가질 경우 컴파일할 때 nowarn 옵션을 사용. 기본값은 off

 

deprecation

on을 값으로 가질 경우 deprecation 옵션을 컴파일할 때에 사용, 기본값은 off

 

 

2. jar: JAR 파일로 압축

destfiel 속성은 생성할 JAR 파일을 지정

basedir 속성은 jar파일로 압축할 기본 디렉토리 지정

includes, includesfile, excludes, excludesfile, defualtexcludes 속성 사용

<jar destfile=${dist}/lib/app.jar  basedir=${build}/classes />

 

3. zip : ZIP 파일로 압축

includes, includesfile, excludes, excludesfile, 속성 사용

<zipfileset>은 압축되는 파일의 경로명을 변경 가능

속성

설명

필수

prefix

ZIP 파일에 압축될 때 변경되어 들어갈 경로명

 

fullpath

특정 파일의 변경될 경로를 지정

 

filemode

유닉스 기반의 시스템에서 사용되며, 압축되는 파일의 모드를 지정. 기본값은 644

 

dirmode

유닉스 기반의 시스템에서 압축되는 디렉토리의 모드를 지정. 기본값은 755

 

 

4. war : 웹 어플리케이션 압축

basdir 속성을 사용하여 해당 디렉토리를 WAR파일로 묶는다.

lib 태그 지정한 파일들을 WEB-INF/lib 디렉토리에 위치하게 해준다.

classes 태그는 지정한 디렉토리에 위치한 classes 파일들을 WEB-INF/classes디렉토리에 위치하게 해준다.

webxml 속성은 지정한 파일을 WEB-INF/web.xml 파일로 복사한다

includes, includesfile, excludes, excludesfile, defualtexcludes 속성 사용

파일을 묶을 때 파일의 경로를 변겨해주는 zipfileset 태그 사용 가능

<war destfile=main.war webxml=src/metadata/web.xml>

   <fileset dir=src/mainapp/html />

   <fileset dir=src/mainapp/j네 />

   <lib dir=lib>

      <exclude name=logging2.jar/>

   </lib>

   <classes dir=build/main/classes/>

   <zipfileset dir=src/imagefile/images prefix=images/>

</war>

 

5. tar : TAR 파일의 생성

basedir속성이나 <fileset> 태그 등을 사용하여 묶을 파일의 목록을 지정

compression 속성을 사용하여 우너하는 방식으로 압축가능, gzipbzip2,none값 지정

tarfileset 태그는 파일을 묶을 때 파일의 경로를 변경해 주며, 파일에 대한 사용자 및 그룹을 지정할 수도 있다.

<tar destfile=${dist}/example.tar.gz basedir=${build} compression=gzip/>

 

[tarfileset 태그가 제공하는 속성]

속성

설명

필수

mode

3자리 8진수값

 

useranme

파일에 대한 사용자 이름을 지정, UID와는 다름

 

group

파일에 대한 그룹 이르을 지정, GID와는 다름

 

prefix

ZIP 파일에 압축될 때 변경되어 들어갈 경로명

 

fullpath

특정 파일의 변경될 경로를 지정

 

preserveLeadingSlashes

맨 앞의 /를 유지할지의 여부를 지정, 기본값은 false

 

 

6. javadoc : API 문서의 생성

소스 코드로부터 Javadoc API문서를 생성

옵션이 너무 많아서 생략^^;

 

7. copy : 파일 복사

지정한 디렉토리로 파일을 복사

개개의 파일을 복사할 수도 있고 디렉토리 단위로 복사할 수도 있다.

<copy todir=${build}/src>

   <fileset dir=${workspace}/src/>

</copy>

 

[copy 태스크에서 자주 사용되는 속성]

속성

설명

필수

file

복사할 파일을 지정

<fileset>으로 복사할 파일 목록을 지정하지 않은 경우 필수

tofile

복사될 파일을 지정

 

todir

원본을 복사할 디렉토리 지정

overwrite

true인경우 기존에 존재하는 파일을 덮어 쓴다. 기본값 false

 

preservelastmodified

True인 경우 원본의 최종 수정 날짜를 유지. 기본값은 false

 

includeEmptyDirs

<fileset>으로 지정한 디렉토리 중 텅빈 디렉토리도 복사할지의 여부를 지정, 기본값은 true

 

failonerror

파일이 없을 경우 빌드 중단, 기본값 true

 

verbose

복사한 파일 목록, 기본값 false

 

 

8. mkdir : 디렉토리의 생성

<mkdir dir=${build}/webapp/WEB-INF/classes />

 

9. delete : 파일의 삭제

file 속성 -  특정 파일을 삭제하기 위해 지정

dir 속성 -  지정 디렉토리 및 그 하위 디렉토리까지 모두 삭제

includes, includesfile, excludes, excludesfile, defualtexcludes 속성 사용

<fileset> 태그를 사용하여 삭제할 파일의 집합 표시 가능 (단 파일만 삭제될 뿐 디렉토리는 삭제되지 않는다)

includeEmptyDirs 속성 - true로 지정하면 텅빈 디렉토리까지 삭제

failonerror 속성  오류시 빌드 중단, 기본값 true

verbose속성  삭제할 파일 목록, 기본값 false

 

10. ant : 또 다른 빌드 파일의 실행

하나의 프로젝트가 여러 개의 서브 프로젝트로 구성되어 있는 경우 한번에 서브 프로젝트를 포함한 모든 프로젝트를 빌드함

[ant 태스크의 속성]

속성

설명

필수

antfile

사용할 빌드 파일을 지정, 명시하지 않을 경우 build.xml파일 사용, dir 속성에 주어진 디렉토리에 대해 상대 경로로 명시해야 함

 

dir

새로운 Ant 프로젝트의 basedir을 지정, 사용될 빌드 파일에서 basedir 속성을 지정하고 있다면 무시됨

 

target

수행할 타겟을 지정

 

output

새로운 Ant 프로젝트의 수행 결과를 저장할 파일을 지정

 

inheritAll

기본값 true이며 새로운 Ant 프로젝트는 현재Ant 프로젝트의 모든 프로퍼티를 전달받는다.

 

inheritRefs

기본값 true이며 새로운 Ant 프로젝트는 현재 Ant 프로젝트의 모든 참조를 전달받는다.

 

 

11. java : 자바 실행

[java 태스크가 제공하는 속성의 목록]

속성

설명

필수

classname

실행할 클래스 이름

둘 중 하나 필수

jar

실행할 jar 파일의 위치

classpath

사용할 클래스 패스를 지정

 

classpathref

미리 지정한 <path>요소를 참조

 

fork

true인경우 새로운 가상 머신에서 클래스를 수행, 기본값은 false

 

maxmemory

포크된 가상 머신에 할당할 메모리의 최대 크기를 지정 (fork가 false인 경우 무시)

 

dir

가상 머신을 호출할 디렉토리(fork가 false인 경우 무시)

 

output

결과 파일

 

append

기본 파일에 연결하거나 겹쳐씀

 

 

<java classname=Add classpath=${basedir}/bin>

   <arg value=100/>

   <arg value=200/>

</java>

 

12. native2ascii : 유니코드로의 변환..

ResourceBundle 클래스나 Properties 클래스를 사용하여 프로퍼티 파일로부터 정보를 읽어올 때 파일에 있는 문자를 유니코드로 변환해준다.

Src 속성은 변환할 파일들의 위치한 기준 디렉토리를 지정

Dest 속성은 변환한 결과를 저장할 디렉토리

includes, includesfile, excludes, excludesfile, defualtexcludes 속성 사용

<include>,<exclude>태그를 사용하여 원하는 파일만 변환처리 가능

encoding속성은 변환할 파일의 인코딩 지정(명시하지 않을 경우 JVM 기본 인코딩 사용)

reverse 옵션은 이스케이프된 유니코드를 지정한 인코딩을 사용하는 문자열로 변환

 

13. buildnumber : 빌드 번호

파일에서 빌드 번호를 읽고 build.number를 설정한 다음 build.number+1의 값을 파일에 기록

<buildnumber file=buildnum.txt/>

 

14. echo

System.out(기본값), 파일, 로그, 수신기에 메시지를 기록

속성

설명

필수

message

기록할 텍스트

텍스트를 요소 컨텐츠로 사용하지 않을 경우 필수

file

결과 파일

선택

append

파일을 겹쳐 쓰지 않고 연결, 기본값 false

 

 

<echo message=Hello/>

<echo> This is a message from Ant </echo>

 

15 tstamp

DSTAMP, TSTAMP, TODAY 프로퍼티를 설정

DSTAMP : yyyyMMdd

TSTAMP : hhmm

TODAY : MMM dd yyy

cf. <format>은 Java의 SimpleDateFormat 클래스에서 정의한 패턴을 사용해 현식을 변경하는데 쓰인다.

'개발/활용정보 > Java' 카테고리의 다른 글

Eclipse Memory Analyzer  (0) 2011.11.28
재귀형 퀵소트..소스..자바..  (0) 2011.05.11
Ant 태스크  (0) 2011.04.19
Creating a Custom Event  (0) 2011.04.19
eclipse 단축키  (0) 2011.04.13
And

Ant 태스크

|

Ant 태스크의 개요

Ant 로 이용 가능한 태스크는 수많은 양이므로, 개개의 태스크가 무엇을 할 수 있는지 전부 파악하는 것은 어려울 것입니다. 다음의 목록에는, 개개의 태스크에 대한 짧은 설명과 완전한 문서로 연결되는 링크가 있습니다.
 

 
Archive Tasks / 압축 태스크맨 위로
태스크명(Task Name)설명(Description)
BUnzip2
GZip 또는 BZip2 로 압축된 파일의 압축을 풉니다.
BZip2
GZip 또는 BZip2 알고리즘을 이용해 파일을 압축합니다. 이 태스크에서는 의존관계(dependency) 체크를 실시하지 않습니다; 출력 파일이 항상 생성됩니다.
Cab
마이크로소프트 CAB 압축 파일을 생성합니다. 이것은 Jar 나 Zip 태스크와 유사하게 실행됩니다. 이 태스크는, 실행 패스(path)에 있는 외부의cabarc 툴 (마이크로소프트에서 제공됨)을 이용해 Windows 상에서 동작합니다.
Ear
Enterprise Application archive 가 되는 파일을 다루는 특별한 방법. Jar 태스크의 확장입니다.
GUnzip
GZip 파일의 압축을 풉니다.
GZip
파일들을 GZip 으로 압축합니다.
Jar
파일들을 Jar 로 압축합니다.
Jlink
비추천. 대신에 Jar 나 Zip 태스크의 zipfileset 와 zipgroupfileset 속성을 사용해 주세요.
Manifest
manifest 파일을 생성합니다.
Rpm
Linux 용 인스톨 파일을 생성(build)하기 위해서 rpm 실행파일을 기동합니다. 이 태스크는 현재 Linux 나 다른 RPM을 지원하는 Unix 플랫폼에서만 작동합니다.
SignJar
javasign 커맨드-라인 툴을 이용해 jar 나 zip 파일에 서명(Sign)합니다.
Tar
tar 압축파일을 생성합니다.
Unjar
jar파일의 압축을 풉니다.
Untar
tar파일의 압축을 풉니다.
Unwar
war파일의 압축을 풉니다.
Unzip
zip파일의 압축을 풉니다.
War
WEB-INF/libWEB-INF/classesWEB-INF 디렉토리인 Web Application Archive가 되는 파일을 다루는 특별한 방법. Jar 태스크의 확장입니다
Zip
zip 압축파일을 생성합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
JDepend
JDepend 파서를 기동합니다. 이 파서는 "Java 소스-파일 디렉토리를 검색해, 각각의 Java 패키지를 위해서 설계-품질 메트릭스를 생성합니다."
JProbe
이 태스크는 JProbe 부분에서 툴을 실행합니다. 이 태스크는 JProbe Suite Server Side 3.0 을 이용해 제작되었습니다.
MMetrics
Metamata Metrics/WebGain Quality Analyzer 소스-코드 분석기를 이용해, Java 소스 파일과의 관계를 계산해, 결과를 XML 파일에 출력합니다.
Maudit
Metamata Metrics/WebGain Quality Analyzer 소스-코드 분석기를 이용해, Java 의 소스-코드와 바이트-코드 파일의 정적인(static) 분석을 실행합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Depend
어느 클래스 파일이 기한마감인지, 그 소스를 조사 판정하고, 기한마감의 클래스에 의존하는 다른 모든 클래스의 클래스 파일을 삭제한 뒤, 삭제된 클래스파일을 강제적으로 재컴파일 합니다. 보통 Javac 태스크와 연결해 사용합니다.
Javac
실행중인(Ant의) VM상에서 지정된 소스 파일을 컴파일 하거나, fork 속성이 지정되었을 경우 다른 VM 으로 컴파일합니다.
JspC
JSP 컴파일러를 실행합니다. JSP 페이지의 처음의 기동을 빠르게 하거나, JDK가 전체 인스톨 되지 않은 서버에 배치시키거나, 배치시키지 않고 단지 페이지의 문법 체크를 실시하기 위해서, JSP 페이지를 먼저 컴파일 하는데 사용합니다. 생성된 Java 소스를 컴파일 하는데 Javac 태스크를 사용할 수 있습니다. (WebLogic JSP 의 컴파일시는, Wljspc 태스크를 참조하세요.)
NetRexxC
실행중인(Ant의) VM상에서 NetRexx 소스 트리를 컴파일 합니다.
Rmic
지정된 파일에 대해 rmic 컴파일러를 실행합니다
Wljspc
Weblogic 의 JSP 컴파일러 weblogic.jspc 를 이용해, JSP 페이지를 컴파일 합니다. (Weblogic 이 아닌 JSP 의 컴파일에 대해서는, JspC 태스크를 참조하세요.)
 
맨 위로
태스크명(Task Name)설명(Description)
ServerDeploy
벤더(vendor)-종류인 J2EE 서버의 "최신의" 배치 툴을 실행하기 위한 태스크입니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Javadoc/Javadoc2
javadoc 툴을 이용해 코드 문서를 작성합니다. Javadoc2 태스크는 권장하지 않습니다: 대신에 Javadoc 를 사용해 주세요.
Stylebook
Apache Stylebook documentation generator 를 실행합니다. 이 툴은 커맨드-라인 버전과 다르게, Stylebook 태스크를 실행하려면 모두 3개 인수가 필요합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
EJB Tasks
(EJB 태스크에 대해 진술된 문서를 참조하세요.)
 
맨 위로
태스크명(Task Name)설명(Description)
Ant
주어진 빌드파일을 기반으로 Ant 를 실행합니다. 추가적으로 프로퍼티(가능한 새로운 값을 붙여)를 건네줄 수 있습니다. 이 태스크는 서브-프로젝트를 빌드하는데 사용됩니다.
AntCall
같은 빌드파일중에서 다른 타겟을 실행합니다. 추가적으로 프로퍼티(가능한 새로운 값을 붙여)를 건네줄 수 있습니다.
Apply/ExecOn
시스템 커멘드를 실행합니다. os 속성이 지정되었을 경우, 지정된 operating system 중에서 Ant 가 실행되고 있을 때, 그 커멘드가 실행됩니다.
Dependset
이 태스크는 소스 파일의 집합과 타겟 파일의 집합을 비교합니다. 소스 파일의 일부가 타겟 파일보다 새로운 버전일 경우, 모든 타겟 파일을 삭제합니다.
Exec
시스템 커멘드를 실행합니다. os 속성이 지정되었을 경우, 지정된 운영체제 중에서 Ant 가 실행되고 있을 때, 그 커멘드가 실행됩니다.
Java
실행중인(Ant의) VM상에서, 혹은 fork 속성이 지정된 경우에는 다른 VM 상에서, Java 클래스를 실행합니다.
Parallel
다른 Ant 태스크를 넣을 수가 있는 컨테이너 태스크입니다. <parallel> 태그 중에서 지정된 각각의 내부의 태스크는, 개별의 쓰레드로 실행됩니다.
Sequential
다른 Ant 태스크를 넣을 수 있는 컨테이너 태스크입니다. 내부의 태스크는 단순하게 순서대로 실행됩니다. 대표적인 사용법은 <parallel> 태그 중의 태스크 부분의 실행을 순서대로에 실시하게 하는 것 입니다.
Sleep
지정된 시간동안 실행을 일시정지합니다. 빌드나 배치(deployment)프로세스에서, 태스크간에 시간이 필요한 경우에 편리합니다.
Waitfor
지정된 조건의 집합이 true 가 될 때까지 블록을 실행합니다. 이 태스크는 Parallel 태스크를 프로세스의 집합과 같이 작동하는데 사용되도록 의도되었습니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Checksum
하나의 파일이나 파일의 집합에 대해 체크섬(checksum)을 실행합니다. 이 태스크는 체크섬을 검증하는데도 사용됩니다.
Chmod
하나의 파일이나 지정된 디렉토리의 모든 파일의 퍼미션을 변경합니다. 현재는, Unix 상에서만 효과가 있습니다. 퍼미션의 지정 방법은 chmod 커멘드의 인수와 같은, UNIX 형식입니다.
Concat
여러개의 파일을 연결해, 하나의 파일이나 Ant 의 로그 시스템에 출력합니다.
Copy
하나의 파일이나 파일세트를 새로운 파일이나 디렉토리에 복사합니다.
Copydir
비추천. 대신에 Copy 태스크를 사용해 주세요
Copyfile
비추천. 대신에 Copy 태스크를 사용해 주세요
Delete
하나의 파일이나, 지정된 디렉토리의 모든 파일,서브 디렉토리를 삭제하거나, 하나 이상의 파일집합(FileSet)에 의해 지정된 파일의 집합을 삭제합니다.
Deltree
비추천. 대신에 Delete 태스크를 사용해 주세요
Filter
프로젝트에 토큰 필터를 설정하거나, 지정된 파일로부터 복수의 토큰 필터를 읽어들여 이것들을 필터로 설정합니다. 토큰 필터는 파일-복사 조작을 실시하는 모든 태스크로 사용됩니다.
FixCRLF
tabs, carriage returns, linefeeds, EOF 문자를 추가 또는 삭제하여 파일을 변경합니다.
Get
URL 에서 파일을 취득합니다.
Mkdir
디렉토리를 생성합니다. 필요할 경우, 존재하지 않는 상위 디렉토리를 생성합니다.
Move
파일을, 새로운 파일이나 디렉토리로 이동하거나, 파일의 집합을 새로운 디렉토리로 이동합니다.
Patch
원본파일에 대해 "diff" 파일을 적용합니다.
Rename
비추천. 대신에 Move 태스크를 사용해 주세요.
RenameExtensions
비추천. 대신에 glob mapper 와 함께 Move 태스크를 사용해 주세요.
Replace
Replace 는 선택된 파일에서, 주어진 문자열이 나타나면 다른 문자열로 대체하는 디렉토리-기반의 태스크입니다.
ReplaceRegExp
파일이나 파일 집합에서, 주어진 정규 표현이 나타나면 대입(substitution) 패턴으로 대체하는 디렉토리-기반의 태스크입니다.
Tempfile
임시파일의 이름을 생성하고 지정된 프로퍼티에 그 이름을 설정합니다.
Touch
파일의 수정 시간을 변경하고 가능하면 같은 시각에 그 파일을 생성합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Jarlib-available
확장 기능이, FileSet 에 있는지 ExtensionSet 에 있는지 체크합니다. 그 확장 기능이 존재한다면, 주어진 프로퍼티가 설정됩니다.
Jarlib-display
주어진 jar 파일에 들어가 있는 "Optional Package" 및 "Package Specification" 의 정보를 표시합니다.
Jarlib-manifest
마니페스트(manifest)에서 모든 의존관계를 선언하는 마니페스트를 생성하는 태스크입니다. 주어진 경로(path) 보기 와, jar 의 마니페스트중에 있는 확장(Extension)/"Optional Package" 의 사양을 검색하기 에 의해 의존관계는 결정됩니다.
Jarlib-resolve
확장 기능을 만족하도록 jar 의 위치변경을 시도해, jar 의 위치를 주어진 프로퍼티에 설정합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Record
빌드-프로세스의 로그 출력을 파일에 기록하는 것 같은 리스너를 실행합니다. 동시에 복수의 레코더(recorder)가 존재할 수 있습니다. 각각의 레코더는 파일에 결합시킬 수 있습니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Mail
SMTP 이메일을 송신하는 태스크.
MimeMail
비추천. 대신에 Mail 태스크를 사용해 주세요.
 
맨 위로
태스크명(Task Name)설명(Description)
Echo
텍스트를 System.out 이나 파일에 갈무리합니다.
Fail
BuildException 을 발생시켜 현재의 빌드를 종료합니다. 추가적으로, 추가 정보를 출력합니다.
GenKey
keystore 에 key 를 생성합니다.
Input
메세지를 표시하고 콘솔로부터 입력을 읽어, 빌드 프로세스 간에 유저끼리 연결될 수 있도록 합니다.
Script
BSF-지원되는 프로그램 언어의 스크립트를 실행합니다.
Sound
빌드의 실패, 성공에 따라, 빌드의 끝부분에 사운드 파일을 재생합니다.
Splash
스플래쉬(splash) 화면을 표시합니다.
Sql
SQL 문장을 JDBC 를 통해 데이타베이스에서 실행합니다. SQL 문장은 src 속성을 이용해 텍스트 파일로부터 읽거나, SQL 태그에 둘러싸인 부분을 읽을 수 있습니다.
Taskdef
새로운 태스크가 현재의 프로젝트에 대해 사용되도록, 현재의 프로젝트에 태스크 정의를 추가합니다.
TStamp
현재의 시간에 근거한 현재의 프로젝트에 DSTAMPTSTAMPTODAY 프로퍼티를 설정합니다.
Typedef
새로운 데이터형이 현재의 프로젝트에 사용되도록, 현재의 프로젝트에 데이터형 정의를 추가합니다.
XmlValidate
XML 파일이 올바른지(혹은 단지 올바른형식인지) 체크합니다. 이 태스크는, 현재 Ant 에서 디폴트로 사용하고 있는 XML 파서를 사용합니다만, 필요하다면 SAX1/2 퍼서를 지정할 수도 있습니다.
 
맨 위로
태스크명(Task Name)설명(Description)
.NET Tasks
(.NET 태스크를 기술한 문서를 참조 하세요.)
 
맨 위로
태스크명(Task Name)설명(Description)
ANTLR
문법 파일상에 ANTLR Translator generator 를 실행합니다.
AntStructure
Ant 가 현재 알고 있는 모든 태스크의 정보를 포함한 Ant 빌드파일의, DTD 를 생성합니다.
IContract
iContract DBC 프리프로세서(preprocessor)를 이용한 Java 클래스의 도구. 이 태스크는, assertion 의 on/off 를 할수 있는 그래픽인터페이스(graphical user interface)인 iControl의 프로퍼티 파일을 생성할 수 있습니다.
JavaCC
문법 파일에 대해, JavaCC 컴파일러-컴파일러를 실행합니다.
Javah
Java 클래스에서 JNI 헤더를 생성합니다.
JJTree
JavaCC 컴파일러 컴파일러를 위한 JJTree 프리프로세서를 실행합니다. 이것에 의해, parse-tree 빌드 액션을, JavaCC 소스를 생성하는 여러가지 장소에 삽입합니다. JJTree 의 결과물은 JavaCC 에 의해 파서를 생성하기 위해서 실행됩니다. 이 태스크는, 문법 파일이 생성된 JavaCC 파일보다 새로운 경우만, JJTree 를 실행합니다.
MParse
문법 파일에 대해, Metamata MParse 컴파일러-컴파일러를 실행합니다.
Native2Ascii
파일을 네이티브(native) 인코딩으로부터 escaped Unicode 에 의한 ASCII 파일로 변환합니다. 일반적인 사용법은, 네이티브 운영체제 인코딩으로 관리되고 있는 소스 파일을, 컴파일전에 ASCII 로 변환하는데 사용합니다.
Translate
특별한 토큰으로 단락지어진 파일중의 키를 구별해, 그것들을 자원 번들로부터 읽힌 값으로 변환합니다.
Xslt/Style
XSLT 에 의한 문서의 집합을 처리합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Available
실행도중에 파일, 디렉토리, 클래스 패스안의 클래스, 혹은 JVM 의 시스템 자원이 사용 가능하면 프로퍼티를 설정합니다.
Basename
지정된 패스의 마지막 요소를 프로퍼티로 설정합니다.
BuildNumber
빌드 번호를 추적하는데 이용되는 태스크.
Condition
지정된 조건이 참인 경우 프로퍼티를 설정합니다 - 이 태스크는 Available 과 Uptodate 를 보편화한 것입니다.
Dirname
프로퍼티에, 지정된 파일의 마지막 패스 요소에 의존한 그것을 포함하지 않는 값을 설정합니다.
Echoproperties
현재 프로퍼티의 리스트.
LoadFile
파일을 읽어들여 프로퍼티로 설정한다.
LoadProperties
파일의 내용을 Ant 프로퍼티로 읽어들입니다. 이 태스크는, 내부의 <filterchain> 요소를 지원하고 있는 점/target 의 밖에서 지정할 수 없는 점 을 제외하여, <property file="..."/> 사용과 동등합니다.
PathConvert
내부의 경로(path), 경로 참조, 파일리스트 참조, 파일집함 참조를 지정된 플랫폼에서 사용 가능한 형식 한편/혹은 지정된 구분 기호에 의해 나눌 수 있었던 요소의 리스트로 변환해, 결과를 지정된 프로퍼티에 변환합니다.
Property
프로젝트에서, 프로퍼티를(이름과 값에 의해) 설정하거나 프로퍼티 집합을(파일이나 자원으로부터) 설정합니다.
PropertyFile
프로퍼티 파일을 생성 혹은 수정합니다. 애플리케이션 서버나 애플리케이션 용의 설정 파일에 내버려둔 수정을 만들고 싶을 때에 편리합니다. 보통 자동적으로 빌드 번호를 생성해, 빌드 프로퍼티 파일에 보존하거나 날짜의 조작을 위해 사용됩니다.
Uptodate
주어진 타겟 파일이 소스 파일의 집합보다 새로운 경우에 프로퍼티를 설정합니다.
XmlProperty
프로퍼티의 값을 올바른 XML 파일에서 읽어드립니다.
 
맨 위로
태스크명(Task Name)설명(Description)
FTP
송신, 수신, 리스트, 파일 삭제, 디렉토리 생성을 할 수 있는 기본적인 FTP 클라이언트의 기능
Telnet
원격 telnet 세션을 자동화하는 태스크. 이 태스크는, 수신하는 string을 나타내거나 송신하는 텍스트를 지정하기 위해서, 내부에 <read> <write> 태그를 이용합니다.
setproxy
같은 JVM 으로 실행되고 있는 태스크나 코드가, 방화벽을 통해 원격의 웹 사이트로 액세스 할 수 있도록 Java의 웹 프록시 프로퍼티를 설정합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Cvs
CVS 저장소에서 꺼낸 패키지/모듈의 취급.
CvsChangeLog
CVS 저장소에 기록된 변경 이력의 XML 리포트를 생성합니다.
CVSPass
.cvspass 파일에 항목을 추가한다. 이 파일에 항목을 더하는 것은, cvs login 커멘드와 같은 효과가 있습니다.
CvsTagDiff
2 개의 태그나 날짜의 사이에 CVS 저장소에 기록된 변경 이력을 XML-형식의 리포트 파일로 생성한다
ClearCase
ClearCase 의 cccheckincccheckoutccuncheckoutccupdate 커멘드를 실행하는 태스크.
Continuus/Synergy
Continuus 의 ccmcheckinccmcheckoutccmcheckintaskccmreconfigure, 및 ccmcreateTask 커맨드를 실행하는 태스크.
Microsoft Visual SourceSafe
Visual SourceSafe 의 vssgetvsslabelvsshistoryvsscheckinvsscheckoutvssaddvsscpvsscreate 커멘드를 실행하는 태스크.
Perforce
Perforce 의 p4syncp4changep4editp4submitp4havep4labelp4counterp4reopenp4revertp4add 커멘드를 실행하는 태스크.
Pvcs
PVCS 저장소로부터 소스 코드의 최신판을 꺼낼 수 있게 허락합니다.
SourceOffSite
SourceOffSite의 sosgetsoslabelsoscheckinsoscheckout 커멘드를 실행하는 태스크.
StarTeam
StarTeam 의 stcheckoutstcheckinstlabelstlist 커멘드를 실행하는 태스크. Starteam 태스크는 비추천합니다; 대신에 STCheckout 을 사용해 주세요.
 
맨 위로
태스크명(Task Name)설명(Description)
Junit
Junit 테스트 프레임웍(framework)에서 테스트를 실행합니다. 이 태스크는 JUnit 3.0 에서 3.7 까지 테스트 되었습니다; JUnit 3.0 보다 전의 버전에서는 작동하지 않을 것입니다.
JunitReport
Junit 태스크에 의해 생성된 각각의 XML 파일을 합쳐서, 시험 결과의 리포트를 브라우저로 볼 수 있도록 스타일시트를 합쳐진 문서 결과에 적용합니다.
Test
org.apache.testlet 프레임웍에서 단체 테스트를 실행합니다.
 
맨 위로
태스크명(Task Name)설명(Description)
Visual Age for Java Tasks
(Visual Age for Java 태스크에 대해 진술된 문서를 참조하세요.)

Copyright © 2001-2002 Apache Software Foundation. All rights Reserved. 
번역: 성백재, contact: soma815@msn.com http://jspmaster.com/ 
http://www.apache-korea.org%20,%20jakarta-seoul%20project/
 
 
 
 
 
 
 
 
 
 
 
===========================================================================================
 
 
 
 
 
 

Overview of Ant Tasks

Given the large number of tasks available with Ant, it may be difficult to get an overall view of what each task can do. The following tables provide a short description of each task and a link to the complete documentation.
Archive Tasks
Audit/Coverage Tasks
Compile Tasks
Deployment Tasks
Documentation Tasks
EJB Tasks
Execution Tasks
File Tasks
Java2 Extensions Tasks
Logging Tasks
Mail Tasks
Miscellaneous Tasks
.NET Tasks
Pre-process Tasks
Property Tasks
Remote Tasks
SCM Tasks
Testing Tasks
Visual Age for Java Tasks
Archive Tasks[Back to top]
Task NameDescription
BUnzip2
Expands a file packed using GZip or BZip2.
BZip2
Packs a file using the GZip or BZip2 algorithm. This task does not do any dependency checking; the output file is always generated
Cab
Creates Microsoft CAB archive files. It is invoked similar to the Jar or Zip tasks. This task will work on Windows using the external cabarc tool (provided by Microsoft), which must be located in your executable path.
Ear
An extension of the Jar task with special treatment for files that should end up in an Enterprise Application archive.
GUnzip
Expands a GZip file.
GZip
GZips a set of files.
Jar
Jars a set of files.
Jlink
Deprecated. Use the zipfileset and zipgroupfileset attributes of the Jar or Zip tasks instead.
Manifest
Creates a manifest file.
Rpm
Invokes the rpm executable to build a Linux installation file. This task currently only works on Linux or other Unix platforms with RPM support.
SignJar
Signs a jar or zip file with the javasign command-line tool.
Tar
Creates a tar archive.
Unjar
Unzips a jarfile.
Untar
Untars a tarfile.
Unwar
Unzips a warfile.
Unzip
Unzips a zipfile.
War
An extension of the Jar task with special treatment for files that should end up in the WEB-INF/libWEB-INF/classes, or WEB-INF directories of the Web Application Archive.
Zip
Creates a zipfile.
Audit/Coverage Tasks[Back to top]
Task NameDescription
JDepend
Invokes the JDepend parser. This parser "traverses a set of Java source-file directories and generates design-quality metrics for each Java package".
JProbe
These tasks run the tools from the JProbe suite. This task was written using JProbe Suite Server Side 3.0.
MMetrics
Computes the metrics of a set of Java source files, using the Metamata Metrics/WebGain Quality Analyzer source-code analyzer, and writes the results to an XML file.
Maudit
Performs static analysis on a set of Java source-code and byte-code files, using the Metamata Metrics/WebGain Quality Analyzer source-code analyzer.
Compile Tasks[Back to top]
Task NameDescription
Depend
Determines which classfiles are out-of-date with respect to their source, removing the classfiles of any other classes that depend on the out-of-date classes, forcing the re-compile of the removed classfiles. Typically used in conjunction with the Javac task.
Javac
Compiles the specified source file(s) within the running (Ant) VM, or in another VM if the fork attribute is specified.
JspC
Runs the JSP compiler. It can be used to precompile JSP pages for fast initial invocation of JSP pages, deployment on a server without the full JDK installed, or simply to syntax-check the pages without deploying them. The Javac task can be used to compile the generated Java source. (For Weblogic JSP compiles, see the Wljspc task.)
NetRexxC
Compiles a NetRexx source tree within the running (Ant) VM.
Rmic
Runs the rmic compiler on the specified file(s).
Wljspc
Compiles JSP pages using Weblogic's JSP compiler, weblogic.jspc. (For non-Weblogic JSP compiles, see the JspC task.
Deployment Tasks[Back to top]
Task NameDescription
ServerDeploy
Task to run a "hot" deployment tool for vendor-specific J2EE server.
Documentation Tasks[Back to top]
Task NameDescription
Javadoc/Javadoc2
Generates code documentation using the javadoc tool. The Javadoc2 task is deprecated; use the Javadoc task instead.
Stylebook
Executes the Apache Stylebook documentation generator. Unlike the command-line version of this tool, all three arguments are required to run the Stylebook task.
EJB Tasks[Back to top]
Task NameDescription
EJB Tasks
(See the documentation describing the EJB tasks.)
Execution Tasks[Back to top]
Task NameDescription
Ant
Runs Ant on a supplied buildfile, optionally passing properties (with possibly new values). This task can be used to build sub-projects.
AntCall
Runs another target within the same buildfile, optionally passing properties (with possibly new values).
Apply/ExecOn
Executes a system command. When the os attribute is specified, the command is only executed when Ant is run on one of the specified operating systems.
Dependset
This task compares a set of source files with a set of target files. If any of the source files is newer than any of the target files, all the target files are removed.
Exec
Executes a system command. When the os attribute is specified, the command is only executed when Ant is run on one of the specified operating systems.
Java
Executes a Java class within the running (Ant) VM, or in another VM if the fork attribute is specified.
Parallel
A container task that can contain other Ant tasks. Each nested task specified within the <parallel> tag will be executed in its own thread.
Sequential
A container task that can contain other Ant tasks. The nested tasks are simply executed in sequence. Its primary use is to support the sequential execution of a subset of tasks within the <parallel> tag.
Sleep
A task for suspending execution for a specified period of time. Useful when a build or deployment process requires an interval between tasks.
Subant
Calls a given target for all defined sub-builds. This is an extension of ant for bulk project execution.
Waitfor
Blocks execution until a set of specified conditions become true. This task is intended to be used with the Parallel task to synchronize a set of processes.
File Tasks[Back to top]
Task NameDescription
Attrib
Changes the permissions and/or attributes of a file or all files inside the specified directories. Currently, it has effect only under Windows.
Checksum
Generates a checksum for a file or set of files. This task can also be used to perform checksum verifications.
Chgrp
Changes the group ownership of a file or all files inside the specified directories. Currently, it has effect only under Unix.
Chmod
Changes the permissions of a file or all files inside the specified directories. Currently, it has effect only under Unix. The permissions are also UNIX style, like the arguments for the chmod command.
Chown
Changes the owner of a file or all files inside the specified directories. Currently, it has effect only under Unix.
Concat
Concatenates multiple files into a single one or to Ant's logging system.
Copy
Copies a file or Fileset to a new file or directory.
Copydir
Deprecated. Use the Copy task instead.
Copyfile
Deprecated. Use the Copy task instead.
Delete
Deletes either a single file, all files and sub-directories in a specified directory, or a set of files specified by one or more FileSets.
Deltree
Deprecated. Use the Delete task instead.
Filter
Sets a token filter for this project, or reads multiple token filters from a specified file and sets these as filters. Token filters are used by all tasks that perform file-copying operations.
FixCRLF
Modifies a file to add or remove tabs, carriage returns, linefeeds, and EOF characters.
Get
Gets a file from a URL.
Mkdir
Creates a directory. Non-existent parent directories are created, when necessary.
Move
Moves a file to a new file or directory, or a set(s) of file(s) to a new directory.
Patch
Applies a "diff" file to originals.
Rename
Deprecated. Use the Move task instead.
RenameExtensions
Deprecated. Use the Move task with a glob mapper instead.
Replace
Replace is a directory-based task for replacing the occurrence of a given string with another string in selected file.
ReplaceRegExp
Directory-based task for replacing the occurrence of a given regular expression with a substitution pattern in a file or set of files.
Sync
Synchronize two directory trees.
Tempfile
Generates a name for a new temporary file and sets the specified property to that name.
Touch
Changes the modification time of a file and possibly creates it at the same time.
Java2 Extensions Tasks[Back to top]
Task NameDescription
Jarlib-available
Check whether an extension is present in a FileSet or an ExtensionSet. If the extension is present, the specified property is set.
Jarlib-display
Display the "Optional Package" and "Package Specification" information contained within the specified jars.
Jarlib-manifest
Task to generate a manifest that declares all the dependencies in manifest. The dependencies are determined by looking in the specified path and searching for Extension/"Optional Package" specifications in the manifests of the jars.
Jarlib-resolve
Try to locate a jar to satisfy an extension, and place the location of the jar into the specified property.
Logging Tasks[Back to top]
Task NameDescription
Record
Runs a listener that records the logging output of the build-process events to a file. Several recorders can exist at the same time. Each recorder is associated with a file.
Mail Tasks[Back to top]
Task NameDescription
Mail
A task to send SMTP email.
MimeMail
Deprecated. Use the Mail task instead.
Miscellaneous Tasks[Back to top]
Task NameDescription
Defaultexcludes
Modify the list of default exclude patterns from within your build file.
Echo
Echoes text to System.out or to a file.
Fail
Exits the current build by throwing a BuildException, optionally printing additional information.
GenKey
Generates a key in keystore.
Input
Allows user interaction during the build process by displaying a message and reading a line of input from the console.
Script
Executes a script in a Apache BSF-supported language.
Sound
Plays a sound file at the end of the build, according to whether the build failed or succeeded.
Splash
Displays a splash screen.
Sql
Executes a series of SQL statements via JDBC to a database. Statements can either be read in from a text file using the src attribute, or from between the enclosing SQL tags.
Taskdef
Adds a task definition to the current project, such that this new task can be used in the current project.
TStamp
Sets the DSTAMPTSTAMP, and TODAY properties in the current project, based on the current date and time.
Typedef
Adds a data-type definition to the current project, such that this new type can be used in the current project.
XmlValidate
Checks that XML files are valid (or only well-formed). This task uses the XML parser that is currently used by Ant by default, but any SAX1/2 parser can be specified, if needed.
.NET Tasks[Back to top]
Task NameDescription
.NET Tasks
(See the documentation describing the .NET tasks.)
Pre-process Tasks[Back to top]
Task NameDescription
ANTLR
Invokes the ANTLR Translator generator on a grammar file.
AntStructure
Generates a DTD for Ant buildfiles that contains information about all tasks currently known to Ant.
IContract
Instruments Java classes using the iContract DBC preprocessor. This task can generate a properties file for iControl, a graphical user interface that lets you turn on/off assertions.
Import
Import another build file and potentially override targets in it with targets of your own.
JavaCC
Invokes the JavaCC compiler-compiler on a grammar file.
Javah
Generates JNI headers from a Java class.
JJDoc
Invokes the JJDoc documentation generator for the JavaCC compiler-compiler. JJDoc takes a JavaCC parser specification and produces documentation for the BNF grammar. It can operate in three modes, determined by command line options. This task only invokes JJDoc if the grammar file is newer than the generated BNF grammar documentation.
JJTree
Invokes the JJTree preprocessor for the JavaCC compiler-compiler. It inserts parse-tree building actions at various places in the JavaCC source that it generates. The output of JJTree is run through JavaCC to create the parser. This task only invokes JJTree if the grammar file is newer than the generated JavaCC file.
Macrodef
Define a new task as a macro built-up upon other tasks.
MParse
Invokes the Metamata MParse compiler-compiler on a grammar file.
Native2Ascii
Converts files from native encodings to ASCII with escaped Unicode. A common usage is to convert source files maintained in a native operating system encoding to ASCII, prior to compilation.
Presetdef
Define a new task by instrumenting an existing task with default values for attributes or child elements.
Translate
Identifies keys in files, delimited by special tokens, and translates them with values read from resource bundles.
Xslt/Style
Processes a set of documents via XSLT.
Property Tasks[Back to top]
Task NameDescription
Available
Sets a property if a specified file, directory, class in the classpath, or JVM system resource is available at runtime.
Basename
Sets a property to the last element of a specified path.
BuildNumber
Task that can be used to track build numbers.
Condition
Sets a property if a certain condition holds true - this is a generalization of Available and Uptodate.
Dirname
Sets a property to the value of the specified file up to, but not including, the last path element.
Echoproperties
Lists the current properties.
LoadFile
Loads a file into a property.
LoadProperties
Load a file's contents as Ant properties. This task is equivalent to using <property file="..."/> except that it supports nested<filterchain> elements, and it cannot be specified outside a target.
PathConvert
Converts a nested path, path reference, filelist reference, or fileset reference to the form usable on a specified platform and/or to a list of items separated by the specified separator and stores the result in the specified property.
Property
Sets a property (by name and value), or set of properties (from a file or resource) in the project.
PropertyFile
Creates or modifies property files. Useful when wanting to make unattended modifications to configuration files for application servers and applications. Typically used for things such as automatically generating a build number and saving it to a build properties file, or doing date manipulation.
Uptodate
Sets a property if a given target file is newer than a set of source files.
Whichresource
Find a class or resource.
XmlProperty
Loads property values from a well-formed XML file.
Remote Tasks[Back to top]
Task NameDescription
FTP
Implements a basic FTP client that can send, receive, list, and delete files, and create directories.
Rexec
Task to automate a remote rexec session.
Scp
Copy files to or from a remote server using SSH.
setproxy
Sets Java's web proxy properties, so that tasks and code run in the same JVM can have through-the-firewall access to remote web sites.
Sshexec
Execute a command on a remote server using SSH.
Telnet
Task to automate a remote telnet session. This task uses nested <read> and <write> tags to indicate strings to wait for and specify text to send.
SCM Tasks[Back to top]
Task NameDescription
Cvs
Handles packages/modules retrieved from a CVS repository.
CvsChangeLog
Generates an XML report of the changes recorded in a CVS repository.
CVSPass
Adds entries to a .cvspass file. Adding entries to this file has the same affect as a cvs login command.
CvsTagDiff
Generates an XML-formatted report file of the changes between two tags or dates recorded in a CVS repository.
ClearCase
Tasks to perform the ClearCase cleartool checkin, checkout, uncheckout, update, lock, unlock, mklbtype, rmtype, mklabel, mkattr, mkdir, mkelem, and mkbl commands.
Continuus/Synergy
Tasks to perform the Continuus ccmcheckin, ccmcheckout, ccmcheckintask, ccmreconfigure, and ccmcreateTask commands.
Microsoft Visual SourceSafe
Tasks to perform the Visual SourceSafe vssget, vsslabel, vsshistory, vsscheckin, vsscheckout, vssadd, vsscp, and vsscreate commands.
Perforce
Tasks to perform the Perforce p4sync, p4change, p4edit, p4submit, p4have, p4label, p4counter, p4reopen, p4revert, and p4addcommands.
Pvcs
Allows the user extract the latest edition of the source code from a PVCS repository.
SourceOffSite
Tasks to perform the SourceOffSite sosget, soslabel, soscheckin, and soscheckout commands.
StarTeam
Tasks to perform the StarTeam stcheckout, stcheckin, stlabel, and stlist commands. The Starteam task is deprecated; useSTCheckout instead.
Testing Tasks[Back to top]
Task NameDescription
Junit
Runs tests from the Junit testing framework. This task has been tested with JUnit 3.0 up to JUnit 3.7; it won't work with versions prior to JUnit 3.0.
JunitReport
Merges the individual XML files generated by the Junit task and applies a stylesheet on the resulting merged document to provide a browsable report of the testcases results.
Test
Executes a unit test in the org.apache.testlet framework.
Visual Age for Java Tasks[Back to top]
Task NameDescription
Visual Age for Java Tasks
(See the documentation describing the Visual Age for Java tasks.)

Copyright © 2001-2004 The Apache Software Foundation. All rights Reserved.

'개발/활용정보 > Java' 카테고리의 다른 글

재귀형 퀵소트..소스..자바..  (0) 2011.05.11
ant 사용법  (0) 2011.04.19
Creating a Custom Event  (0) 2011.04.19
eclipse 단축키  (0) 2011.04.13
자바가 사용하는 메모리의 종류와 특징  (0) 2011.04.13
And

Creating a Custom Event

|

-----------------------------------------------------------

import java.util.EventListener;
import java.util.EventObject;

import javax.swing.event.EventListenerList;

class MyEvent extends EventObject {
  public MyEvent(Object source) {
    super(source);
  }
}

interface MyEventListener extends EventListener {
  public void myEventOccurred(MyEvent evt);
}

class MyClass {
  protected EventListenerList listenerList = new EventListenerList();

  public void addMyEventListener(MyEventListener listener) {
    listenerList.add(MyEventListener.class, listener);
  }
  public void removeMyEventListener(MyEventListener listener) {
    listenerList.remove(MyEventListener.class, listener);
  }
  void fireMyEvent(MyEvent evt) {
    Object[] listeners = listenerList.getListenerList();
    for (int i = 0; i < listeners.length; i = i+2) {
      if (listeners[i== MyEventListener.class) {
        ((MyEventListenerlisteners[i+1]).myEventOccurred(evt);
      }
    }
  }
}

public class Main {
  public static void main(String[] argvthrows Exception {
    MyClass c = new MyClass();
    c.addMyEventListener(new MyEventListener() {
      public void myEventOccurred(MyEvent evt) {
        System.out.println("fired");
      }
    });

  }
}

 

--------------------------------------------

 

This is an example of custom event classes made to monitor the folder for changes ie. when some change is made in the folder, the event is fired. 
This connects this topic to the topic regarding folder listener from the archive : 
http://forums.sun.com/thread.jspa?threadID=482409&start=0&tstart=0

So, in order to make an custom event first you have to define your event in a class that will extends EventObject class from java.util package.

// class that defines the custom event
import java.util.EventObject;
public class FolderEvent extends EventObject {
       public FolderEvent(Object source){
       super(source);
       }
}



Secondly, you have to define an interface which will represent the contract for making the listener

public interface FolderListenerInterface {
     //you need to override this method to add some functionality as a response to the event 
     public void handleFolderEvent(FolderEvent e);
}





Then, you have to make an class that will fire your event when some specific event occurs. 
Monitor.java starts a low priority thread in which it periodically ( in 1sec interval )checks the folder for some changes and if any it fires an FolderEvent.


import java.io.File;
import java.util.ArrayList;
import java.util.Date;
 
public class Monitor extends Thread{
 
//a list of listeners  -  contains a references to all classes that are interested in listening to FolderEvent
private ArrayList listeners = new ArrayList();
 
//dir - monitored directory
private File dir;
 
//constructor - starts a low priority thread
public Monitor(){
    this.start();
    this.setPriority(Thread.MIN_PRIORITY);	
}
 
//register new listener
public void addFolderListener(FolderListenerInterface folderListener){
     listeners.add(folderListener);
}
 
//removes the listener
public void removeFolderLIstener(FolderListenerInterface folderListener){
     listeners.remove(folderListener);
}
 
void dispatchEvent(){
     for(int i=0;i<listeners.size();i++){
          FolderListenerInterface folderListener = (FolderListenerInterface)listeners.get(i);
          if (folderListener != null){
               FolderEvent folderEvent = new FolderEvent(this);
               folderListener.handleFolderEvent(folderEvent);
          }	
     }
}
 
public void run(){
      dir = new File("C:\\FolderToBeMonitored");
      Date lastChange = new Date(dir.lastModified());
 
      while(true){
                Date change = new Date(dir.lastModified());
 
                if(change.after(lastChange)){       //event occurred
                dispatchEvent();                //dispatching event to all listeners
                lastChange = change;
           }
 
           try{
                Thread.sleep(1000);          
           }catch(InterruptedException e){}	
     }	
}	
}





And as the last thing to write, here is an simple app that uses the classes above

public class FolderListenerApp {
 
     public static void main(String[] args) {
     Monitor m = new Monitor();
 
     m.addFolderListener(new FolderListenerInterface(){
          public void handleFolderEvent(FolderEvent fe){
          System.out.println("EVENT  OCCURRED");		
          }
     });
		
     }
}

'개발/활용정보 > Java' 카테고리의 다른 글

ant 사용법  (0) 2011.04.19
Ant 태스크  (0) 2011.04.19
eclipse 단축키  (0) 2011.04.13
자바가 사용하는 메모리의 종류와 특징  (0) 2011.04.13
Java 메모리 설정 MaxPermSize  (0) 2011.04.13
And