Package aQute.lib.osgi

Examples of aQute.lib.osgi.Jar


    }

    @Test
    public void isBundle_manifestWithAttributes() throws Exception {
        // given
        Jar jar = mock(Jar.class, Mockito.RETURNS_DEEP_STUBS);
        when(jar.getManifest().getMainAttributes().getValue(any(Attributes.Name.class))).thenReturn("org.apache.commons");

        // when
        boolean isBundle = utils.isBundle(jar);

        // then
View Full Code Here


    @Test
    public void getBundleName_correctBundleNameFromMainAttribuets() throws Exception {
        // given
        String bundleName = "org.reficio.example.bundle";
        Jar jar = mock(Jar.class, Mockito.RETURNS_DEEP_STUBS);
        when(jar.getManifest().getMainAttributes().getValue(new Attributes.Name(Analyzer.BUNDLE_NAME))).thenReturn(bundleName);

        // when
        String bundleNameFromManifest = utils.getBundleName(jar);

        // then
View Full Code Here

    public String cleanupVersion(String version) {
        return super.getMaven2OsgiConverter().getVersion(version);
    }

    public boolean isBundle(File file) {
        Jar inputJar = null;
        try {
            inputJar = new Jar(file);
            return isBundle(inputJar);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        } finally {
            if (inputJar != null) {
                inputJar.close();
            }
        }
    }
View Full Code Here

    private static final String JAR_SNAPSHOT_POSTFIX = "-SNAPSHOT";
    private static final String OSGI_SNAPSHOT_POSTFIX = ".SNAPSHOT";

    public static void adjustSnapshotOutputVersion(File inputFile, File outputFile, String version) {
        Jar jar = null;
        try {
            jar = new Jar(inputFile);
            Manifest manifest = jar.getManifest();
            Attributes attributes = manifest.getMainAttributes();
            attributes.putValue(Analyzer.BUNDLE_VERSION, version);
            jar.write(outputFile);
        } catch (IOException e) {
            throw new RuntimeException("Cannot open jar " + outputFile);
        } catch (Exception e) {
            throw new RuntimeException("Cannot open jar " + outputFile);
        } finally {
            if (jar != null) {
                jar.close();
            }
        }
    }
View Full Code Here

                            File target;

                            builder.build();
                            String name = builder.getBsn() + ".jar";

                            Jar jar = builder.getJar();

                            String path = builder.getProperty("-output");
                            if (path == null) {
                                target = new File(cwd, name);
                            } else {
                                target = new File(path);
                                if (!target.isAbsolute())
                                    target = new File(cwd, path);
                                if (target.isDirectory()) {
                                    target = new File(target, name);
                                }
                            }

                            target.delete();
                            if (builder.getErrors().size() > 0) {
                                activator.error(builder.getErrors());
                            } else {
                                jar.write(target);

                                File copy = activator.getCopy();
                                if (copy != null) {
                                    copy = new File(copy, target.getName());
                                    jar.write(copy);
                                }
                                if (builder.getWarnings().size() > 0) {
                                    activator.warning(builder.getWarnings());
                                } else {
                                    if (activator.getReportDone()) {
View Full Code Here

        try {
            if (locations != null) {
                for (int i = 0; i < locations.length; i++) {
                    File mf = locations[i].getLocation().toFile();
                    try {
                        Jar jar = new Jar(mf.getName(), mf);
                        Verifier verifier = new Verifier(jar);
                        try {
                            verifier.verify();
                            if (verifier.getErrors().size()
                                    + verifier.getWarnings().size() > 0) {
                                List<String> info = new ArrayList<String>(verifier.getErrors());
                                info.addAll(verifier.getWarnings());
                                Activator.getDefault().error(info);
                            }
                        } finally {
                            jar.close();
                            verifier.close();
                        }

                    } catch (Exception e) {
                        Activator.getDefault().error(
View Full Code Here

TOP

Related Classes of aQute.lib.osgi.Jar

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.