Changing directories and list of directories in variable
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rasheed_Muhammad
Posted On:   Tuesday, December 9, 2003 05:14 AM

I have to replace a develpoment and deployment system using make with ant. I have a hirecrchical package structure of source files which contained a make file at each level and the rules I had defined would recursively traverse each level, use the makefile present there and make the given targets. Now I am trying to replace each makefile at each level with a build.xml file. These files defines some variables like package_dir, subpackages (a list of subdirs), or at inner levels a variable source_files (list of .java files to be compiled). What I want to do here is that When I run any target from top level I would like to get the list of directories in a variable and go into every directory recursively using cd    More>>

I have to replace a develpoment and deployment system using make with ant. I have a
hirecrchical package structure of source files which contained a make file at each level and the rules I had defined would recursively traverse each level,
use the makefile present there and make the given targets. Now I am trying to replace each makefile at each level with a build.xml file.
These files defines some variables like package_dir, subpackages (a list of subdirs), or at inner levels a variable
source_files (list of .java files to be compiled). What I want to do here is that
When I run any target from top level I would like to get the list of
directories in a variable and go into every directory recursively using
cd command and execute the ant task using that level build.xml file.
There are 2 things which i'm not able to do.
1- Get the list of directories or files exists in a particular directory
into a variable.
2- Iterate the directories in the variable and go inside the directory and
execte the ant task using that level build.xml file.

Has anybody done a similar thing with ant? I will appreciate all feedback.

   <<Less

Re: Changing directories and list of directories in variable

Posted By:   Anonymous  
Posted On:   Saturday, December 20, 2003 09:58 AM

You might want to do the following :


  • download ant 1.6.0 to get started with an upto date system,

  • for each package or subproject, create a build.xml file
    this build.xml can include a common file containing for instance property definitions valid for all projects (see the import task documentation .

  • use the subant task to recurse into each project/subproject.



Converting a list of files into a variable : you can define a fileset in ant, then convert its contents to a property using the path convert task.



Cd ing into one directory, this is implemented in ant by tasks like or which allow you to execute another build file, optionally with a new base directory.



You might also be interested in using a combination of gump and ant.



Cheers,


Antoine.

Re: Changing directories and list of directories in variable

Posted By:   Jim_Tootell  
Posted On:   Monday, December 15, 2003 12:10 PM

I'm doing a similar project and what I've found is there is no need to use 'cd' to manually traverse your subdirectories. When using, for example, the 'javac' task you can specify your 'includes' attribute like this: '/**/*.java'. The double asterisk tells Ant to recursively scan a directory and its subdirectories for .java files to compile. Just specify a top level directory Ant will find the rest. If you really want to keep everything in separate build.xml files, look into the task and the 'loadProperties' attribute. I also recommend the Sam's Ant Developer's Handbook (ISBN: 00672324261, Williamson/Pepperdine/Gibson/Wu).

Good luck.

Re: Changing directories and list of directories in variable

Posted By:   Eugene_Kuleshov  
Posted On:   Tuesday, December 9, 2003 09:38 AM

If you want to port your makefiles directly, there are 3rd party project that provides such tasks. http://ant-contrib.sourceforge.net/tasks/index.html



But it will be better to rethink your build process and use single build file for the whole project.
About | Sitemap | Contact