====== Gant ====== * http://gant.codehaus.org/ * [[http://gant.codehaus.org/|Gant]] is [[http://groovy.codehaus.org/|Groovy]] [[ant|Ant]] Scripting * [[http://ant.apache.org/manual/anttaskslist.html|Ant Tasks]] * [[http://www.ibm.com/developerworks/java/tutorials/j-gant/index.html|Build Software with Gant]] 오래된 문서지만 좋은 팁들이 있음. ===== 기본 ===== * Gant는 [[http://groovy.codehaus.org/api/groovy/util/AntBuilder.html|Groovy의 AntBuilder]]에 대한 파사드일 뿐이다. [[http://groovy.codehaus.org/Using+Ant+from+Groovy|Using Ant from Groovy]] 참조. * [[http://groovy.codehaus.org/Using+Ant+Libraries+with+AntBuilder|Using Ant Libraries with AntBuilder]] * Gant는 Ant 스크립팅 프레임워크이지 프로젝트 관리/빌드 툴이 아니다. 빌드 프레임워크를 원한다면 [[gradle|Gradle]]을 사용한다. * ''build.gant'' 가 기본 Gant 스크립트 ===== Options ===== * ''-p'' : 타겟 목록 보기 * ''-T'' : 타겟 목록 보기 * ''-D ='' : Ant 프라퍼티 생성 ===== 설치 ===== * Gant 홈페이지에서 Groovy 버전에 맞는 것으로 다운로드한다. * ''GANT_HOME'' 환경변수 설정. * ''GROOVY_HOME'' 환경변수 확인 * ''JAVA_HOME'' 환경변수 확인 * MS-Window의 경우 ''$GANT_HOME/stargGroovy.bat'' 파일을 열어서 다음과 같은 줄을 찾아서 ''groovy-all-**x.y.z**.jar''의 버전을 자신의 ''$GROOVY_HOME''에 있는 버전으로 정확히 맞춰준다. set STARTER_CLASSPATH=%GROOVY_HOME%\embeddable\groovy-all-2.0.0.jar;%STARTER_CLASSPATH% * Linux의 경우 gant 파일들에 "''chmod -R og+r *''" 해야할 필요가 있을 수도 있다. * [[http://ant.apache.org/|Ant]]도 설치 해 두고, ''ANT_HOME''을 설정해 둔다. ===== 기본 Ant 태스크와 기타 태스크 ===== Groovy는 기본적으로 Ant와 JUnit을 내장하고 있다. 따라서 Gant는 어떠한 추가 없이 Ant와 JUnit 태스크를 실행할 수 있다. 기타 직접 태스크 라이브러리를 추가하고자 할 때는 다음과 같이 클래스패스를 지정한다. * ''--classpath '' 혹은 ''-P ''로 다른 Ant 태스크 jar 클래스패스 추가 * ''${user.home}/.ant/lib''에 있는 jar 자동 추가 * ''$ANT_HOME/lib''에 있는 jar 자동 추가 * ''$GANT_HOME/conf/gant-start.conf''에 따르면 다음 디렉토리들도 자동 클래스패스 추가 대상인듯 * ''${user.home}/.gant/lib'' * ''${user.home}/.ant/lib'' * ''${user.home}/.groovy/lib'' * ''${gant.home}/lib'' ===== Ant Properties ===== * [[http://ant.apache.org/manual/Tasks/property.html|Property Task]] 참조. * ''gant -D name=value''로 Ant 프라퍼티를 지정하면 자동으로 ''ant.property'' 영역으로 들어가게 된다. * Ant 태스크들은 들어온 문자열에 ''${프라퍼티명}''이 있으면 자동으로 Ant 프라퍼티에서 값을 찾아서 치환한다. 이때, **Groovy의 GString이 작동하지 않도록 홑따옴표를 사용**해야 한다. // 프라퍼티 파일에서 읽어오기 ant.property(file: 'common-versions.properties') // 값넣기 ant.property(name: 'ivy.local.repository.dir', value: ivyLocalRepoDir) // 값 읽기 logkitVersion = ant.project.properties.'logkit.version' // ant task에 프라퍼티 전달 ant.echo(message: '${ivy.local.repository.dir}) ===== 환경 변수 ===== 환경 변수를 읽어오고 그것을, Ant 태스크에 넘길 때는 GString을 사용하지 말 것. // 환경 변수의 값들을 'env' 프라퍼티로 읽어 올 수 있도록 지정한다. ant.property(environment:'env') ... ant.echo("${env.CATALINA_HOME}") // 에러 발생 -> ant.echo('${env.CATALINA_HOME}') // ant.echo 스스로가 ''${}''를 해석한다. ===== Path 지정해서 넘기기 ===== Classpath 등을 지정해서 레퍼런스를 넘기는 방법 ant.path(id : 'libClasspath') { // id가 'libClasspath'인 path 레퍼런스 생성 fileset(dir : libDir, includes : '*.jar') } // 어느 타겟에선가... ant.javac(srcdir : 'src', destdir : 'build', classpathref : 'libClasspath') // libClasspath 참조 ===== 사용자 가이드 ===== - [[gant:scripts|Gant Scripts]] - [[gant:targets|Gant Targets]] - [[gatn:return_code|Gant Returncode]] - [[gant:tasks|Gant Tasks]] - [[gant:target_sets|Gant Target Sets]] - [[gant:tools|Gant Tools]] - [[gant:antlib|Gant Ant Libraries]] - [[gant:bash_completion|Gant Bash Completion]]