Está en: Home >> ISDirValidator >> ISDirValidator Presentation
SourceForge Logo
En Español

Página... ISDirValidator Presentation


IsDirValidator is an utility and Ant´s task to validate directory structures. It permit to define directorys and what files can exist.

The situation that this utility whan to handle is the fullfil of the requeriments about the structure of the folders in computers that provide hosting of applications.

An example:

<taskdef name="isdirectory" 
<taskdef name="isfile" 
<taskdef name="isfilepatterm" 
<taskdef name="issubdirectorypatterm"

<isdirectory dir="folder" />

<isdirectory dir="..\ISDirCheck\" recursive="yes" >
	<isfile file="build.xml" required="yes" />
	<isfile file="Definition.txt" required="no" />
	<isfilePatterm filePatterm="^[a-z]+\.txt$" />
	<isfilePatterm filePatterm=".*\.xml$" />
	<issubdirectoryPatterm directoryPatterm="^[a-zA-Z]+$" />

The frist task is the simplest form and checks that the directory "folder" exist. It takes the basedir of the Ant's project as the path

The second task chack that the directory "ISDirCheck" exist. It takes the parent of the ant´s basedir as the path. It also check that some conditions are fullfill:

  • The build.xml file must exist
  • It can exist a file with name "Definicion.txt", but it is not obligatory (The attribute "required" could be ommited because this is its default value).
  • It can exist files that match the regular expression "^[a-z]+\.txt", files with its name in lowercase and with the extension txt. (See the regExp documentation to see the posibilities about the regular expressions)
  • It can exisit files that match the regular expression ".*\.xml", files with a xml extension and the name acepts any caracter.
  • This directory can has subdirectories with its name filling the patterm "^[a-z]+$", so only lowercase name.

If exist one file that dosen´t fullfill at least one of this conditions then it is an error

If the attribute recursive is on the all the subdirectories must fill all the conditions of the parent.

For example if exist the files:

  • myPage.htm
  • Hello.txt

If the file "build.xml" dosen´t exist it is also an error.

The use of regular expressions is provided by the RegExp packaque of in the version 1.2. You can obtain more information about this package in the web

Another example of use coud be the definition of the structure of a Servlet's WAR folder (This example is not complet)

<isdirectory dir="${path}">
	<isfilePatterm filePatterm="^[a-zA-Z]+\.jsp$" />
	<isfilePatterm filePatterm="^[a-zA-Z]+\.html$" /> 

<isdirectory dir="${path}/META-INF">
	<isfile file="MANIFEST.MF" required="yes" />

<isdirectory dir="${path}/WEB-INF">
	<isfile file="web.xml" required="yes" />
	<isfilePatterm filePatterm="^[a-zA-Z-]+\.tld$" />

<isdirectory dir="${path}/WEB-INF/classes" recursive="yes" >
	<isfilePatterm filePatterm="^[:alnum:]+\.properties$" />
	<isfilePatterm filePatterm="^[:alnum:]+\.class$" />
	<issubdirectoryPatterm directoryPatterm="^[a-zA-Z]+$" />

Version 2

Version 2 of this packaqe adds the support of subdirectorypatter and the recursive attribute and some minors changes to fix bugs. The recursive and required attributes have been changed to support the conventions of Ant (yes, true or no) to activate it.


To install this package you must put the ISDirValitator and the regExp in the CLASSPATH


You can download IsDirValidator in the general download page

Iñigo Serrano todos los derechos reservados.
Queda prohibida la reproducción total o parcial del contenido aquí expuesto.