Package org.codehaus.plexus.archiver.jar.Manifest

Examples of org.codehaus.plexus.archiver.jar.Manifest.Attribute


            if ( manifest != null ) {
                final Map<Object, Object> attrs = manifest.getMainAttributes();
                for(final Map.Entry<Object, Object> entry : attrs.entrySet()) {
                    final String key = entry.getKey().toString();
                    if ( !BuildConstants.ATTRS_EXCLUDES.contains(key)) {
                        final Attribute a = new Attribute(key, entry.getValue().toString());
                        outManifest.addConfiguredAttribute(a);
                    }
                    if ( key.equals(BuildConstants.ATTR_MAIN_CLASS) ) {
                        hasMain = true;
                    }
                }
            }
            outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_IMPLEMENTATION_BUILD,
                            project.getVersion()));
            outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_IMPLEMENTATION_VERSION,
                            project.getVersion()));

            String organizationName = project.getOrganization() != null ? project.getOrganization().getName() : null;
            if ( organizationName != null ) {
                outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_IMPLEMENTATION_VENDOR,
                            organizationName));
                outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_CREATED_BY,
                            organizationName));
                outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_BUILT_BY,
                            organizationName));
                outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_SPECIFICATION_VENDOR,
                        organizationName));
            }

            outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_IMPLEMENTATION_VENDOR_ID,
                            project.getGroupId()));
            outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_IMPLEMENTATION_TITLE,
                            project.getName()));
            outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_SPECIFICATION_TITLE,
                            project.getName()));
            outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_SPECIFICATION_VERSION,
                            project.getVersion()));

            if ( archiver.getDestFile().getName().endsWith(".jar") && !hasMain) {
                outManifest.addConfiguredAttribute(new Attribute(BuildConstants.ATTR_MAIN_CLASS,
                                BuildConstants.ATTR_VALUE_MAIN_CLASS));
            }

            archiver.addConfiguredManifest(outManifest);
        } catch (final ManifestException e) {
View Full Code Here


            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());

            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);

            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(mainClassName);
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());
           
            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);
           
            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(cls.getName());
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
           
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());

            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);

            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(mainClassName);
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());

            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);

            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(mainClassName);
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());
           
            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);
           
            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(cls.getName());
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
           
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());
           
            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);
           
            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(cls.getName());
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
           
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());

            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);

            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(mainClassName);
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
View Full Code Here

                getLog().debug( "This project did not have a META-INF/MANIFEST.MF file before, so a new file was created." );
            }

            // Read the manifest from disk
            Manifest mf = new Manifest( new FileReader( manifestFile ) );
            Attribute classPath = mf.getMainSection().getAttribute( "Class-Path" );
            List<String> classPathElements = new ArrayList<String>();

            if ( classPath != null )
            {
                classPathElements.addAll( Arrays.asList( classPath.getValue().split( " " ) ) );
            }
            else
            {
                classPath = new Attribute( "Class-Path", "" );
            }

            // Modify the classpath entries in the manifest
            for ( EarModule o : getModules() )
            {
                if ( o instanceof JarModule )
                {
                    JarModule jm = (JarModule) o;

                    if ( module.getLibDir() != null )
                    {
                        File artifact =
                            new File( new File( workDirectory, module.getLibDir() ), jm.getBundleFileName() );

                        if ( artifact.exists() )
                        {
                            if ( !artifact.delete() )
                            {
                                getLog().error( "Could not delete '" + artifact + "'" );
                            }
                        }
                    }

                    if ( classPathElements.contains( jm.getBundleFileName() ) )
                    {
                        classPathElements.set( classPathElements.indexOf( jm.getBundleFileName() ), jm.getUri() );
                    }
                    else
                    {
                        classPathElements.add( jm.getUri() );
                    }
                }
            }
            classPath.setValue( StringUtils.join( classPathElements.iterator(), " " ) );
            mf.getMainSection().addConfiguredAttribute( classPath );

            // Write the manifest to disk
            PrintWriter pw = new PrintWriter( manifestFile );
            mf.write( pw );
View Full Code Here

            JarArchiver jar = new JarArchiver();
            jar.setDestFile(file.getAbsoluteFile());

            Manifest manifest = new Manifest();
            Attribute attr = new Attribute();
            attr.setName("Class-Path");
            StringBuilder b = new StringBuilder(8000);
            for (URI cp : classPath) {
                b.append(cp.toURL().toExternalForm()).append(' ');
            }
            attr.setValue(b.toString());
            manifest.getMainSection().addConfiguredAttribute(attr);

            attr = new Attribute();
            attr.setName("Main-Class");
            attr.setValue(mainClassName);
            manifest.getMainSection().addConfiguredAttribute(attr);

            jar.addConfiguredManifest(manifest);
            jar.createArchive();
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.jar.Manifest.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.