private String generateExtensions()

in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateWebstartAppMojo.java [690:737]


    private String generateExtensions( FileSet files, Project antProject, String masterPrefix )
            throws IOException
    {
        StringBuilder buff = new StringBuilder();
        for ( String nm : files.getDirectoryScanner( antProject ).getIncludedFiles() )
        {
            File jar = new File( files.getDir( antProject ), nm );

            if ( !jar.canRead() )
            {
                throw new IOException( "Cannot read file: " + jar );
            }

            JarFile theJar = new JarFile( jar );
            Attributes attr = theJar.getManifest().getMainAttributes();
            String codenamebase = attr.getValue( "OpenIDE-Module" );
            if ( codenamebase == null )
            {
                codenamebase = attr.getValue( "Bundle-SymbolicName" );
            }
            if ( codenamebase == null )
            {
                throw new IOException( "Not a NetBeans Module: " + jar );
            }

            // see http://hg.netbeans.org/main-silver/rev/87823abb86d9
            if ( codenamebase.equals( "org.objectweb.asm.all" )
                    && jar.getParentFile().getName().equals( "core" )
                    && jar.getParentFile().getParentFile().getName().startsWith( "platform" ) )
            {
                continue;
            }

            int slash = codenamebase.indexOf( '/' );
            if ( slash >= 0 )
            {
                codenamebase = codenamebase.substring( 0, slash );
            }

            String dashcnb = codenamebase.replace( '.', '-' );

            buff.append( "    <extension name='" ).append( codenamebase ).append( "' href='" ).append( masterPrefix ).
                    append( dashcnb ).append( ".jnlp' />\n" );
            theJar.close();
        }
        return buff.toString();

    }