Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:47:00+00:00 2026-06-04T12:47:00+00:00

I need to include all xml files inside a directory (I dont know the

  • 0

I need to include all xml files inside a directory (I dont know the name, and count of files) in my current build.xml using ImportTask.

This is my build.xml file:

<?xml version="1.0" encoding="utf-8"?>
<project name="New Project" basedir="." default="myimport">
    <target name="myimport" description="dummy to import other build files">
        <if>
            <isset property="file" />
            <then>
                <echo msg="Importing ${file}" />
                <import file="${file}" />
            </then>
        </if>
    </target>

    <if>
        <not>
            <isset property="dummy.property" />
        </not>
        <then>
            <echo msg="Now include all files in ./dev/build directory" />
            <property name="dummy.property" value="true" />
            <foreach param="msg" absparam="file" target="myimport">
                <fileset dir="./dev/build/">
                    <include name="*.xml"/>
                </fileset>
            </foreach>
        </then>
    </if>
</project>

and an example file in target directory:

<?xml version="1.0" encoding="utf-8"?>
<project name="test" basedir="." default="dummy">
    <target name="dummy" description="Dummy task">
        <echo msg="Dummy task, just for test" />
    </target>

    <echo msg="Imported!" />
</project>

when I run phing -l the result is:

Buildfile: /home/f0rud/workspace/s/build.xml
     [echo] Now include all files in ./dev/build directory
  [foreach] Calling Buildfile '/home/f0rud/workspace/s/build.xml' with target 'myimport'

New Project > myimport:

     [echo] Importing ./dev/build/test.xml
     [echo] Imported!
Default target:
----------------------------------------------------------------------------
 myimport  dummy to import other build files

Main targets:
----------------------------------------------------------------------------
 myimport  dummy to import other build files

But there is no dummy (or test.dummy) target, why?

Note : There is a funny bug, if I remove the if part, I get Maximum function nesting level of '100' reached, aborting! error but thats not my problem (the if solve that problem.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:47:01+00:00Added an answer on June 4, 2026 at 12:47 pm

    The problem is import work on global context.

    When I call it inside a target, its not available in global context.

    So I’ve written a simple Phing task to load all files of a fileset like so:

    class ImportDirTask extends Task {
    
        /** Array of filesets */
        private $filesets = array();
    
        /**
         * Nested creator, adds a set of files (nested fileset attribute).
         */
        function createFileSet() {
            $num = array_push($this->filesets, new FileSet());
            return $this->filesets[$num-1];
        }
    
      /**
       * Parse a Phing build file and copy the properties, tasks, data types and 
       * targets it defines into the current project.
       *
       * @return void
       */
      public function main () {
        // filesets
        foreach ($this->filesets as $fs) {
            $ds       = $fs->getDirectoryScanner($this->project);
            $srcFiles = $ds->getIncludedFiles();
            $srcDirs  = $ds->getIncludedDirectories();
            foreach ($srcFiles as $f)
            {
                $task = new ImportTask();
                $task->setProject($this->project);
                $task->init();
                $task->setFile($this->file = $fs->getDir($this->project) . FileSystem::getFileSystem()->getSeparator() . $f);
                $task->main();
            }
    
         }
      } //end main
    
    } //end ImportDirTask
    

    It just work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using NHibernate in our project and need all .hbm.xml files to be
I'm using Enunciate to build a prototype REST api and need to include a
Programaticly, I need to include a google Maps map to automaticly generated pdf files.
I need xml file for indexing my website for google crawling. I'm using some
I need to include a header graphic in all of my activities/views. The file
short: I need to filter all .java files and every META-INF folder from a
I need to include some kind of notifications in a sidebar gadget, preferably systray
I need to include a dashboard in a JavaScript application I am building. The
I have a prototype model where I need to include the following extension methods
I'm packaging an ejb and I need to include some .classes from a dependency

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.