Search in sources :

Example 11 with Feature

use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.

the class BlacklistTest method testBlacklistBundle.

@Test
public void testBlacklistBundle() {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    List<String> blacklist = new ArrayList<>();
    blacklist.add("mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.7_1");
    Blacklist.blacklist(features, blacklist);
    for (Feature feature : features.getFeature()) {
        for (Bundle bundle : feature.getBundle()) {
            assertNotEquals("mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.7_1", bundle.getLocation());
        }
    }
}
Also used : Bundle(org.apache.karaf.features.internal.model.Bundle) ArrayList(java.util.ArrayList) Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature) URL(java.net.URL) Test(org.junit.Test)

Example 12 with Feature

use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.

the class BlacklistTest method testBlacklistFeatureWithVersion.

@Test
public void testBlacklistFeatureWithVersion() {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    List<String> blacklist = new ArrayList<>();
    blacklist.add("spring;range=2.5.6.SEC02");
    Blacklist.blacklist(features, blacklist);
    for (Feature feature : features.getFeature()) {
        assertNotEquals("spring/2.5.6.SEC02", feature.getId());
    }
}
Also used : ArrayList(java.util.ArrayList) Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature) URL(java.net.URL) Test(org.junit.Test)

Example 13 with Feature

use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.

the class BlacklistTest method testBlacklistFeatureWithRange.

@Test
public void testBlacklistFeatureWithRange() {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    List<String> blacklist = new ArrayList<>();
    blacklist.add("spring;range=\"[2,3)\"");
    Blacklist.blacklist(features, blacklist);
    for (Feature feature : features.getFeature()) {
        assertNotEquals("spring/2.5.6.SEC02", feature.getId());
    }
}
Also used : ArrayList(java.util.ArrayList) Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature) URL(java.net.URL) Test(org.junit.Test)

Example 14 with Feature

use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.

the class ExportFeatureMetaDataMojo method mergeFeatureOneVersion.

private Feature mergeFeatureOneVersion(Set<Feature> featuresSet) throws MojoExecutionException {
    Feature merged = new Feature("merged");
    Map<String, Bundle> bundleVersions = new HashMap<>();
    for (Feature feature : featuresSet) {
        for (Bundle bundle : feature.getBundle()) {
            String symbolicName = getBundleSymbolicName(bundle);
            if (symbolicName == null) {
                logIgnored(bundle);
                continue;
            }
            Bundle existingBundle = bundleVersions.get(symbolicName);
            if (existingBundle != null) {
                Version existingVersion = new Version(getBundleVersion(existingBundle));
                Version newVersion = new Version(getBundleVersion(bundle));
                if (newVersion.compareTo(existingVersion) > 0) {
                    bundleVersions.put(symbolicName, bundle);
                }
            } else {
                bundleVersions.put(symbolicName, bundle);
            }
        }
    }
    for (Bundle bundle : bundleVersions.values()) {
        merged.getBundle().add(bundle);
    }
    return merged;
}
Also used : HashMap(java.util.HashMap) Version(org.osgi.framework.Version) Bundle(org.apache.karaf.features.internal.model.Bundle) Feature(org.apache.karaf.features.internal.model.Feature)

Example 15 with Feature

use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.

the class GenerateDescriptorMojo method toFeatures.

private Features toFeatures(Collection<Bundle> addedBundles, Collection<Dependency> addedDependencys, ObjectFactory objectFactory) {
    Features features = objectFactory.createFeaturesRoot();
    Feature feature = objectFactory.createFeature();
    feature.getBundle().addAll(addedBundles);
    feature.getFeature().addAll(addedDependencys);
    features.getFeature().add(feature);
    return features;
}
Also used : Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature)

Aggregations

Feature (org.apache.karaf.features.internal.model.Feature)25 Features (org.apache.karaf.features.internal.model.Features)16 ArrayList (java.util.ArrayList)10 Bundle (org.apache.karaf.features.internal.model.Bundle)9 ConfigFile (org.apache.karaf.features.internal.model.ConfigFile)8 HashMap (java.util.HashMap)7 Downloader (org.apache.karaf.features.internal.download.Downloader)6 Dependency (org.apache.karaf.features.internal.model.Dependency)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)6 IOException (java.io.IOException)5 HashSet (java.util.HashSet)5 File (java.io.File)4 URL (java.net.URL)4 LinkedHashSet (java.util.LinkedHashSet)4 Properties (org.apache.felix.utils.properties.Properties)4 Conditional (org.apache.karaf.features.internal.model.Conditional)4 Profile (org.apache.karaf.profile.Profile)4 Test (org.junit.Test)4 Hashtable (java.util.Hashtable)3 LinkedHashMap (java.util.LinkedHashMap)3