ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: How to get package name for a directory?
Date Fri, 23 Jul 2004 14:13:43 GMT
> From: ralapa@spamex.com [mailto:ralapa@spamex.com]
> 
> 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.
> <pre>
> <project name="api/abc" default="compile" basedir=".">
>     <property name="TOP" value="../../.."/>
> 
>     <!-- compile all subdirectories -->
>     <target name="compile">
>         <echo>package: ${ant.project.name}</echo>
>         <property name="compile.dir" value="${basedir}"/>
>         <ant dir="${TOP}/build" target="compile" inheritAll="true"/>
>     </target>
> </project>
> </pre>
> The "compile" target sets the "compile.dir" property, and then calls
> the "compile" target in the master build.xml located in $(TOP)/build.
> 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.
> 
> <pre>
> <project name="${ant.package.name}" basedir=".">
>        <property name="TOP" value="../${ant.package.path}"/>
> ...
> </project>
> </pre>
> 
> 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 guess I could create a custom task
> which,
> given a directory containing a java package, it could parse the package
> statements in the .java source files to find out the package name.
> 
> 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.

As Charles as said, what you describe seems very un-Ant, meaning that is
does not sound like you approach building your system using Ant the
classical (canonical) way.

You may want to describe your file/project structure some more so folks on
this list can advise you on perhaps a better build system...

That said, a master build that calls sub-builds, that call back the master
build sounds like a pre-Ant 1.6 organization. Nowdays, you'd have the master
build call the sub-builds using <subant>, and the sub-builds <import>ing the
common part from the build, and doing the work themselves.

Good luck. --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message