ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ellsworth <>
Subject Re: Critique my optional file copy target, please?
Date Tue, 05 Feb 2002 17:00:37 GMT

Hi, Stefan.  Thank you for the commentary and critique.

On Tuesday, February 5, 2002, at 02:47  AM, Stefan Bodewig wrote:

> On Mon, 4 Feb 2002, Scott Ellsworth <> wrote:
>> One way to do this is to sent compile.scr to the same as src, and to 
>> make the copy phase only do the delete and copy if it actually needs 
>> to.
>> <target name="copy" depends="init" if="copy.needed">
>>    <rmdir dir="${compile.source}"/ >
> wouldn't that delete the "new" sources that follow your new layout or 
> is <rmdir> a shortcut for a task that knows which files to delete and 
> which to leave alone?

The copy.needed property should only be set for the old sources.  
Assuming my copy-setup target properly does not set it for projects in 
the new layout, the entire copy target will not happen for a new layout 
project because of the if.  Thus, for new sources, the deletion of the 
directory will not happen, but for old sources, the entire 
compile.source directory (into which I copied the contents of the src 
directory) will vanish and be recopied.

>> 1.  Would it be better to do
>> <target name="copy" depends="copy-setup" if="copy.needed">
>> as then the no other target needs to be changed?
> I think so - especially since the if attribute doesn't make any sense
> unless the copy-setup target has been run, there is a logical
> dependency between these two targets - much stronger than between your 
> copy-setup and the compile target IMHO.

Makes sense.  I just wanted to make sure that it will check the if= part 
to decide whether to perform the copy target AFTER running the 
copy-setup target.

>> 2.  Is this the best way to handle this situation where two
>> different layouts exist, and I really want to use the same set of
>> targets for both layouts?
> I don't think so - some creative use of multiple <src> elements in
> <javac> or two separate <javac>s together with includes on the <javac>

> task(s) seems better to me - don't copy sources at all.

I cannot avoid a copy with the old layout, I believe, if I want javac to 
only compile the sources I tell it to, and not others in the same com 

The "src" property is set to the for-real sources both when the build 
files are in the source tree among the java files (old layout), and when 
they are separate (new layout).

A copy files task is needed with the old layout to prevent "why does ant 
recompile all of my source files" and to prevent it from finding classes 
I do not want it to.  Under the old layout, if someone happened to 
import a file they were not supposed to under the same com tree, javac 
would go find it.  This is normally what you want, but in this case, I 
do not.

The right solution is the new layout, but it will take a while to 
transition.  Of course, someone could add a package they are not 
supposed to with the new layout as well, but we are pretty aggressive 
about preventing that, and it is easier to spot.

Thanks again, Stefan, as making ant happy was one of the drivers for 
this transition.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message