in maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java [271:392]
private void generateComponents(Model model, Properties cachedInfo, long lastModifiedMetadata) throws IOException,
MojoExecutionException
{
File tf = new File(templateSourceDirectory, _getTemplateTagName());
if (isCachingEnabled())
{
boolean upToDate = true;
for (Iterator it = model.getComponents().iterator(); it.hasNext();)
{
ComponentMeta component = (ComponentMeta) it.next();
if (component.getTagClass() != null)
{
File f = new File(mainSourceDirectory, StringUtils.replace(
component.getTagClass(), ".", "/")+".java");
if (!f.exists() && canGenerateComponentTag(component))
{
if (mainSourceDirectory2 != null)
{
File f2 = new File(mainSourceDirectory2, StringUtils.replace(
component.getTagClass(), ".", "/")+".java");
if (f2.exists())
{
//Skip
continue;
}
}
File outFile = new File(generatedSourceDirectory, StringUtils.replace(
component.getTagClass(), ".", "/")+".java");
String lastModifiedString = cachedInfo.getProperty(outFile.getAbsolutePath());
if (lastModifiedString == null)
{
upToDate = false;
break;
}
else if (!outFile.exists())
{
upToDate = false;
break;
}
else
{
Long lastModified = Long.valueOf(lastModifiedString);
if (lastModified != null && lastModifiedMetadata > lastModified.longValue())
{
upToDate = false;
break;
}
}
}
}
}
if (upToDate && tf != null && tf.exists())
{
upToDate = isFileUpToDate(cachedInfo, tf);
}
if (upToDate)
{
getLog().info("generated component tag files are up to date");
return;
}
}
VelocityEngine velocityEngine = initVelocity();
VelocityContext baseContext = new VelocityContext();
baseContext.put("utils", new MyfacesUtils());
for (Iterator it = model.getComponents().iterator(); it.hasNext();)
{
ComponentMeta component = (ComponentMeta) it.next();
if (component.getTagClass() != null)
{
File f = new File(mainSourceDirectory, StringUtils.replace(
component.getTagClass(), ".", "/")+".java");
if (!f.exists() && canGenerateComponentTag(component))
{
if (mainSourceDirectory2 != null)
{
File f2 = new File(mainSourceDirectory2, StringUtils.replace(
component.getTagClass(), ".", "/")+".java");
if (f2.exists())
{
//Skip
continue;
}
}
getLog().info("Generating tag class:"+component.getTagClass());
try
{
_generateComponent(velocityEngine, component,baseContext,
cachedInfo, lastModifiedMetadata);
}
catch(MojoExecutionException e)
{
if (force)
{
getLog().error(e.getMessage());
}
else
{
//Stop execution throwing exception
throw e;
}
}
}
}
}
if (isCachingEnabled())
{
if (tf != null && tf.exists())
{
cachedInfo.put(tf.getAbsolutePath(), Long.toString(tf.lastModified()));
}
}
}