Java 8 Manifest - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Manifest class.

This code example shows how to use the following methods:getMainAttributes, write
 
        File manifestDir = new File(moduleDir, "classes" + File.separator + "META-INF");
        Assert.assertTrue(manifestDir.mkdirs());
 
        File moduleManifestFile = new File(manifestDir, "MANIFEST.MF");
        Manifest m = new Manifest();
        m.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
        m.getMainAttributes().putValue("JBoss-Product-Release-Name", PRODUCT_NAME);
        m.getMainAttributes().putValue("JBoss-Product-Release-Version", PRODUCT_VERSION);
        OutputStream manifestStream = new BufferedOutputStream(new FileOutputStream(moduleManifestFile));
        m.write(manifestStream);
        manifestStream.flush();
        manifestStream.close();
 
        // set product.conf         
        File binDir = new File(AS_PATH, "bin");
        Assert.assertTrue(binDir.exists());
        File productConf = new File(binDir, "product.conf");
        if (productConf.exists()) productConf.delete();
        FileUtils.writeStringToFile(productConf, "slot=test" + System.getProperty("line.separator"));
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes
    public static Manifest getOrCreateManifest(Archive<?> archive) {
        Manifest manifest;
        try { 
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null) {
                manifest = new Manifest();
                Attributes attributes = manifest.getMainAttributes();
                attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            } else { 
                manifest = new Manifest(node.getAsset().openStream());
            } 
            return manifest;
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain manifest", ex);
        } 
    } 
 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes
    static { 
        InputStream stream = Version.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
        Manifest manifest = null;
        try { 
            if (stream != null)
                manifest = new Manifest(stream);
        } catch (Exception e) {
        } 
 
        String version = null, code = version;
        if (manifest != null) {
            version = manifest.getMainAttributes().getValue("JBossAS-Release-Version");
            code = manifest.getMainAttributes().getValue("JBossAS-Release-Codename");
        } 
        if (version == null) {
            version = "Unknown";
        } 
        if (code == null) {
            code = "Unknown";
        } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes
    public static Manifest getManifest(Archive<?> archive, boolean create) {
        Manifest manifest = null;
        try { 
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null) {
                manifest = new Manifest();
                Attributes attributes = manifest.getMainAttributes();
                attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            } else if (create) {
                manifest = new Manifest(node.getAsset().openStream());
            } 
            return manifest;
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain manifest", ex);
        } 
    } 
 
    public static Manifest getOrCreateManifest(Archive<?> archive) {
        Manifest manifest;
        try { 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes
    } 
 
    public static String getMainAttributeValue(Manifest manifest, String attribute) {
        String result = null;
        if (manifest != null && attribute != null) {
            Attributes attributes = manifest.getMainAttributes();
            result = attributes.getValue(attribute);
        } 
        return result;
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes, write
            fail("Exception during 3rd test: " + e.toString());
        } 
 
        try { 
            // this is used to create jarName3 used in the previous test 
            Manifest manifest = new Manifest();
            Attributes attributes = manifest.getMainAttributes();
            attributes.put(new Attributes.Name("Manifest-Version"), "1.0");
            ByteArrayOutputStream manOut = new ByteArrayOutputStream();
            manifest.write(manOut);
            byte[] manBytes = manOut.toByteArray();
            File file = File.createTempFile(
                    Support_PlatformFile.getNewPlatformFile("hyts_manifest1", 
                            ""), ".jar"); 
            JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(
                    file.getAbsolutePath()));
            ZipEntry entry = new ZipEntry("META-INF/");
            entry.setSize(0);
            jarOut.putNextEntry(entry);
            entry = new ZipEntry(JarFile.MANIFEST_NAME);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes, hashCode
    private final String androidPackageVersionName;
     
    protected JogampVersion(String packageName, Manifest mf) {        
        this.packageName = packageName;
        this.mf = ( null != mf ) ? mf : new Manifest();
        this.hash = this.mf.hashCode();
        mainAttributes = this.mf.getMainAttributes();
        mainAttributeNames = mainAttributes.keySet();
        androidPackageVersionName = AndroidUtils.getPackageInfoVersionName(packageName); // null if !Android
    } 
 
    @Override 
    public final int hashCode() { 
        return hash;
    } 
 
    @Override 
    public final boolean equals(Object o) {
        if (o instanceof JogampVersion) {
            return mf.equals(((JogampVersion) o).getManifest());
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    private Manifest readManifestFile() {
        InputStream resource = null;
        try { 
            resource = delegate.getResourceAsStream(MANIFEST_MF);
            return resource != null ? new Manifest(resource) : null;
        } catch (IOException e) {
            return null; 
        } 
        finally { 
            if ( resource != null) {
                try { 
                    resource.close();
                } catch (IOException ignored) {
 
                } 
            } 
        } 
    } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMainAttributes, read
 
		final ZipEntry manifestEntry = zipFile.getEntry("META-INF/MANIFEST.MF");
		assertNotNull(manifestEntry);
 
		final InputStream inputStream = zipFile.getInputStream(manifestEntry);
		final Manifest mf = new Manifest();
		mf.read(inputStream);
 
		final String cp = mf.getMainAttributes().getValue("Class-Path");
		assertNotNull(cp);
		assertTrue(cp.contains("dsl.jar"));
      assertTrue(cp.contains("dsl-backwards.jar"));
		assertTrue(cp.contains("usm.jar"));
		inputStream.close();
 
		assertNotNull(zipFile.getEntry("ext/groovy-service.groovy"));
		assertNotNull(zipFile.getEntry("ext/run.groovy"));
		assertNotNull(zipFile.getEntry("META-INF/spring/pu.xml"));
		 
		assertTrue(null == zipFile.getEntry("lib/usm.jar"));
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAttributes, getMainAttributes
See Code Examples for Java 8 Manifest Methods: