use of org.apache.karaf.features.internal.model.Features in project karaf by apache.
the class Builder method startupStage.
private Profile startupStage(Profile startupProfile) throws Exception {
LOGGER.info("Startup stage");
//
// Compute startup
//
Profile startupOverlay = Profiles.getOverlay(startupProfile, allProfiles, environment);
Profile startupEffective = Profiles.getEffective(startupOverlay, false);
// Load startup repositories
LOGGER.info(" Loading repositories");
Map<String, Features> startupRepositories = loadRepositories(manager, startupEffective.getRepositories(), false);
//
// Resolve
//
LOGGER.info(" Resolving features");
Map<String, Integer> bundles = resolve(manager, resolver, startupRepositories.values(), startupEffective.getFeatures(), startupEffective.getBundles(), startupEffective.getOverrides(), startupEffective.getOptionals());
//
// Generate startup.properties
//
Properties startup = new Properties();
startup.setHeader(Collections.singletonList("# Bundles to be started on startup, with startlevel"));
Map<Integer, Set<String>> invertedStartupBundles = MapUtils.invert(bundles);
for (Map.Entry<Integer, Set<String>> entry : new TreeMap<>(invertedStartupBundles).entrySet()) {
String startLevel = Integer.toString(entry.getKey());
for (String location : new TreeSet<>(entry.getValue())) {
if (useReferenceUrls) {
if (location.startsWith("mvn:")) {
location = "file:" + Parser.pathFromMaven(location);
}
if (location.startsWith("file:")) {
location = "reference:" + location;
}
}
if (location.startsWith("file:") && karafVersion == KarafVersion.v24) {
location = location.substring("file:".length());
}
startup.put(location, startLevel);
}
}
Path startupProperties = etcDirectory.resolve("startup.properties");
startup.save(startupProperties.toFile());
return startupEffective;
}
use of org.apache.karaf.features.internal.model.Features in project karaf by apache.
the class GenerateDescriptorMojoTest method testReadXml1.
@Test
public void testReadXml1() throws Exception {
URL url = getClass().getClassLoader().getResource("input-features-1.1.0.xml");
Features featuresRoot = JaxbUtil.unmarshal(url.toExternalForm(), false);
List<Feature> featuresList = featuresRoot.getFeature();
assertEquals(featuresList.size(), 1);
Feature feature = featuresList.get(0);
assertEquals(feature.getInstall(), "auto");
}
use of org.apache.karaf.features.internal.model.Features in project karaf by apache.
the class GenerateDescriptorMojo method saveDependencyChanges.
protected void saveDependencyChanges(Collection<Bundle> addedBundles, Collection<Bundle> removedBundles, Collection<Dependency> addedDependencys, Collection<Dependency> removedDependencys, ObjectFactory objectFactory) throws Exception {
File addedFile = new File(filteredDependencyCache.getParentFile(), "dependencies.added.xml");
Features added = toFeatures(addedBundles, addedDependencys, objectFactory);
writeDependencies(added, addedFile);
File removedFile = new File(filteredDependencyCache.getParentFile(), "dependencies.removed.xml");
Features removed = toFeatures(removedBundles, removedDependencys, objectFactory);
writeDependencies(removed, removedFile);
StringWriter out = new StringWriter();
out.write(saveTreeListing());
out.write("Dependencies have changed:\n");
if (!addedBundles.isEmpty() || !addedDependencys.isEmpty()) {
out.write("\tAdded dependencies are saved here: " + addedFile.getAbsolutePath() + "\n");
if (logDependencyChanges) {
JaxbUtil.marshal(added, out);
}
}
if (!removedBundles.isEmpty() || !removedDependencys.isEmpty()) {
out.write("\tRemoved dependencies are saved here: " + removedFile.getAbsolutePath() + "\n");
if (logDependencyChanges) {
JaxbUtil.marshal(removed, out);
}
}
out.write("Delete " + dependencyCache.getAbsolutePath() + " if you are happy with the dependency changes.");
if (failOnDependencyChange) {
throw new MojoFailureException(out.toString());
} else {
getLog().warn(out.toString());
}
}
use of org.apache.karaf.features.internal.model.Features 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.Features in project karaf by apache.
the class FeaturesValidationTest method testNs11Unmarshall.
@Test
public void testNs11Unmarshall() throws Exception {
URL url = getClass().getResource("f04.xml");
Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
assertNotNull(features);
}
Aggregations