* @throws FileNotFoundException
* @throws IOException
*/
private void updateManifest( final List<Artifact> list ) throws FileNotFoundException, IOException
{
final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
final File manifestFile = new File( project.getBasedir(), "META-INF/MANIFEST.MF" );
getLog().info( "Update Bundle-Classpath in " + manifestFile );
// Build Bundle-ClassPath entry
final StringBuilder bundleClasspath = new StringBuilder( " ." );
for ( Artifact artifact : list )
{
if ( !artifact.getScope().equalsIgnoreCase( "test" ) )
{
bundleClasspath.append( "," ).append( NEWLINE ).append( " " ).append( libraryPath ).append(
File.separator ).append( artifact.getFile().getName() );
}
}
boolean inBundleClasspathEntry = false;
// Read existing MANIFEST.MF and add existing entries
// to StringBuilder exept Bundle-ClassPath entry
StringBuilder manifestSb = new StringBuilder();
BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( manifestFile ), "UTF-8" ) );
String line;
while ( ( line = in.readLine() ) != null )
{
if ( inBundleClasspathEntry && line.indexOf( ":" ) > -1 )
{
inBundleClasspathEntry = false;
}
else if ( inBundleClasspathEntry )
{
continue;
}
String name = line.substring( 0, line.indexOf( ":" ) + 1 );
if ( !name.equalsIgnoreCase( ENTRY_BUNDLE_CLASSPATH ) )
{
if ( name.equalsIgnoreCase( ENTRY_BUNDLE_SYMBOLICNAME ) )
{
// get OSGI Bundle Name
manifestSb.append( ENTRY_BUNDLE_SYMBOLICNAME );
manifestSb.append( " " );
manifestSb.append( maven2OsgiConverter.getBundleSymbolicName( project.getArtifact() ) );
manifestSb.append( ";singleton:=true" );
manifestSb.append( NEWLINE );
}
else
{