this.printLine();
this.printText(MARGIN + bannerStart + " A n d r o M D A P o w e r e d A p p l i c a t i o n");
this.printLine();
rootDirectory.mkdirs();
final Map locations = new LinkedHashMap();
// - first write any mapped resources
for (final Iterator iterator = this.resourceLocations.iterator(); iterator.hasNext();)
{
final String location = (String)iterator.next();
final URL[] resourceDirectories = ResourceFinder.findResources(location);
if (resourceDirectories != null)
{
final int numberOfResourceDirectories = resourceDirectories.length;
for (int ctr = 0; ctr < numberOfResourceDirectories; ctr++)
{
final URL resourceDirectory = resourceDirectories[ctr];
final List contents = ResourceUtils.getDirectoryContents(
resourceDirectory,
false,
null);
final Set newContents = new LinkedHashSet();
locations.put(
location,
newContents);
for (final ListIterator contentsIterator = contents.listIterator(); contentsIterator.hasNext();)
{
final String path = (String)contentsIterator.next();
if (!path.endsWith(FORWARD_SLASH))
{
boolean hasNewPath = false;
for (final Iterator mappingIterator = this.mappings.iterator(); mappingIterator.hasNext();)
{
final Mapping mapping = (Mapping)mappingIterator.next();
String newPath = mapping.getMatch(path);
if (newPath != null && newPath.length() > 0)
{
final URL absolutePath = ResourceUtils.getResource(path);
if (absolutePath != null)
{
newPath =
this.getTemplateEngine().getEvaluatedExpression(
newPath,
this.templateContext);
ResourceWriter.instance().writeUrlToFile(
absolutePath,
ResourceUtils.normalizePath(TEMPORARY_MERGE_LOCATION + '/' + newPath));
newContents.add(newPath);
hasNewPath = true;
}
}
}
if (!hasNewPath)
{
newContents.add(path);
}
}
}
}
}
}
// - second process and write any output from the defined resource locations.
for (final Iterator iterator = locations.keySet().iterator(); iterator.hasNext();)
{
final String location = (String)iterator.next();
final Collection contents = (Collection)locations.get(location);
if (contents != null)
{
for (final Iterator contentsIterator = contents.iterator(); contentsIterator.hasNext();)
{
final String path = (String)contentsIterator.next();