You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "sam.hendley" <sa...@summus.com> on 2007/02/08 01:46:59 UTC

Copying multiple source trees without loops

I have been hacking at this problem for about an hour and I have to believe
that there must just be something basic I am missing. I am rewriting our
build scripts to be more maintainable, useful and faster. I am trying to
avoid using antcontrib this time as all the loops and antcalls I had were
killing the performance of the script. Anyways here is the situation, I have
the source for different builds spread out over a few source directories
which I then collect in temporary directory before compiling. Lets say they
look like this: 
<pre>
app\
	shared\  main source tree
	custom1\ custom source tree1
	custom2\ custom source tree2
	devices\ holds the device specific source files
		device1\
		device2\
</pre>
Each directory contains contains a full package directory heirarchy so when
theyre all copied to the same place the packages will all line up. In my old
build system I did it like this:
<pre>
<target name="GetOneTree">
	<echo message="Checking ${base}/${dir} for ${includesList} minus
${excludesList} to ${outputDir}"
	/>
	<copy todir="${outputDir}" overwrite="true">
		<fileset dir="${base}/${dir}"
		         includes="${includesList}"
		         excludes="${excludesList}"
		/>
	</copy>
</target>
<target name="GetSources" if="src.outOfDate">
	<delete failonerror="false">
		<fileset dir="${temp.dir}/src" />
	</delete>
	<var name="includesList" value="${target.src.includesList}" />
	<var name="excludesList" value="${target.src.excludesList}" />
	<var name="outputDir" value="${src.tempDir}" />
	<foreach list="${target.src.dirList}"
	         target="GetOneTree"
	         param="dir"
	         inheritall="true"
	/>
</target>
</pre>

Where target.src.includesList would equal a list of the source directories I
would want to run through for that build. 
Example: target.src.includesList=src/,custom1/,devices/device1/

I feel like it should be possible to do something with patternset, mappers
and copy but I have had no luck in figuring it out yet. Anyone have any
ideas? Thanks.
-- 
View this message in context: http://www.nabble.com/Copying-multiple-source-trees-without-loops-tf3190728.html#a8857626
Sent from the Ant - Users mailing list archive at Nabble.com.


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


RE: Copying multiple source trees without loops

Posted by "sam.hendley" <sa...@summus.com>.
Disclaimer: This is for a J2ME porting system so it has some odd
requirements.

Thats a good suggestion for most projects but in this case the code in each
of the trees is not a compilable unit, I need the source files from all the
trees to get it to compile. I also have to do preproccessing on the source
files and I cant do that in-situ. So I definably need to get these trees
copied I just am trying to figure out the ant 1.7 way of doing it. Another
use I had for the GetOneTree method I had before is that I could use it for
collecting and configuring my resources as well. Example:
includesList for the resources:
app/res/LargeResources,app/res/sounds/,app/res/CommonResources
defualt includes for the resourses is: **/*.png,**/*.properties,**/*.mid
but If I want to just not include the large theme song I could add
excludes=**/Theme.mid and it wouldn't include the Theme.mid file. 

Another issue that occurs to me that may force me to use the older looped
methodology is that I could override source files and resources with new
files by putting the directory (or tree) at the end of the includesList and
if they were named the same it would overwrite them allowing my team more
flexability in configuring builds. 




Daffin, Miles (IT) wrote:
> 
> I think you may be making things too complicated for yourself. 
> 
> Why not just compile each tree in situ? If you want you can compile them
> into the same dest dir. You could even wrap the javac task in a macro
> and just pass the source dir to this as an attribute. Then just invoke
> the macro once for each tree. Its neat, fast and simple.
> 
> Miles
> 
>> -----Original Message-----
>> From: sam.hendley [mailto:sam.hendley@summus.com] 
>> Sent: Thursday 08 February 2007 00:47
>> To: user@ant.apache.org
>> Subject: Copying multiple source trees without loops
>> 
>> 
>> I have been hacking at this problem for about an hour and I 
>> have to believe that there must just be something basic I am 
>> missing. I am rewriting our build scripts to be more 
>> maintainable, useful and faster. I am trying to avoid using 
>> antcontrib this time as all the loops and antcalls I had were 
>> killing the performance of the script. Anyways here is the 
>> situation, I have the source for different builds spread out 
>> over a few source directories which I then collect in 
>> temporary directory before compiling. Lets say they look like this: 
>> <pre>
>> app\
>> 	shared\  main source tree
>> 	custom1\ custom source tree1
>> 	custom2\ custom source tree2
>> 	devices\ holds the device specific source files
>> 		device1\
>> 		device2\
>> </pre>
>> Each directory contains contains a full package directory 
>> heirarchy so when theyre all copied to the same place the 
>> packages will all line up. In my old build system I did it like this:
>> <pre>
>> <target name="GetOneTree">
>> 	<echo message="Checking ${base}/${dir} for 
>> ${includesList} minus ${excludesList} to ${outputDir}"
>> 	/>
>> 	<copy todir="${outputDir}" overwrite="true">
>> 		<fileset dir="${base}/${dir}"
>> 		         includes="${includesList}"
>> 		         excludes="${excludesList}"
>> 		/>
>> 	</copy>
>> </target>
>> <target name="GetSources" if="src.outOfDate">
>> 	<delete failonerror="false">
>> 		<fileset dir="${temp.dir}/src" />
>> 	</delete>
>> 	<var name="includesList" value="${target.src.includesList}" />
>> 	<var name="excludesList" value="${target.src.excludesList}" />
>> 	<var name="outputDir" value="${src.tempDir}" />
>> 	<foreach list="${target.src.dirList}"
>> 	         target="GetOneTree"
>> 	         param="dir"
>> 	         inheritall="true"
>> 	/>
>> </target>
>> </pre>
>> 
>> Where target.src.includesList would equal a list of the 
>> source directories I would want to run through for that build. 
>> Example: target.src.includesList=src/,custom1/,devices/device1/
>> 
>> I feel like it should be possible to do something with 
>> patternset, mappers and copy but I have had no luck in 
>> figuring it out yet. Anyone have any ideas? Thanks.
>> --
>> View this message in context: 
>> http://www.nabble.com/Copying-multiple-source-trees-without-lo
> ops-tf3190728.html#a8857626
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>> 
>>
> --------------------------------------------------------
> 
> NOTICE: If received in error, please destroy and notify sender. Sender
> does not intend to waive confidentiality or privilege. Use of this email
> is prohibited when received in error.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Copying-multiple-source-trees-without-loops-tf3190728.html#a8873267
Sent from the Ant - Users mailing list archive at Nabble.com.


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


RE: Copying multiple source trees without loops

Posted by "Daffin, Miles (IT)" <Mi...@morganstanley.com>.
I think you may be making things too complicated for yourself. 

Why not just compile each tree in situ? If you want you can compile them
into the same dest dir. You could even wrap the javac task in a macro
and just pass the source dir to this as an attribute. Then just invoke
the macro once for each tree. Its neat, fast and simple.

Miles

> -----Original Message-----
> From: sam.hendley [mailto:sam.hendley@summus.com] 
> Sent: Thursday 08 February 2007 00:47
> To: user@ant.apache.org
> Subject: Copying multiple source trees without loops
> 
> 
> I have been hacking at this problem for about an hour and I 
> have to believe that there must just be something basic I am 
> missing. I am rewriting our build scripts to be more 
> maintainable, useful and faster. I am trying to avoid using 
> antcontrib this time as all the loops and antcalls I had were 
> killing the performance of the script. Anyways here is the 
> situation, I have the source for different builds spread out 
> over a few source directories which I then collect in 
> temporary directory before compiling. Lets say they look like this: 
> <pre>
> app\
> 	shared\  main source tree
> 	custom1\ custom source tree1
> 	custom2\ custom source tree2
> 	devices\ holds the device specific source files
> 		device1\
> 		device2\
> </pre>
> Each directory contains contains a full package directory 
> heirarchy so when theyre all copied to the same place the 
> packages will all line up. In my old build system I did it like this:
> <pre>
> <target name="GetOneTree">
> 	<echo message="Checking ${base}/${dir} for 
> ${includesList} minus ${excludesList} to ${outputDir}"
> 	/>
> 	<copy todir="${outputDir}" overwrite="true">
> 		<fileset dir="${base}/${dir}"
> 		         includes="${includesList}"
> 		         excludes="${excludesList}"
> 		/>
> 	</copy>
> </target>
> <target name="GetSources" if="src.outOfDate">
> 	<delete failonerror="false">
> 		<fileset dir="${temp.dir}/src" />
> 	</delete>
> 	<var name="includesList" value="${target.src.includesList}" />
> 	<var name="excludesList" value="${target.src.excludesList}" />
> 	<var name="outputDir" value="${src.tempDir}" />
> 	<foreach list="${target.src.dirList}"
> 	         target="GetOneTree"
> 	         param="dir"
> 	         inheritall="true"
> 	/>
> </target>
> </pre>
> 
> Where target.src.includesList would equal a list of the 
> source directories I would want to run through for that build. 
> Example: target.src.includesList=src/,custom1/,devices/device1/
> 
> I feel like it should be possible to do something with 
> patternset, mappers and copy but I have had no luck in 
> figuring it out yet. Anyone have any ideas? Thanks.
> --
> View this message in context: 
> http://www.nabble.com/Copying-multiple-source-trees-without-lo
ops-tf3190728.html#a8857626
> Sent from the Ant - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
>
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

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