Phing: Exclude all directories except one

287 Views Asked by At

I'm trying to exclude all dirs which contain the string "export". Only one directory called "exportspecial" should be included.

This way "exportspecial" is still not included:

    <fileset dir="${dir.root}/plugins" id="something">
        <include name="abc/**" />
        <exclude name="abc/*export**" />            
        <include name="abc/exportspecial/**" />         
    </fileset>
1

There are 1 best solutions below

0
Siad Ardroumli On

You can use selectors

    <fileset dir=".">
        <include name="abc/**"/>
        <or>
            <filename name="**/exportspecial/**"/>
            <not>
                <filename name="**/*export*/**"/>
            </not>
        </or>
    </fileset>

Example build file:

<project name="selector-test" default="includeTest" basedir=".">
    <target name="includeTest" depends="prepare">
      <path id="export.path">
        <fileset dir=".">
          <include name="abc/**"/>
          <or>
            <filename name="**/exportspecial/**"/>
            <not>
              <filename name="**/*export*/**"/>
            </not>
          </or>
        </fileset>
      </path>
      <pathconvert pathsep="${line.separator}"
                   property="echo.include.path"
                   refid="export.path"/>
      <echo>${echo.include.path}</echo>
  </target>

  <target name="prepare">
    <touch file="abc/test/inc" mkdirs="true"/>
    <touch file="abc/exportspecial/inc" mkdirs="true"/>
    <touch file="abc/export/exc" mkdirs="true"/>
    <touch file="abc/inc"/>
  </target>

</project>