사용자 도구

사이트 도구


gant:targets

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
gant:targets [2012/10/17 19:17]
kwon37xi
gant:targets [2012/10/22 16:55] (현재)
kwon37xi [동적 타겟 생성]
줄 27: 줄 27:
 target ( adob : 'A target called adob.' ) { target ( adob : 'A target called adob.' ) {
   flob ( ) //flob 이라는 타겟 호출   flob ( ) //flob 이라는 타겟 호출
 +  this['flob']() // 문자열로 flob 타겟 호출
 } }
 </code> </code>
   * 다른 타겟에 의존할 수도 있다.<code groovy>   * 다른 타겟에 의존할 수도 있다.<code groovy>
 target ( adob : 'A target called adob.' ) { target ( adob : 'A target called adob.' ) {
-  depends ( flob ) +  depends ( flob ) // adob 타겟을 실행하면 그 전에 항상 flob 타겟 호출 
-  // adob 타겟을 실행하면 그 전에 항상 flob 타겟 호출+  depends ( 'floc' ) // 문자열로 'floc'' 타겟에 의존하게
 } }
 </code> </code>
 +    * 의존성은 여러개 설정할 수 있으며 설정 순서에 따라 실행한다. 위 예에서는 'flob', 'floc' 순서로 실행한다.
 ===== 기본 타겟 ===== ===== 기본 타겟 =====
   * ''gant'' 명령만 실행해도 되는 기본 타겟을 설정할 수 있다.<code groovy>   * ''gant'' 명령만 실행해도 되는 기본 타겟을 설정할 수 있다.<code groovy>
줄 49: 줄 50:
 </code> </code>
  
-===== 기본 Ant 태스크와 기타 태스크 ===== 
-Groovy는 기본적으로 Ant와 JUnit을 내장하고 있다. 따라서 Gant는 어떠한 추가 없이 Ant와 JUnit 태스크를 실행할 수 있다. 기타 직접 설치한 태스크는 다음과 같이 실행할 수 있다. 
  
-  * ''--classpath <path>'' 혹은 ''-P <path>''로 다른 Ant 태스크 jar 클래스패스 추가 +===== 동적 타겟 생성 ===== 
-  ''${user.home}/.ant/lib''에 있는 jar 동 추 +''build.gant''는 그 가 스크립트이고 ''target''도 메소드이므로 동적으로 타겟을 생성하는 것이 능하다. 단, **GString으로 ''target''의 인자를 넘기는 것은 하지 말 것.** GString의 늦은 초기화 특징 때문에 엉뚱한 값이 어갈 수도 있다. 
-  * ''$ANT_HOME/lib''에 있는 jar 자동 추 +  * ''build.gant''<code groovy> 
-  * ''$GANT_HOME/conf/gant-start.conf''에 따르면 다음 디렉토리들도 자동 클래스패스 추가 대상인듯 +def names = ['a','b','c','d']
-    * ''${user.home}/.gant/lib'' +
-    ''${user.home}/.ant/lib'' +
-    * ''${user.home}/.groovy/lib'' +
-    * ''${gant.home}/lib'' +
- +
-===== TaskDef ===== +
-  * 기본이 아닌 외부 태스크 정의 [[http://ant.apache.org/manual/Tasks/taskdef.html|Ant taskdef 태스크 참조]]+
  
 +names.each { name ->
 +    target(name: name + '_project', description: 'Description for ' + name) {
 +        echo(message: "project name : ${name}")
 +    }
 +}
 +target(allProject: 'run all projects') {
 +    names.each {
 +        depends(it) // 모든 name_project에 대해 의존성 걸기
 +    }
 +}
 +</code>
 +  * ''gant -T'' <code>
 +$ gant -T
 + a_project    Description for a
 + allProject   run all projects
 + b_project    Description for b
 + c_project    Description for c
 + d_project    Description for d
 +</code>
gant/targets.1350469054.txt.gz · 마지막으로 수정됨: 2012/10/17 19:17 저자 kwon37xi