ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "W. Sean Hennessy" <shenne...@goldenhourdata.com>
Subject RE: Warn for includes not found?
Date Thu, 02 Oct 2003 19:42:30 GMT
Identifying files which do not exist is a bit different than collecting files which do not
match a filter.
A FileSet is filtered which results in (Mispeled.java) being left out of the selection.
Using foreach one can iterate through a FileList and check each file explicitly.
Example below demonstrates FileList iteration.
If you can generate a FileList from patternset you're almost there...

<?xml version="1.0"?>
<project name="trythis" default="chkthefiles" basedir=".">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
  <classpath>
       <pathelement location="C:/Tools/ant-contrib-0.3/lib/ant-contrib-0.3.jar" />
  </classpath>
</taskdef>

  <property name="bandeirabr.logic" value="${basedir}"/>

  <patternset id="bandeirabr.logic">
    <include name="${bandeirabr.logic}/Role.java"/>
    <include name="${bandeirabr.logic}/User.java"/>
    <include name="${bandeirabr.logic}/UserException.java"/>
    <include name="${bandeirabr.logic}/Mispeled.java"/>
  </patternset>

  <filelist dir="${bandeirabr.logic}" id="bandeirabr.flist" files="Role.java User.java
UserException.java Mispeled.java"
/>


<target name="chkthefiles"
 description="check through filelist.">
  <foreach param="iterFilespec" target="tstfileexits">
   <path>   
       <filelist refid="bandeirabr.flist" />
   </path>
  </foreach>
</target>
<target name="tstfileexits"
   description="test barks if param iterFilespec does not exist.">
<!-- -->
<if>
<not><available file="${iterFilespec}" /></not>
<then>
<echo message="${iterFilespec} does not exist!" />

</then>
</if>
</target>
</project>

-----Original Message-----
From: Leonardo Abreu de Barros [mailto:leobarros@email.com] 
Sent: Wednesday, October 01, 2003 11:33 AM
To: ant-user@jakarta.apache.org
Subject: Re: Warn for includes not found?


Hi Sean,

I'm not sure if I understand your answer, so I'm sending you a snippet to get things clearer.

I have the following xml: 
  <!-- Package bandeirabr.logic -->
  <property name="bandeirabr.logic" value="bandeirabr/logic"/>
  <patternset id="bandeirabr.logic">
    <include name="${bandeirabr.logic}/Role.java"/>
    <include name="${bandeirabr.logic}/User.java"/>
    <include name="${bandeirabr.logic}/UserException.java"/>
    <include name="${bandeirabr.logic}/Mispeled.java"/>
  </patternset>

  <target name="compile" depends="update">
    <javac srcdir="${src}" destdir="${build}" listfiles="true">
      <patternset refid="bandeirabr.logic"/>
    </javac>
  </target>

As you may see, the file "Mispeled.java" is missing an "l". In consequence of this, it doesn't
get compiled. What I need
is something that warns the programmer about his mistake.

thanks,
Leonardo.

--- In apache-ant@yahoogroups.com, "W. Sean Hennessy" <shennessy@g...>
wrote:
> Would not an exclude patternset help to identify file(s) that do not
match the naming convention in the javac patternset
> as a result of misspellings?
> The build.xml could then generate a warning if the exclude
patternset is not empty.
> 
> -----Original Message-----
> From: Leonardo Abreu de Barros [mailto:leobarros@e...]
> Sent: Wednesday, October 01, 2003 8:14 AM
> To: ant-user@j...
> Subject: Warn for includes not found?
> 
> 
> Hi all,
> 
> I was requested to do something that I'm not sure if it's possible
using Ant... People here are giving a patternset to
> the javac task of source files to be compiled; this is because they
want to be allowed to have other java files in the
> source directories, test files for example, that shouldn't be
compiled during the project build. The problem is: when
> someone mispells a file name, Ant ignores it. As a result, the right
file isn't compiled. So, they want Ant to warn or
> crash when some include file is not found. Is there a simple way to
accomplish this?
> 
> thanks,
> Leonardo A. Barros
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@a...
> For additional commands, e-mail: user-help@a...
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@a...
> For additional commands, e-mail: user-help@a...


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


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


Mime
View raw message