ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles Daniels" <c...@yahoo.com>
Subject RE: How to get package name for a directory?
Date Fri, 23 Jul 2004 04:25:25 GMT
> -----Original Message-----
> From: ralapa@spamex.com [mailto:ralapa@spamex.com]
> Sent: Friday, July 23, 2004 1:23 AM
> To: user@ant.apache.org
> Subject: How to get package name for a directory?
> 
> 
> 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.

Why would you do such a thing?

> 
> 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.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

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


Mime
View raw message