ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin McGinn" <kmcg...@entradasoftware.com>
Subject Re: pointer on making <copy> fail on file not found
Date Wed, 26 Jun 2002 17:02:11 GMT
I noticed in your code clip that make use of the <foreach> task. What
version of ant are you using? I am uisng the 1.5.1 Beta, but I can not find
any reference to that task in either the documentation or the include jar
files. I have use for such a task if I can determine which version of ant
contains that task.


Kevin McGinn
----- Original Message -----
From: "Diane Holt" <holtdl@yahoo.com>
To: "Ant Developers List" <ant-dev@jakarta.apache.org>
Sent: Wednesday, June 26, 2002 9:12 AM
Subject: Re: pointer on making <copy> fail on file not found


> --- Michael Slass <mikesl@wrq.com> wrote:
> > Thanks for the workaround; I agree that your solution will work, but
> > it seems a bit cumbersome in terms of additional tags added to
> > build.xml.
>
> Well, much of Ant "seems a bit cumbersome in terms of additional tags" :)
>
> But, really, in this case, it's not as bad as you think it might be -- eg:
> <target name="copy">
>   <property name="src.dir" location="some/source/dir/foo"/>
>   <property name="files.list" value="README,LICENSE,GPL,INSTALL,COPYING"/>
>   <foreach list="${files.list}" param="file" target="chkFile"/>
>   <fileset dir="${src.dir}" id="fs1">
>     <patternset id="ps1">
>       <include name="**/*.class"/>
>     </patternset>
>   </fileset>
>   <pathconvert pathsep="" refid="fs1" property="fs1"/>
>   <fail unless="fs1">
>     Error: No class files found! Exiting...
>   </fail>
>   <copy todir="some/target/dir">
>     <fileset dir="${src.dir}" includes="${files.list}">
>       <patternset refid="ps1"/>
>     </fileset>
>   </copy>
> </target>
>
> <target name="chkFile">
>   <available file="${src.dir}/${file}" type="file" property="found"/>
>   <fail unless="found">
>     Error: File ${file} not found! Exiting...
>   </fail>
> </target>
>
> > The solution I envision would allow the failure to occur if any files
> > or filesets in a copy task were not found, just by modifying the copy
> > task:
> [snip]
> > In this instance, I'd like it to fail if any of the explicitly-named
> > files are not found, or if there are no .class files found under the
> > foo directory, just by setting the strictfind property to "true".
> [snip]
> > Again, I've posted to the dev list, because I'm quite willing to take
> > a crack at hacking the ant code to do this.  I do, however, need some
> > pointers at where I should be looking.
>
> It looks like you could just add an "else" to the "if" that starts out
> doFileOperations() -- but that'd only give you an opportunity to say that
> "some" file(s) was/were missing; whereas, the specific checks in my
> approach will let you say exactly what's missing. To get Copy to check and
> error out for specific files would take a lot more digging into the source
> -- so if you want to go that way, good luck :) (Note: I suspect your added
> functionality could well clash with the includeEmptyDirs attribute, though
> -- but that's just a guess.)
>
> Diane
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
>
>


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


Mime
View raw message