2011-03-15 2 views
2

특정 파일이 이미있을 때 maven-antrun-plugin 실행을 비활성화하려면 어떻게합니까? :특정 파일이 이미 존재하는 경우 antrun을 비활성화하는 방법은 무엇입니까?

[...] 
<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <executions> 
    <execution> 
     <phase>test</phase> 
     <goals> 
     <goal>run</goal> 
     </goals> 
     <configuration> 
     <target> 
      <!-- do something really complex in order to create file.txt --> 
     </target> 
     </configuration> 
    </execution> 
    </executions> 
</build> 
[...] 

실행에는 시간이 걸리고 file.txt이 이미있을 때마다 반복하지 않으려 고합니다.

답변

6

독립 실행 형 Ant 파일에서 파일 존재 여부를 확인하십시오. 예 :

<target name="check-file"> 
    <available file="foo.bar" property="fileExists" /> 
</target> 

<target name="time-consuming" depends="check-file" unless="fileExists"> 
    ... 
</target> 
+0

당신이를 전해 주 시겠어요 짧은 전자 여기에 xample? 나는 여기에 제안 된 (http://stackoverflow.com/questions/133710) 시도했지만 Maven 내부에서 작동하지 못했습니다. – yegor256

+0

maven antrun plugin은 두 개의 '' – yegor256

+2

@ yegor256을 허용하지 않습니다. 실제로 외부 Ant 파일을 사용하고 POM이''시간 소모적 인'대상을 호출한다고 가정합니다. –

2

에만 활성화의 <profile>를 사용 file.txt 경우 존재하지 않습니다

<profiles> 
    <profile> 
     <id>createFile</id> 
     <activation><file><missing>file.txt</missing></file></activation> 
     <build><plugins> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <version>1.6</version> 
       <!-- etc --> 
      </plugin> 

     </plugins></build> 
    </profile> 
</profiles> 

참조 :

+0

한 가지 문제가 있습니다. 'mvn clean test'를 실행하면 파일은 POM 초기화 중에 존재하지만'clean' 단계 후에 파손됩니다. 따라서 antrun 실행이 시작되지 않은 반면 필요한 ... 모든 생각? – yegor256

+0

@yegor 죄송합니다. 작동하는 방식입니다. 프로파일은 빌드가 시작되기 전에 평가되고 목표간에 다시 평가되지 않습니다. –