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)));
}
}
}
}
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;
}
Aggregations