Package aQute.lib.osgi

Examples of aQute.lib.osgi.Jar


      // parsed from its MANISFEST.MF file at first.
      String symbolName = null;
      String version = "0.0.0";

      try {
        Jar jar = new Jar(f);
        Manifest manifest = jar.getManifest();
        symbolName = manifest.getMainAttributes().getValue(
            Analyzer.BUNDLE_SYMBOLICNAME);
        version = manifest.getMainAttributes().getValue(
            Analyzer.BUNDLE_VERSION);
        version = new Version(version).toString();
View Full Code Here


            builder.addClasspath(new File(config.getDestinationFolder(),CONFIG_ROOT));
        } catch (IOException e) {
            log.warn("Unable to build OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
            return;
        }
        Jar jar;
        try {
            jar = builder.build();
        } catch (Exception e) {
            log.warn("Unable to build OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
            return;
        }
        try {
            jar.write(new File(config.getDistributionFolder(),
                CONFIG_PACKAGE+config.getName()+"-1.0.0.jar"));
        } catch (Exception e) {
            log.warn("Unable to write OSGI Bundle for Indexed Referenced Site "+config.getName(),e);
        }
    }
View Full Code Here

        if (resolvedArtifact.isRoot()) {
            Object symbolicNameValue = p2Artifact.getInstructions().get(Analyzer.BUNDLE_SYMBOLICNAME);
            symbolicName = symbolicNameValue != null ? symbolicNameValue.toString() : null;
        }
        if (symbolicName == null) {
            symbolicName = BundleUtils.INSTANCE.getBundleSymbolicName(new Jar(resolvedArtifact.getArtifact().getFile()));
        }
        if (symbolicName == null) {
            symbolicName = BundleUtils.INSTANCE.calculateBundleSymbolicName(resolvedArtifact.getArtifact());
        }
        // bug28 - handle classifiers
View Full Code Here

        String version;
        // otherwise calculate the proper version for snapshot and non-snapshot
        if (resolvedArtifact.isSnapshot()) {
            version = calculateSnapshotVersion(resolvedArtifact);
        } else {
            version = BundleUtils.INSTANCE.getBundleVersion(new Jar(resolvedArtifact.getArtifact().getFile()));
            if (version == null) {
                version = BundleUtils.INSTANCE.calculateBundleVersion(resolvedArtifact.getArtifact());
            }
        }
        // if still contains snapshot (manually set by the user) -> "SNAPSHOT" will be manually replaced
View Full Code Here

    }

    private static Jar getInputJarWithBlankManifest(ArtifactBundlerRequest request) throws Exception {
        File parentFolder = request.getBinaryInputFile().getParentFile();
        File jarBlankManifest = new File(parentFolder, request.getBinaryInputFile().getName() + "." + UUID.randomUUID());
        Jar jar = new Jar(request.getBinaryInputFile());
        try {
            jar.setManifest(new Manifest());
            jar.write(jarBlankManifest);
            return new Jar(jarBlankManifest);
        } finally {
            FileUtils.deleteQuietly(jarBlankManifest);
            // do not close the newly created jar, analyzer will do it
        }
    }
View Full Code Here

            analyzer.close();
        }
    }

    private void populateJar(Analyzer analyzer, File outputFile) throws Exception {
        Jar jar = analyzer.getJar();
        try {
            jar.write(outputFile);
        } finally {
            jar.close();
        }
    }
View Full Code Here

            // do not take user-defined and take proposed version
            // there is no bundling -> so cannot take version from instructions
            version = instructions.getProposedVersion();
        }
        String name = instructions.getSourceName();
        Jar jar = new Jar(request.getSourceInputFile());
        try {
            Manifest manifest = getManifest(jar);
            decorateSourceManifest(manifest, name, referencedBundleSymbolicName, symbolicName, version);
            jar.setManifest(manifest);
            jar.write(request.getSourceOutputFile());
        } finally {
            jar.close();
        }
    }
View Full Code Here

    }

    @Test
    public void isBundle_nonExistingJar() {
        // given
        Jar jar = new Jar("non-existing.jar");

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

        // then
View Full Code Here

    }

    @Test
    public void isBundle_cannotOpenManifest() throws Exception {
        // given
        Jar jar = mock(Jar.class, Mockito.RETURNS_DEEP_STUBS);
        when(jar.getManifest()).thenThrow(new IOException());

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

        // then
View Full Code Here

    }

    @Test
    public void isBundle_emptyManifest() throws Exception {
        // given
        Jar jar = mock(Jar.class, Mockito.RETURNS_DEEP_STUBS);
        when(jar.getManifest().getMainAttributes()).thenReturn(null);

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

        // then
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.