Search in sources :

Example 1 with Maven2OsgiConverter

use of org.apache.maven.shared.osgi.Maven2OsgiConverter in project sling by apache.

the class BaseBundleList method add.

/**
     * Merge bundle into a start level using the supplied level if present.
     * @param mergeStartLevel
     * @param newBnd
     */
private void add(StartLevel mergeStartLevel, Bundle newBnd) {
    Bundle current = get(newBnd, false);
    if (current != null) {
        final Maven2OsgiConverter converter = new DefaultMaven2OsgiConverter();
        // compare versions, the highest will be used
        final Version newVersion = new Version(converter.getVersion(newBnd.getVersion()));
        final Version oldVersion = new Version(converter.getVersion(current.getVersion()));
        if (newVersion.compareTo(oldVersion) > 0) {
            current.setVersion(newBnd.getVersion());
        }
    } else {
        StartLevel startLevel = null;
        if (mergeStartLevel == null || newBnd.getStartLevel() != 0) {
            startLevel = getOrCreateStartLevel(newBnd.getStartLevel());
        } else {
            startLevel = getOrCreateStartLevel(mergeStartLevel.getStartLevel());
        }
        startLevel.getBundles().add(newBnd);
    }
}
Also used : Maven2OsgiConverter(org.apache.maven.shared.osgi.Maven2OsgiConverter) DefaultMaven2OsgiConverter(org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter) Version(org.osgi.framework.Version) Bundle(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle) StartLevel(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel) DefaultMaven2OsgiConverter(org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter)

Aggregations

DefaultMaven2OsgiConverter (org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter)1 Maven2OsgiConverter (org.apache.maven.shared.osgi.Maven2OsgiConverter)1 Bundle (org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle)1 StartLevel (org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel)1 Version (org.osgi.framework.Version)1