The moose likes Ant, Maven and Other Build Tools and the fly likes How to get package name for a directory? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "How to get package name for a directory?" Watch "How to get package name for a directory?" New topic
Author

How to get package name for a directory?

Ann Bernstein
Greenhorn

Joined: Jul 21, 2004
Posts: 1
Hi,
I have a very large projectd with 300 packages and 1000s of source files. In each package, we created a build.xml file for that package.
We also have a master build.xml file under our <workspace>/build directory which has targets to rebuild all the packages by invoking the "compile" target on all 200 build.xml files.

Everything works, but I am trying to see if there is a way to simplify the build.xml files in each directory, so that it is even easier to add a new build.xml for a new package.

Here is an example build.xml that is in each package directory.



I am trying to find some way to make the assignement of project name and the TOP variable automatic. I want to do something like.



For the package api.abc, I would need
${ant.package.name} = api.abc
${ant.package.path} = api/abc

Is there anyway for me to construct this information based on the basedir, or would this require a custom task?

I would think this would be a commmon request, but I can't find any builtin tasks or predefined variables which would help me find out the java package name or base path for the package.
I found BaseName and DirName but these are very limited.
 
 
subject: How to get package name for a directory?
 
Threads others viewed
Ant, windows xp, and a funky infinite loop
Beginner problem
automatically echo project name for each task
HOW TO COMPILE JAVA FILES PROGAMMATICALLY
echo classpath in build
developer file tools