My application has many properties/text configuration files. Is there a common way to validate these kind of files? May be some tools or something like xsd?
The files are large (more 1000 rows), so I frequently make mistake. Information in file in majority of cases – is path to different directories. So it will be good if they exist and are consistent. E.g.
if I have
mydata.root="c:\data"
and after I have:
myreports=${mydata.root}/reports
that will be good check that c:\data and c:\data\report exist
and not written (some hundreds rows down) e.g.
myreports=${mdata.root}/reports
You could do this validation in your build file.
For example, the following build file defines a macrodef
validate-file-propertywhich validates that a specified property is defined and that it exists as a file or dir in the file system.You need to decide when to validate the properties, and you need to validate them explicitly – as shown in the
inittarget in this example.BTW, if you used a standardized pattern to name properties which refer to files or directories – e.g.
my.special.file,my.build.dir– then you could use a shell script to discover all relevant properties and write all yourvalidate-file-propertyelements . Something like this:You could paste the output into your build file.