use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.
the class ExportFeatureMetaDataMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
Set<Feature> featuresSet = resolveFeatures();
if (mergedFeature) {
Feature feature = oneVersion ? mergeFeatureOneVersion(featuresSet) : mergeFeature(featuresSet);
featuresSet = new HashSet<>();
featuresSet.add(feature);
}
try {
metaDataFile.getParentFile().mkdirs();
Features features = new Features();
features.getFeature().addAll(featuresSet);
try (OutputStream os = new FileOutputStream(metaDataFile)) {
JaxbUtil.marshal(features, os);
}
} catch (Exception e) {
throw new RuntimeException("Error writing feature meta data to " + metaDataFile + ": " + e.getMessage(), e);
}
}
use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.
the class ExportFeatureMetaDataMojo method mergeFeature.
private Feature mergeFeature(Set<Feature> featuresSet) throws MojoExecutionException {
Feature merged = new Feature("merged");
Set<String> bundleIds = new HashSet<>();
for (Feature feature : featuresSet) {
for (Bundle bundle : feature.getBundle()) {
String symbolicName = getBundleSymbolicName(bundle);
if (symbolicName == null) {
logIgnored(bundle);
continue;
}
String bundleId = symbolicName + ":" + getBundleVersion(bundle);
if (!bundleIds.contains(bundleId)) {
bundleIds.add(bundleId);
merged.getBundle().add(bundle);
}
}
}
return merged;
}
use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.
the class AbstractFeatureMojo method retrieveDescriptorsRecursively.
protected void retrieveDescriptorsRecursively(String uri, Set<String> bundles, Map<String, Feature> featuresMap) {
// let's ensure a mvn: based url is sitting in the local repo before we try reading it
Artifact descriptor;
try {
descriptor = resourceToArtifact(uri, true);
} catch (MojoExecutionException e) {
throw new RuntimeException(e.getMessage(), e);
}
if (descriptor != null) {
resolveArtifact(descriptor, remoteRepos);
descriptorArtifacts.add(descriptor);
}
if (includeMvnBasedDescriptors) {
bundles.add(uri);
}
Features repo = JaxbUtil.unmarshal(translateFromMaven(uri.replaceAll(" ", "%20")), true);
for (Feature f : repo.getFeature()) {
featuresMap.put(f.getId(), f);
}
if (resolveDefinedRepositoriesRecursively) {
for (String r : repo.getRepository()) {
retrieveDescriptorsRecursively(r, bundles, featuresMap);
}
}
}
use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.
the class AddToRepositoryMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
Set<Feature> featuresSet = resolveFeatures();
for (Artifact descriptor : descriptorArtifacts) {
copy(descriptor, repository);
}
for (Feature feature : featuresSet) {
copyBundlesToDestRepository(feature.getBundle());
for (Conditional conditional : feature.getConditional()) {
copyBundlesConditionalToDestRepository(conditional.getBundles());
}
copyConfigFilesToDestRepository(feature.getConfigfile());
}
copyFileBasedDescriptorsToDestRepository();
}
use of org.apache.karaf.features.internal.model.Feature in project karaf by apache.
the class BlacklistTest method testBlacklistFeatureWithoutVersion.
@Test
public void testBlacklistFeatureWithoutVersion() {
URL url = getClass().getResource("f02.xml");
Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
List<String> blacklist = new ArrayList<>();
blacklist.add("spring");
Blacklist.blacklist(features, blacklist);
for (Feature feature : features.getFeature()) {
assertFalse(feature.getId().startsWith("spring/"));
}
}
Aggregations