* @param file
*/
public void setContextProperties( String file )
{
String[] sources = StringUtils.split(file,",");
contextProperties = new ExtendedProperties();
// Always try to get the context properties resource
// from a file first. Templates may be taken from a JAR
// file but the context properties resource may be a
// resource in the filesystem. If this fails than attempt
// to get the context properties resource from the
// classpath.
for (int i = 0; i < sources.length; i++)
{
ExtendedProperties source = new ExtendedProperties();
try
{
// resolve relative path from basedir and leave
// absolute path untouched.
File fullPath = project.resolveFile(sources[i]);
log("Using contextProperties file: " + fullPath);
source.load(new FileInputStream(fullPath));
}
catch (IOException e)
{
ClassLoader classLoader = this.getClass().getClassLoader();
try
{
InputStream inputStream = classLoader.getResourceAsStream(sources[i]);
if (inputStream == null)
{
throw new BuildException("Context properties file " + sources[i] +
" could not be found in the file system or on the classpath!");
}
else
{
source.load(inputStream);
}
}
catch (IOException ioe)
{
source = null;
}
}
if (source != null)
{
for (Iterator j = source.getKeys(); j.hasNext(); )
{
String name = (String) j.next();
String value = StringUtils.nullTrim(source.getString(name));
contextProperties.setProperty(name,value);
}
}
}
}