Package org.gradle.api.java.archives.internal

Examples of org.gradle.api.java.archives.internal.DefaultManifest


    @Test
    public void merge() throws Exception {
        setUpOsgiManifest();
        prepareMock();
        DefaultManifest otherManifest = new DefaultManifest(fileResolver);
        otherManifest.mainAttributes(WrapUtil.toMap("somekey", "somevalue"));
        otherManifest.mainAttributes(WrapUtil.toMap(Analyzer.BUNDLE_VENDOR, "mergeVendor"));
        osgiManifest.from(otherManifest);
        DefaultManifest defaultManifest = getDefaultManifestWithOsgiValues();
        DefaultManifest expectedManifest = new DefaultManifest(fileResolver).attributes(defaultManifest.getAttributes());
        for(Map.Entry<String, Attributes> ent : defaultManifest.getSections().entrySet()) {
            expectedManifest.attributes(ent.getValue(), ent.getKey());
        }
        expectedManifest.attributes(otherManifest.getAttributes());

        DefaultManifest manifest = osgiManifest.getEffectiveManifest();
        assertTrue(manifest.isEqualsTo(expectedManifest));
    }
View Full Code Here


    }

    @Override
    public DefaultManifest getEffectiveManifest() {
        ContainedVersionAnalyzer analyzer = analyzerFactory.create();
        DefaultManifest effectiveManifest = new DefaultManifest(null);
        try {
            setAnalyzerProperties(analyzer);
            Manifest osgiManifest = analyzer.calcManifest();
            for (Map.Entry<Object, Object> entry : osgiManifest.getMainAttributes().entrySet()) {
                effectiveManifest.attributes(WrapUtil.toMap(entry.getKey().toString(), (String) entry.getValue()));
            }
            effectiveManifest.attributes(this.getAttributes());
            for(Map.Entry<String, Attributes> ent : getSections().entrySet()) {
                effectiveManifest.attributes(ent.getValue(), ent.getKey());
            }
        } catch (Exception e) {
            throw UncheckedException.asUncheckedException(e);
        }
        return getEffectiveManifestInternal(effectiveManifest);
View Full Code Here

            will(returnValue(testManifest));
        }});
    }

    private DefaultManifest getDefaultManifestWithOsgiValues() {
        DefaultManifest manifest = new DefaultManifest(fileResolver);
        manifest.getAttributes().put(Analyzer.BUNDLE_SYMBOLICNAME, osgiManifest.getSymbolicName());
        manifest.getAttributes().put(Analyzer.BUNDLE_NAME, osgiManifest.getName());
        manifest.getAttributes().put(Analyzer.BUNDLE_DESCRIPTION, osgiManifest.getDescription());
        manifest.getAttributes().put(Analyzer.BUNDLE_LICENSE, osgiManifest.getLicense());
        manifest.getAttributes().put(Analyzer.BUNDLE_VENDOR, osgiManifest.getVendor());
        manifest.getAttributes().put(Analyzer.BUNDLE_DOCURL, osgiManifest.getDocURL());
        manifest.getAttributes().put(Analyzer.EXPORT_PACKAGE, GUtil.join(osgiManifest.instructionValue(Analyzer.EXPORT_PACKAGE), ","));
        manifest.getAttributes().put(Analyzer.IMPORT_PACKAGE, GUtil.join(osgiManifest.instructionValue(Analyzer.IMPORT_PACKAGE), ","));
        addPlainAttributesAndSections(manifest);
        return manifest;
    }
View Full Code Here

    @Test
    public void getEffectiveManifest() throws Exception {
        setUpOsgiManifest();
        prepareMock();

        DefaultManifest manifest = osgiManifest.getEffectiveManifest();
        DefaultManifest defaultManifest = getDefaultManifestWithOsgiValues();
        DefaultManifest expectedManifest = new DefaultManifest(fileResolver).attributes(defaultManifest.getAttributes());
        for(Map.Entry<String, Attributes> ent : defaultManifest.getSections().entrySet()) {
            expectedManifest.attributes(ent.getValue(), ent.getKey());
        }

        assertThat(manifest.getAttributes(), Matchers.equalTo(expectedManifest.getAttributes()));
        assertThat(manifest.getSections(), Matchers.equalTo(expectedManifest.getSections()));
    }
View Full Code Here

    private final CopySpecInternal metaInf;

    public Jar() {
        setExtension(DEFAULT_EXTENSION);

        manifest = new DefaultManifest(getFileResolver());
        // Add these as separate specs, so they are not affected by the changes to the main spec
        metaInf = (CopySpecInternal) getRootSpec().addFirst().into("META-INF");
        metaInf.addChild().from(new Callable<FileTreeAdapter>() {
            public FileTreeAdapter call() throws Exception {
                MapFileTree manifestSource = new MapFileTree(getTemporaryDirFactory(), getFileSystem());
                manifestSource.add("MANIFEST.MF", new Action<OutputStream>() {
                    public void execute(OutputStream outputStream) {
                        Manifest manifest = getManifest();
                        if (manifest == null) {
                            manifest = new DefaultManifest(null);
                        }
                        manifest.writeTo(new OutputStreamWriter(outputStream));
                    }

                });
View Full Code Here

     * @param configureClosure The closure.
     * @return This.
     */
    public Jar manifest(Closure<?> configureClosure) {
        if (getManifest() == null) {
            manifest = new DefaultManifest(((ProjectInternal) getProject()).getFileResolver());
        }

        ConfigureUtil.configure(configureClosure, getManifest());
        return this;
    }
View Full Code Here

    }

    @Override
    public DefaultManifest getEffectiveManifest() {
        ContainedVersionAnalyzer analyzer = analyzerFactory.create();
        DefaultManifest effectiveManifest = new DefaultManifest(null);
        try {
            setAnalyzerProperties(analyzer);
            Manifest osgiManifest = analyzer.calcManifest();
            java.util.jar.Attributes attributes = osgiManifest.getMainAttributes();
            for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
                effectiveManifest.attributes(WrapUtil.toMap(entry.getKey().toString(), (String) entry.getValue()));
            }
            effectiveManifest.attributes(this.getAttributes());
            for (Map.Entry<String, Attributes> ent : getSections().entrySet()) {
                effectiveManifest.attributes(ent.getValue(), ent.getKey());
            }
            if (classesDir != null) {
                long mod = classesDir.lastModified();
                if (mod > 0) {
                    effectiveManifest.getAttributes().put(Analyzer.BND_LASTMODIFIED, mod);
                }
            }
        } catch (Exception e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
View Full Code Here

TOP

Related Classes of org.gradle.api.java.archives.internal.DefaultManifest

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.