문제

이름에 "TMP"가 포함 된 루트 디렉토리에서 모든 디렉토리 및 하위 디렉토리를 삭제하고 싶습니다. 여기에는 .SVN 파일도 포함되어야합니다. 나의 첫 번째 추측은 사용하는 것입니다

<delete>
    <dirset dir="${root}">
          <include name="**/*tmp*" />
    </dirset>
</delete>

이것은 당신이 둥지를 둘 수 없으므로 작동하지 않는 것 같습니다. dirset 안에 delete 꼬리표.

이것이 올바른 접근법입니까, 아니면 다른 일을해야합니까?

  • 개미 버전 == 1.6.5.
  • Java 버전 == 1.6.0_04
도움이 되었습니까?

해결책

Here's the answer that worked for me:

<delete includeemptydirs="true">
    <fileset dir="${root}" defaultexcludes="false">
       <include name="**/*tmp*/**" />
    </fileset>
</delete>

I had an added complication I needed to remove .svn directories too. With defaultexcludes, .* files were being excluded, and so the empty directories weren't really empty, and so weren't getting removed.

The attribute includeemptydirs (thanks, flicken, XL-Plüschhase) enables the trailing ** wildcard to match the an empty string.

다른 팁

try:

<delete includeemptydirs="true">
    <fileset dir="${root}">
          <include name="**/*tmp*/*" />
    </fileset>
</delete>

ThankYou flicken !

I just wanted to add that the part of the solution that worked for me was appending /** to the end of the include path. I tried the following to delete Eclipse .settings directories:

<delete includeemptydirs="true">
    <fileset dir="${basedir}" includes"**/.settings">
</delete>

but it did not work until I changed it to the following:

<delete includeemptydirs="true">
    <fileset dir="${basedir}" includes"**/.settings/**">
</delete>

For some reason appending /** to the path deletes files in the matching directory, all files in all sub-directories, the sub-directories, and the matching directories. Appending /* only deletes files in the matching directory but will not delete the matching directory.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top