log.info( "URL template: " + urlTemplate );
List<File> files = new ArrayList<File>();
findAllJars( new File( repo ), files );
DataModelHelperImpl dmh = new DataModelHelperImpl();
RepositoryImpl repository;
File obrRepoFile = new File( repositoryXml );
if ( obrRepoFile.isFile() )
{
repository = ( RepositoryImpl ) dmh.repository( repositoryXml.toURL() );
}
else
{
repository = new RepositoryImpl();
}
for ( File file : files )
{
try
{
ResourceImpl resource = ( ResourceImpl ) dmh.createResource( file.toURI().toURL() );
if ( resource != null )
{
repository.addResource( resource );
doTemplate( mavenRepoUri, file, resource );
log.info( "Adding resource: " + file );
}
else
{
log.info( "Ignoring non OSGi bundle: " + file );
}
}
catch ( Exception e )
{
log.warn( "Error processing bundle: " + file + " " + e.getMessage() );
}
}
Writer writer = new FileWriter( obrRepoFile );
try
{
dmh.writeRepository( repository, writer );
}
finally
{
writer.close();
}