aQute.bnd.osgi.Analyzer Java Examples

The following examples show how to use aQute.bnd.osgi.Analyzer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeAppendModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(appendValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(appendValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(appendValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(appendValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(appendValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(appendValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(appendValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #2
Source File: ImportedPackageRangeFixer.java    From wisdom with Apache License 2.0 6 votes vote down vote up
/**
 * Analyzes the jar and update the version range.
 *
 * @param analyzer the analyzer
 * @return {@code false}
 * @throws Exception if the analaysis fails.
 */
@Override
public boolean analyzeJar(Analyzer analyzer) throws Exception {
    loadInternalRangeFix();
    loadExternalRangeFix();

    if (analyzer.getReferred() == null) {
        return false;
    }

    // Data loaded, start analysis
    for (Map.Entry<Descriptors.PackageRef, Attrs> entry : analyzer.getReferred().entrySet()) {
        for (Range range : ranges) {
            if (range.matches(entry.getKey().getFQN())) {
                String value = range.getRange(analyzer);
                if (value != null) {
                    reporter.warning("Updating import version of " + range.name + " to " + value);
                    entry.getValue().put("version", value);
                }
            }
        }
    }
    return false;
}
 
Example #3
Source File: OSGiWrapper.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Parse the Bundle-Includes header. Files in the bundles Include header are
 * included in the jar. The source can be a directory or a file.
 *
 * @throws Exception
 */
private void doIncludeResources(Analyzer analyzer) throws Exception {
    String includes = analyzer.getProperty(Analyzer.INCLUDE_RESOURCE);
    if (includes == null) {
        return;
    }
    Parameters clauses = analyzer.parseHeader(includes);
    Jar jar = analyzer.getJar();

    for (Map.Entry<String, Attrs> entry : clauses.entrySet()) {
        String name = entry.getKey();
        Map<String, String> extra = entry.getValue();
        // TODO consider doing something with extras

        String[] parts = name.split("\\s*=\\s*");
        String source = parts[0];
        String destination = parts[0];
        if (parts.length == 2) {
            source = parts[1];
        }

        includeFiles(jar, destination, source);
    }
}
 
Example #4
Source File: ImportedPackageRangeFixer.java    From wisdom with Apache License 2.0 6 votes vote down vote up
private String getRange(Analyzer analyzer) throws Exception {
    if (foundRange != null) {
        return foundRange;
    }
    if (Strings.isNullOrEmpty(value)) {
        for (Jar jar : analyzer.getClasspath()) {
            if (isProvidedByJar(jar) && jar.getVersion() != null) {
                foundRange = jar.getVersion();
                return jar.getVersion();
            }
        }
        // Cannot find a provider.
        reporter.error("Cannot find a dependency providing " + name + " in the classpath");
        return null;
    } else {
        return value;
    }
}
 
Example #5
Source File: ImportedPackageRangeFixerTest.java    From wisdom with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithReferredWithoutClasspath() throws Exception {
    ImportedPackageRangeFixer fixer = new ImportedPackageRangeFixer();
    Reporter reporter = mock(Reporter.class);
    fixer.setReporter(reporter);
    fixer.setProperties(Collections.<String, String>emptyMap());

    Analyzer analyzer = mock(Analyzer.class);
    final Packages packages = new Packages();
    Descriptors descriptors = new Descriptors();
    packages.put(descriptors.getPackageRef("com.acme"));
    when(analyzer.getReferred()).thenReturn(packages);
    fixer.analyzeJar(analyzer);
    final Map.Entry<Descriptors.PackageRef, Attrs> actual = foundByPackageName(analyzer, "com.acme");
    assertThat(actual).isNotNull();
    assertThat(actual.getValue()).isEmpty();
}
 
Example #6
Source File: ImportedPackageRangeFixerTest.java    From wisdom with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithReferredMatchingButNotInClasspath() throws Exception {
    ImportedPackageRangeFixer fixer = new ImportedPackageRangeFixer();
    Reporter reporter = mock(Reporter.class);
    fixer.setReporter(reporter);
    fixer.setProperties(Collections.<String, String>emptyMap());

    Analyzer analyzer = mock(Analyzer.class);
    final Packages packages = new Packages();
    Descriptors descriptors = new Descriptors();
    packages.put(descriptors.getPackageRef("com.acme"));
    packages.put(descriptors.getPackageRef("com.google.common.collections"));
    when(analyzer.getReferred()).thenReturn(packages);

    fixer.analyzeJar(analyzer);

    Map.Entry<Descriptors.PackageRef, Attrs> actual = foundByPackageName(analyzer, "com.acme");
    assertThat(actual).isNotNull();
    assertThat(actual.getValue()).isEmpty();
    actual = foundByPackageName(analyzer, "com.google.common.collections");
    assertThat(actual).isNotNull();
    assertThat(actual.getValue()).isEmpty();
}
 
Example #7
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Map<String, List<String>> getModelledInstructions() {
    Map<String, List<String>> modelledInstructions = new HashMap<String, List<String>>();
    modelledInstructions.put(Analyzer.BUNDLE_SYMBOLICNAME, createListFromPropertyString(symbolicName));
    modelledInstructions.put(Analyzer.BUNDLE_NAME, createListFromPropertyString(name));
    modelledInstructions.put(Analyzer.BUNDLE_VERSION, createListFromPropertyString(version));
    modelledInstructions.put(Analyzer.BUNDLE_DESCRIPTION, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_LICENSE, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_VENDOR, createListFromPropertyString(vendor));
    modelledInstructions.put(Analyzer.BUNDLE_DOCURL, createListFromPropertyString(docURL));

    return CollectionUtils.filter(modelledInstructions, new Spec<Map.Entry<String, List<String>>>() {
        public boolean isSatisfiedBy(Map.Entry<String, List<String>> element) {
            return element.getValue() != null;
        }
    });
}
 
Example #8
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeSetModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(createPropertyStringFromArray(values));
        return true;
    } else {
        return false;
    }
}
 
Example #9
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybePrependModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(prependValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(prependValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(prependValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(prependValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(prependValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(prependValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(prependValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #10
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeAppendModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(appendValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(appendValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(appendValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(appendValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(appendValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(appendValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(appendValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #11
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<String> instructionValue(String instructionName) {
    if (instructionName.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        return createListFromPropertyString(getSymbolicName());
    } else if (instructionName.equals(Analyzer.BUNDLE_NAME)) {
        return createListFromPropertyString(getName());
    } else if (instructionName.equals(Analyzer.BUNDLE_VERSION)) {
        return createListFromPropertyString(getVersion());
    } else if (instructionName.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        return createListFromPropertyString(getDescription());
    } else if (instructionName.equals(Analyzer.BUNDLE_LICENSE)) {
        return createListFromPropertyString(getLicense());
    } else if (instructionName.equals(Analyzer.BUNDLE_VENDOR)) {
        return createListFromPropertyString(getVendor());
    } else if (instructionName.equals(Analyzer.BUNDLE_DOCURL)) {
        return createListFromPropertyString(getDocURL());
    } else {
        return unmodelledInstructions.get(instructionName);
    }
}
 
Example #12
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
 
Example #13
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Map<String, List<String>> getModelledInstructions() {
    Map<String, List<String>> modelledInstructions = new HashMap<String, List<String>>();
    modelledInstructions.put(Analyzer.BUNDLE_SYMBOLICNAME, createListFromPropertyString(symbolicName));
    modelledInstructions.put(Analyzer.BUNDLE_NAME, createListFromPropertyString(name));
    modelledInstructions.put(Analyzer.BUNDLE_VERSION, createListFromPropertyString(version));
    modelledInstructions.put(Analyzer.BUNDLE_DESCRIPTION, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_LICENSE, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_VENDOR, createListFromPropertyString(vendor));
    modelledInstructions.put(Analyzer.BUNDLE_DOCURL, createListFromPropertyString(docURL));

    return CollectionUtils.filter(modelledInstructions, new Spec<Map.Entry<String, List<String>>>() {
        public boolean isSatisfiedBy(Map.Entry<String, List<String>> element) {
            return element.getValue() != null;
        }
    });
}
 
Example #14
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeSetModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(createPropertyStringFromArray(values));
        return true;
    } else {
        return false;
    }
}
 
Example #15
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybePrependModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(prependValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(prependValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(prependValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(prependValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(prependValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(prependValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(prependValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #16
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<String> instructionValue(String instructionName) {
    if (instructionName.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        return createListFromPropertyString(getSymbolicName());
    } else if (instructionName.equals(Analyzer.BUNDLE_NAME)) {
        return createListFromPropertyString(getName());
    } else if (instructionName.equals(Analyzer.BUNDLE_VERSION)) {
        return createListFromPropertyString(getVersion());
    } else if (instructionName.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        return createListFromPropertyString(getDescription());
    } else if (instructionName.equals(Analyzer.BUNDLE_LICENSE)) {
        return createListFromPropertyString(getLicense());
    } else if (instructionName.equals(Analyzer.BUNDLE_VENDOR)) {
        return createListFromPropertyString(getVendor());
    } else if (instructionName.equals(Analyzer.BUNDLE_DOCURL)) {
        return createListFromPropertyString(getDocURL());
    } else {
        return unmodelledInstructions.get(instructionName);
    }
}
 
Example #17
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
 
Example #18
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
 
Example #19
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Map<String, List<String>> getModelledInstructions() {
    Map<String, List<String>> modelledInstructions = new HashMap<String, List<String>>();
    modelledInstructions.put(Analyzer.BUNDLE_SYMBOLICNAME, createListFromPropertyString(symbolicName));
    modelledInstructions.put(Analyzer.BUNDLE_NAME, createListFromPropertyString(name));
    modelledInstructions.put(Analyzer.BUNDLE_VERSION, createListFromPropertyString(version));
    modelledInstructions.put(Analyzer.BUNDLE_DESCRIPTION, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_LICENSE, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_VENDOR, createListFromPropertyString(vendor));
    modelledInstructions.put(Analyzer.BUNDLE_DOCURL, createListFromPropertyString(docURL));

    return CollectionUtils.filter(modelledInstructions, new Spec<Map.Entry<String, List<String>>>() {
        public boolean isSatisfiedBy(Map.Entry<String, List<String>> element) {
            return element.getValue() != null;
        }
    });
}
 
Example #20
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeSetModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(createPropertyStringFromArray(values));
        return true;
    } else {
        return false;
    }
}
 
Example #21
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybePrependModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(prependValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(prependValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(prependValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(prependValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(prependValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(prependValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(prependValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #22
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<String> instructionValue(String instructionName) {
    if (instructionName.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        return createListFromPropertyString(getSymbolicName());
    } else if (instructionName.equals(Analyzer.BUNDLE_NAME)) {
        return createListFromPropertyString(getName());
    } else if (instructionName.equals(Analyzer.BUNDLE_VERSION)) {
        return createListFromPropertyString(getVersion());
    } else if (instructionName.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        return createListFromPropertyString(getDescription());
    } else if (instructionName.equals(Analyzer.BUNDLE_LICENSE)) {
        return createListFromPropertyString(getLicense());
    } else if (instructionName.equals(Analyzer.BUNDLE_VENDOR)) {
        return createListFromPropertyString(getVendor());
    } else if (instructionName.equals(Analyzer.BUNDLE_DOCURL)) {
        return createListFromPropertyString(getDocURL());
    } else {
        return unmodelledInstructions.get(instructionName);
    }
}
 
Example #23
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeAppendModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(appendValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(appendValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(appendValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(appendValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(appendValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(appendValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(appendValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #24
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<String> instructionValue(String instructionName) {
    if (instructionName.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        return createListFromPropertyString(getSymbolicName());
    } else if (instructionName.equals(Analyzer.BUNDLE_NAME)) {
        return createListFromPropertyString(getName());
    } else if (instructionName.equals(Analyzer.BUNDLE_VERSION)) {
        return createListFromPropertyString(getVersion());
    } else if (instructionName.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        return createListFromPropertyString(getDescription());
    } else if (instructionName.equals(Analyzer.BUNDLE_LICENSE)) {
        return createListFromPropertyString(getLicense());
    } else if (instructionName.equals(Analyzer.BUNDLE_VENDOR)) {
        return createListFromPropertyString(getVendor());
    } else if (instructionName.equals(Analyzer.BUNDLE_DOCURL)) {
        return createListFromPropertyString(getDocURL());
    } else {
        return unmodelledInstructions.get(instructionName);
    }
}
 
Example #25
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeAppendModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(appendValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(appendValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(appendValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(appendValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(appendValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(appendValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(appendValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #26
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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);
    }
    return getEffectiveManifestInternal(effectiveManifest);
}
 
Example #27
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Map<String, List<String>> getModelledInstructions() {
    Map<String, List<String>> modelledInstructions = new HashMap<String, List<String>>();
    modelledInstructions.put(Analyzer.BUNDLE_SYMBOLICNAME, createListFromPropertyString(symbolicName));
    modelledInstructions.put(Analyzer.BUNDLE_NAME, createListFromPropertyString(name));
    modelledInstructions.put(Analyzer.BUNDLE_VERSION, createListFromPropertyString(version));
    modelledInstructions.put(Analyzer.BUNDLE_DESCRIPTION, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_LICENSE, createListFromPropertyString(description));
    modelledInstructions.put(Analyzer.BUNDLE_VENDOR, createListFromPropertyString(vendor));
    modelledInstructions.put(Analyzer.BUNDLE_DOCURL, createListFromPropertyString(docURL));

    return CollectionUtils.filter(modelledInstructions, new Spec<Map.Entry<String, List<String>>>() {
        public boolean isSatisfiedBy(Map.Entry<String, List<String>> element) {
            return element.getValue() != null;
        }
    });
}
 
Example #28
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybeSetModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(createPropertyStringFromArray(values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(createPropertyStringFromArray(values));
        return true;
    } else {
        return false;
    }
}
 
Example #29
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean maybePrependModelledInstruction(String name, String... values) {
    if (name.equals(Analyzer.BUNDLE_SYMBOLICNAME)) {
        setSymbolicName(prependValues(getSymbolicName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_NAME)) {
        setName(prependValues(getName(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VERSION)) {
        setVersion(prependValues(getVersion(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DESCRIPTION)) {
        setDescription(prependValues(getDescription(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_LICENSE)) {
        setLicense(prependValues(getLicense(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_VENDOR)) {
        setVendor(prependValues(getVendor(), values));
        return true;
    } else if (name.equals(Analyzer.BUNDLE_DOCURL)) {
        setDocURL(prependValues(getDocURL(), values));
        return true;
    } else {
        return false;
    }
}
 
Example #30
Source File: MavenUtilsTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetDefaultPropertiesOnMinimalPom() throws Exception {
    Model model = new Model();
    model.setPomFile(new File("target/test-classes/maven/test/minimal.xml"));
    MavenProject project = new MavenProject(model);
    project.setFile(new File("target/test-classes/maven/test/minimal.xml"));
    project.setArtifactId("acme");
    project.setGroupId("corp.acme");
    project.setVersion("1.0.0-SNAPSHOT");
    final ProjectArtifact artifact = new ProjectArtifact(project);
    project.setArtifact(artifact);
    Build build = new Build();
    build.setDirectory(new File(project.getBasedir(), "target").getAbsolutePath());
    build.setOutputDirectory(new File(project.getBasedir(), "target/classes").getAbsolutePath());
    project.setBuild(build);

    Properties properties = MavenUtils.getDefaultProperties(project);
    assertThat(properties.getProperty("maven-symbolicname")).isEqualTo(DefaultMaven2OsgiConverter
            .getBundleSymbolicName(artifact));
    assertThat(properties.getProperty(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME)).isEqualTo(DefaultMaven2OsgiConverter
            .getBundleSymbolicName(artifact));

    assertThat(properties.getProperty(org.osgi.framework.Constants.BUNDLE_VERSION)).isEqualTo(DefaultMaven2OsgiConverter
            .getVersion(project.getVersion()));

    assertThat(properties.getProperty(org.osgi.framework.Constants.BUNDLE_DESCRIPTION)).isNull();
    assertThat(properties.getProperty(Analyzer.BUNDLE_LICENSE)).isNull();
    assertThat(properties.getProperty(Analyzer.BUNDLE_VENDOR)).isNull();
    assertThat(properties.getProperty(Analyzer.BUNDLE_DOCURL)).isNull();

    assertThat(properties.getProperty(Analyzer.BUNDLE_LICENSE)).isNull();

    assertThat(properties.getProperty(Analyzer.BUNDLE_NAME)).isEqualTo(project.getArtifactId());
}