Search in sources :

Example 36 with Features

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

the class GenerateDescriptorMojo method processFeatureArtifact.

private void processFeatureArtifact(Features features, Feature feature, Map<Dependency, Feature> otherFeatures, Map<Feature, String> featureRepositories, FeaturesCache cache, Object artifact, Object parent, boolean add) throws MojoExecutionException, XMLStreamException, JAXBException, IOException {
    if (this.dependencyHelper.isArtifactAFeature(artifact) && FEATURE_CLASSIFIER.equals(this.dependencyHelper.getClassifier(artifact))) {
        File featuresFile = this.dependencyHelper.resolve(artifact, getLog());
        if (featuresFile == null || !featuresFile.exists()) {
            throw new MojoExecutionException("Cannot locate file for feature: " + artifact + " at " + featuresFile);
        }
        Features includedFeatures = cache.getFeature(featuresFile);
        for (String repository : includedFeatures.getRepository()) {
            processFeatureArtifact(features, feature, otherFeatures, featureRepositories, cache, cache.getArtifact(repository), parent, false);
        }
        for (Feature includedFeature : includedFeatures.getFeature()) {
            Dependency dependency = new Dependency(includedFeature.getName(), includedFeature.getVersion());
            dependency.setPrerequisite(prerequisiteFeatures.contains(dependency.getName()));
            dependency.setDependency(dependencyFeatures.contains(dependency.getName()));
            // Determine what dependency we're actually going to use
            Dependency matchingDependency = findMatchingDependency(feature.getFeature(), dependency);
            if (matchingDependency != null) {
                // The feature already has a matching dependency, merge
                mergeDependencies(matchingDependency, dependency);
                dependency = matchingDependency;
            }
            // We mustn't de-duplicate here, we may have seen a feature in !add mode
            otherFeatures.put(dependency, includedFeature);
            if (add) {
                if (!feature.getFeature().contains(dependency)) {
                    feature.getFeature().add(dependency);
                }
                if (aggregateFeatures) {
                    features.getFeature().add(includedFeature);
                }
            }
            if (!featureRepositories.containsKey(includedFeature)) {
                featureRepositories.put(includedFeature, this.dependencyHelper.artifactToMvn(artifact, getVersionOrRange(parent, artifact)));
            }
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Features(org.apache.karaf.features.internal.model.Features) Dependency(org.apache.karaf.features.internal.model.Dependency) LocalDependency(org.apache.karaf.tooling.utils.LocalDependency) ConfigFile(org.apache.karaf.features.internal.model.ConfigFile) File(java.io.File) Feature(org.apache.karaf.features.internal.model.Feature)

Example 37 with Features

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

the class GenerateDescriptorMojo method toFeatures.

private static 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

Features (org.apache.karaf.features.internal.model.Features)37 Feature (org.apache.karaf.features.internal.model.Feature)21 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)14 File (java.io.File)12 LinkedHashMap (java.util.LinkedHashMap)12 IOException (java.io.IOException)11 LinkedHashSet (java.util.LinkedHashSet)11 URL (java.net.URL)10 HashSet (java.util.HashSet)10 ConfigFile (org.apache.karaf.features.internal.model.ConfigFile)10 Test (org.junit.Test)10 Map (java.util.Map)9 TreeMap (java.util.TreeMap)9 Downloader (org.apache.karaf.features.internal.download.Downloader)8 InputStream (java.io.InputStream)7 List (java.util.List)7 Bundle (org.apache.karaf.features.internal.model.Bundle)7 Conditional (org.apache.karaf.features.internal.model.Conditional)7 Dependency (org.apache.karaf.features.internal.model.Dependency)7