문서의 이전 판입니다!
AntUnit의 태스크들이 antlib:org.apache.ant.antunit
네임스페이스에 속한 상태이며, 이를 매번 직접 지정하여 호출한다.
// 파일이 존재하지 않음(assertFileDoesntExist)을 확인 ant.'antlib:org.apache.ant.antunit:assertFileDoesntExist'(file:'copytest1.tmp') ant.copy(file:'src/antunit.groovy', tofile:'copytest1.tmp') // 이제 파일이 존재함(assertFileExists)을 확인 ant.'antlib:org.apache.ant.antunit:assertFileExists'(file:'copytest1.tmp') ant.delete(file:'copytest1.tmp') ant.'antlib:org.apache.ant.antunit:assertFileDoesntExist'(file:'copytest1.tmp')
자신만의 네임스페이스에 있던 antlib 태스크들을 기본 네임스페이스로 가져와서 ant.*
(혹은, ant.
빼고) 직접 호출하게 변경할 수 있다.
import org.apache.tools.ant.taskdefs.Antlib // AntUnit 태스크 설정정보 파일 읽기 def url = this.class.getResource('org/apache/ant/antunit/antlib.xml') // AntUnit의 태스크들을 현재 네임스페이스(ant.*)로 가져옴 Antlib.createAntlib(ant.antProject, url, 'antlib:org.apache.ant.antunit').execute() target(antunittest: 'AntUnit Test') { // AntUnit의 태스크 바로 실행 assertFileDoesntExist(file:'copytest1.tmp') copy(file:'src/some/HelloWorld.groovy', tofile:'copytest1.tmp') assertFileExists(file:'copytest1.tmp') delete(file:'copytest1.tmp') assertFileDoesntExist(file:'copytest1.tmp') }