in nb-shared/src/main/java/org/apache/netbeans/nbm/utils/ExamineManifest.java [178:349]
private void processManifest( Manifest mf )
{
Attributes attrs = mf.getMainAttributes();
this.module = attrs.getValue( "OpenIDE-Module" );
setNetBeansModule( getModule() != null );
if ( isNetBeansModule() )
{
this.locBundle = attrs.getValue( "OpenIDE-Module-Localizing-Bundle" );
this.localized = locBundle != null;
this.specVersion = attrs.getValue( "OpenIDE-Module-Specification-Version" );
this.implVersion = attrs.getValue( "OpenIDE-Module-Implementation-Version" );
String cp = attrs.getValue( Attributes.Name.CLASS_PATH );
classpath = cp == null ? "" : cp;
String value = attrs.getValue( "OpenIDE-Module-Public-Packages" );
String frList = attrs.getValue( "OpenIDE-Module-Friends" );
if ( value == null || value.trim().equals( "-" ) )
{
this.publicPackages = false;
}
else
{
if ( frList != null )
{
this.publicPackages = false;
String[] friendList = StringUtils.stripAll( StringUtils.split( frList, "," ) );
friendPackages = true;
friends = Arrays.asList( friendList );
}
else
{
this.publicPackages = true;
}
String[] packageList = StringUtils.stripAll( StringUtils.split( value, "," ) );
packages = Arrays.asList( packageList );
}
if ( populateDependencies )
{
String deps = attrs.getValue( "OpenIDE-Module-Module-Dependencies" );
if ( deps != null )
{
StringTokenizer tokens = new StringTokenizer( deps, "," );
List<String> depList = new ArrayList<String>();
while ( tokens.hasMoreTokens() )
{
String tok = tokens.nextToken();
//we are just interested in specification and loose dependencies.
int spec = tok.indexOf( '>' );
int impl = tok.indexOf( '=' );
if ( spec > 0 )
{
tok = tok.substring( 0, spec );
}
else if ( impl > 0 )
{
tok = tok.substring( 0, impl );
}
int slash = tok.indexOf( '/' );
if ( slash > 0 )
{
tok = tok.substring( 0, slash );
}
depList.add( tok.trim().intern() );
}
this.dependencyTokens = depList;
}
String req = attrs.getValue( "OpenIDE-Module-Requires" );
String prov = attrs.getValue( "OpenIDE-Module-Provides" );
String needs = attrs.getValue( "OpenIDE-Module-Needs" );
if ( prov != null )
{
provides = Arrays.asList( StringUtils.stripAll( StringUtils.split( prov, "," ) ) );
}
if ( req != null || needs != null )
{
requires = new ArrayList<String>();
if ( req != null )
{
requires.addAll( Arrays.asList( StringUtils.stripAll( StringUtils.split( req, "," ) ) ) );
}
if ( needs != null )
{
requires.addAll( Arrays.asList( StringUtils.stripAll( StringUtils.split( needs, "," ) ) ) );
}
}
}
}
else
{
//check osgi headers first, let nb stuff override it, making nb default
String bndName = attrs.getValue( "Bundle-SymbolicName" );
if ( bndName != null )
{
this.osgiBundle = true;
this.module =
bndName./* MNBMODULE-125 */replaceFirst( " *;.+", "" )./* MNBMODULE-96 */replace( '-', '_' );
this.specVersion = attrs.getValue( "Bundle-Version" );
String exp = attrs.getValue( "Export-Package" );
String autoload = attrs.getValue( "Nbm-Maven-Plugin-Autoload" );
if ( autoload != null )
{
bundleAutoload = Boolean.parseBoolean( autoload );
}
this.publicPackages = exp != null;
if ( populateDependencies )
{
//well, this doesn't appear to cover
//the major way of declation dependencies in osgi - Import-Package
String deps = attrs.getValue( "Require-Bundle" );
if ( deps != null )
{
List<String> depList = new ArrayList<String>();
// https://stackoverflow.com/questions/1757065
// java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
for ( String piece : deps.split( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)" ) )
{
depList.add( piece.replaceFirst( ";.+", "" ).trim().intern() );
}
this.dependencyTokens = depList;
}
String imps = attrs.getValue( "Import-Package" );
if ( imps != null )
{
Set<String> depList = new HashSet<String>();
// https://stackoverflow.com/questions/1757065
// java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
for ( String piece : imps.split( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)" ) )
{
depList.add( piece.replaceFirst( ";.+", "" ).trim().intern() );
}
this.osgiImports = depList;
}
String exps = attrs.getValue( "Export-Package" );
if ( exps != null )
{
Set<String> depList = new HashSet<String>();
// https://stackoverflow.com/questions/1757065
// java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
for ( String piece : exps.split( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)" ) )
{
depList.add( piece.replaceFirst( ";.+", "" ).trim().intern() );
}
this.osgiExports = depList;
}
}
}
else
{
// for non-netbeans, non-osgi jars.
this.specVersion = attrs.getValue( "Specification-Version" );
this.implVersion = attrs.getValue( "Implementation-Version" );
this.module = attrs.getValue( "Package" );
this.publicPackages = false;
classpath = "";
/* if ( module != null )
{
// now we have the package to make it a module definition, add the version there..
module = module + "/1";
}
*/
if ( getModule() == null )
{
// do we want to do that?
this.module = attrs.getValue( "Extension-Name" );
}
}
}
}