// Based on the path, metaResource is where it should exist in a 5.4 and beyond world ... unless the expanded
// path was a bit too full of ../ sequences, in which case the expanded path is not valid and we adjust the
// error we write.
Resource metaResource = findLocalizedResource(null, metaPath, resources.getLocale());
Asset result = getComponentAsset(resources, expanded, metaResource);
if (result == null)
{
throw new RuntimeException(String.format("Unable to locate asset '%s' for component %s. It should be located at %s.",
path, resources.getCompleteId(),
metaPath));
}
// This is the best way to tell if the result is an asset for a Classpath resource.
Resource resultResource = result.getResource();
if (!resultResource.equals(metaResource))
{
if (firstWarning.getAndSet(false))
{
logger.error("Packaging of classpath assets has changed in release 5.4; " +
"Assets should no longer be on the main classpath, " +
"but should be moved to 'META-INF/assets/' or a sub-folder. Future releases of Tapestry may " +
"no longer support assets on the main classpath.");
}
if (metaResource.getFolder().startsWith(metaRoot))
{
logger.warn(String.format("Classpath asset '/%s' should be moved to folder '/%s/'.",
resultResource.getPath(),
metaResource.getFolder()));
} else
{
logger.warn(String.format("Classpath asset '/%s' should be moved under folder '/%s', and the relative path adjusted.",
resultResource.getPath(),
metaRoot));
}
}
return result;