사용자 도구

사이트 도구


gant:targets

차이

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

차이 보기로 링크

다음 판
이전 판
gant:targets [2012/10/17 18:41]
kwon37xi 새로 만듦
gant:targets [2012/10/22 16:55] (현재)
kwon37xi [동적 타겟 생성]
줄 23: 줄 23:
 </code> </code>
  
 +===== 다른 타겟 호출 =====
 +  * 타겟 이름으로 다른 타겟을 호출 할 수 있다.<code groovy>
 +target ( adob : 'A target called adob.' ) {
 +  flob ( ) //flob 이라는 타겟 호출
 +  this['flob']() // 문자열로 flob 타겟 호출
 +}
 +</code>
 +  * 다른 타겟에 의존할 수도 있다.<code groovy>
 +target ( adob : 'A target called adob.' ) {
 +  depends ( flob ) // adob 타겟을 실행하면 그 전에 항상 flob 타겟 호출
 +  depends ( 'floc' ) // 문자열로 'floc'' 타겟에 의존하게
 +}
 +</code>
 +    * 의존성은 여러개 설정할 수 있으며 설정 순서에 따라 실행한다. 위 예에서는 'flob', 'floc' 순서로 실행한다.
 +===== 기본 타겟 =====
 +  * ''gant'' 명령만 실행해도 되는 기본 타겟을 설정할 수 있다.<code groovy>
 +setDefaultTarget ( aTarget )
 +</code>
 +  * 저 명령은 실제로는 다음으로 실행된다<code groovy>
 +target ( 'default' : 'aTarget' ) { aTarget ( ) }
 +</code>
 +
 +===== target-closure의 파라미터 =====
 +  * target-closure에는 항상 타겟에 대한 정보가 Map으로 전달된다.<code groovy>
 +target ( example : '' ) { println ( it.name ) ; println ( it.description ) }
 +</code>
 +
 +
 +===== 동적 타겟 생성 =====
 +''build.gant''는 그 자체가 스크립트이고 ''target''도 메소드이므로 동적으로 타겟을 생성하는 것이 가능하다. 단, **GString으로 ''target''의 인자를 넘기는 것은 하지 말 것.** GString의 늦은 초기화 특징 때문에 엉뚱한 값이 들어갈 수도 있다.
 +  * ''build.gant''<code groovy>
 +def names = ['a','b','c','d']
 +
 +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.1350466877.txt.gz · 마지막으로 수정됨: 2012/10/17 18:41 저자 kwon37xi