Matt, Many thanks! It will be a few days before I can give this a trial run, but I will let you know how it goes, post updates back to the list, etc.
John-Mason Shackelford Software Developer NCS Pearson - Measurement Services 2510 North Dodge St. Iowa City, IA 52245 319-354-9200x6214 [EMAIL PROTECTED] > -----Original Message----- > From: Matt Benson [mailto:[EMAIL PROTECTED]] > Sent: Thursday, August 08, 2002 3:44 PM > To: Ant Users List > Subject: Re: Fix Package Structure > > > I was interested when I first saw this post, but > didn't know any way to do it without first being able > to iterate over the elements of a FileSet. I was very > close to writing a task called foreach to do this. > Having thought about it, I couldn't see any practical > way to implement it other than having it call other > Ant tasks. Today from the list I learned that someone > else had already had the same idea! Including lists > as well as FileSets is an improvement over what I had > thought of as well. > > The result is that this is VERY hacked together, but > it works using Ant core and optional tasks, plus > ant-contrib's foreach task to move Java files to their > proper place in a directory hierarchy based on their > package statements. Very likely it could be improved > upon: > > <project name="test" default="packagejava" > basedir="."> > > <taskdef > resource="net/sf/antcontrib/antcontrib.properties"/> > > <property environment="env" /> > <property name="flat.dir" value="src" /> > <property name="pkg.dir" value="pkgdsrc" /> > <property name="tmp.dir" value="tmp" /> > > <target name="clean"> > <delete dir="${pkg.dir}"/> > </target> > > <target name="packagejava"> > <property name="package" value="x" /> > <foreach target="copyjava" param="javafile" > inheritall="false"> > <fileset dir="${flat.dir}" > includes="**/*.java" /> > <param name="dest.dir" value="${pkg.dir}" /> > </foreach> > > </target> > > <target name="checkpackage"> > > <mkdir dir="${dest.dir}" /> > > <echo message="movejava: processing file > ${javafile}." /> > > <loadproperties srcfile="${javafile}"> > <filterchain> > > <stripjavacomments /> > > <linecontainsregexp> > <regexp pattern="^package" /> > </linecontainsregexp> > > <striplinebreaks linebreaks=";" /> > > </filterchain> > </loadproperties> > > <condition property="validpackage"> > <isset property="package" /> > </condition> > > </target> > > <target name="setpkgdir" if="validpackage"> > <mkdir dir="${tmp.dir}" /> > <echo message="packagedir=${package}" > file="${tmp.dir}/pkgdir.dat" /> > <replace file="${tmp.dir}/pkgdir.dat" token="." > value="/" /> > <loadproperties srcfile="${tmp.dir}/pkgdir.dat" /> > <delete dir="${tmp.dir}" /> > <copy file="${javafile}" > todir="${pkg.dir}/${packagedir}" /> > </target> > > <target name="blankpkgdir" unless="validpackage"> > <mkdir dir="${tmp.dir}" /> > <echo message="packagedir=" > file="${tmp.dir}/pkgdir.dat" /> > <replace file="${tmp.dir}/pkgdir.dat" token="." > value="/" /> > <loadproperties srcfile="${tmp.dir}/pkgdir.dat" /> > <delete dir="${tmp.dir}" /> > <copy file="${javafile}" todir="${pkg.dir}" /> > </target> > > <target name="copyjava" > depends="checkpackage,setpkgdir,blankpkgdir" /> > > </project> > > > -Matt > > > --- "Shackelford, John-Mason" <[EMAIL PROTECTED]> wrote: > > Does anyone know of a task or utility available to > > fix the package structure > > on a source tree? > > > > I am generating javadocs with 1.4 which crashes when > > the package structure > > is wrong, but links in the source code--a feature I > > really like. The javadoc > > creation process runs from cron, and I can't afford > > to have one package name > > mistake break the whole thing. I've hacked together > > a perl script that will > > move files / create directories as necessary, but > > I'd really like to move > > this process into my ant buildfile so that it will > > be available to all. > > > > Any ideas? > > > > > > John-Mason Shackelford > > > > Software Developer > > NCS Pearson - Measurement Services > > 2510 North Dodge St. > > Iowa City, IA 52245 > > 319-354-9200x6214 > > [EMAIL PROTECTED] > > > > -- > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > __________________________________________________ > Do You Yahoo!? > HotJobs - Search Thousands of New Jobs > http://www.hotjobs.com > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
