protected List extractMojoDescriptorsFromMetadata( Map metadataFilesKeyedByBasedir, PluginDescriptor pluginDescriptor )
throws ExtractionException, InvalidPluginDescriptorException
{
List descriptors = new ArrayList();
PluginMetadataParser parser = new PluginMetadataParser();
for ( Iterator mapIterator = metadataFilesKeyedByBasedir.entrySet().iterator(); mapIterator.hasNext(); )
{
Map.Entry entry = (Map.Entry) mapIterator.next();
String basedir = (String) entry.getKey();
Set metadataFiles = (Set) entry.getValue();
for ( Iterator it = metadataFiles.iterator(); it.hasNext(); )
{
File metadataFile = (File) it.next();
String basename = metadataFile.getName();
basename = basename.substring( 0, basename.length() - METADATA_FILE_EXTENSION.length() );
File scriptFile = new File( metadataFile.getParentFile(), basename + SCRIPT_FILE_EXTENSION );
if ( !scriptFile.exists() )
{
throw new InvalidPluginDescriptorException( "Found orphaned plugin metadata file: "
+ metadataFile );
}
String relativePath = null;
if ( basedir.endsWith( "/" ) )
{
basedir = basedir.substring( 0, basedir.length() - 2 );
}
relativePath = scriptFile.getPath().substring( basedir.length() );
relativePath = relativePath.replace( '\\', '/' );
try
{
Set mojoDescriptors = parser.parseMojoDescriptors( metadataFile );
for ( Iterator discoveredMojoIterator = mojoDescriptors.iterator(); discoveredMojoIterator
.hasNext(); )
{
MojoDescriptor descriptor = (MojoDescriptor) discoveredMojoIterator.next();