ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ellsworth <sc...@alodar.com>
Subject Critique my optional file copy target, please?
Date Mon, 04 Feb 2002 20:17:51 GMT
Hi, all.

Our builds have source and build in the same hierarchy, but are moving 
to the more usual source separate from build.  Once we do that, we will 
get rid of some legacy cruft, but for at least the next few months, we 
will need to have both, and since we have one site-wide set of build 
targets, they need to be flexible.

E.g:

Now:
com
   us
     build
       build.xml
     somesrc.java

Soon:
project
   build
     build.xml
   src
     com
       us
         somesrc.java

Since I do not want it to recompile the world, and there are java files 
in the old structure I do NOT want to have compiled, the old projects 
all copy the source to a separate directory before compiling.

<target name="copy" depends="init">
   <mkdir dir="${compile.source}"/>
   <copy todir="${compile.source}" preservelastmodified="on">
     <fileset dir="${src}" includes="${build.includedFiles}" />
   </copy>
</target>

<target name="compile" depends="copy" />

The new projects do not need to do this copy, and our rule is that if 
you put a file is a new project, it WILL be compiled.  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.

(If it is different, then I should probably not only overwrite the 
temporary compilation source directory files, but delete the directory 
and copy fresh.)

What is the easiest way to rewrite the target?  I thought of using if, 
something like:

<target name="copy-setup" depends="init">
   <condition property="copy.needed" >
       <equals arg1="${compile.src}" arg2="${src}" />
   </condition>
</target>

<target name="copy" depends="init" if="copy.needed">
   <rmdir dir="${compile.source}"/ >
   <mkdir dir="${compile.source}"/>
   <copy todir="${compile.source}" preservelastmodified="on">
     <fileset dir="${src}" includes="${build.includedFiles}" />
   </copy>
</target>

<target name="compile" depends="copy-setup, copy" />

My questions are:

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?

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?

Meta-question 3.  If you ran across this setup at a client, would you 
find it an acceptable solution to the transition layout, and the need 
for only ONE set of standard targets included into all build files, or 
would you scream in anguish about it?

Scott


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


Mime
View raw message