use of org.jboss.galleon.config.FeatureGroup in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method resolveFeatureGroupConfig.
ResolvedFeatureGroupConfig resolveFeatureGroupConfig(ConfigModelStack configStack, FeatureGroupSupport fg) throws ProvisioningException {
ProducerSpec fgOrigin = null;
if (!(fg.isConfig() || fg.isLayer())) {
final FeaturePackRuntimeBuilder originalOrigin = currentOrigin;
getFeatureGroupSpec(fg.getName());
fgOrigin = currentOrigin.producer;
currentOrigin = originalOrigin;
}
final ResolvedFeatureGroupConfig resolvedFgc = new ResolvedFeatureGroupConfig(configStack, fg, fgOrigin);
resolvedFgc.inheritFeatures = fg.isInheritFeatures();
if (fg.hasExcludedSpecs()) {
resolvedFgc.excludedSpecs = resolveSpecIds(resolvedFgc.excludedSpecs, fg.getExcludedSpecs());
}
if (fg.hasIncludedSpecs()) {
resolvedFgc.includedSpecs = resolveSpecIds(resolvedFgc.includedSpecs, fg.getIncludedSpecs());
}
if (fg.hasExcludedFeatures()) {
resolvedFgc.excludedFeatures = resolveExcludedIds(resolvedFgc.excludedFeatures, fg.getExcludedFeatures());
}
if (fg.hasIncludedFeatures()) {
resolvedFgc.includedFeatures = resolveIncludedIds(resolvedFgc.includedFeatures, fg.getIncludedFeatures());
}
if (fg.hasExternalFeatureGroups()) {
final FeaturePackRuntimeBuilder originalOrigin = currentOrigin;
for (Map.Entry<String, FeatureGroup> entry : fg.getExternalFeatureGroups().entrySet()) {
final FeatureGroup extFg = entry.getValue();
setOrigin(entry.getKey());
try {
if (extFg.hasExcludedSpecs()) {
resolvedFgc.excludedSpecs = resolveSpecIds(resolvedFgc.excludedSpecs, extFg.getExcludedSpecs());
}
if (extFg.hasIncludedSpecs()) {
resolvedFgc.includedSpecs = resolveSpecIds(resolvedFgc.includedSpecs, extFg.getIncludedSpecs());
}
if (extFg.hasExcludedFeatures()) {
resolvedFgc.excludedFeatures = resolveExcludedIds(resolvedFgc.excludedFeatures, extFg.getExcludedFeatures());
}
if (extFg.hasIncludedFeatures()) {
resolvedFgc.includedFeatures = resolveIncludedIds(resolvedFgc.includedFeatures, extFg.getIncludedFeatures());
}
} finally {
setOrigin(originalOrigin);
}
}
}
return resolvedFgc;
}
use of org.jboss.galleon.config.FeatureGroup in project galleon by wildfly.
the class FeatureGroupXmlWriter method addFeatureGroupDepBody.
public static void addFeatureGroupDepBody(FeatureGroupSupport dep, final ElementNode depE, String ns) {
if (dep.getName() != null) {
addAttribute(depE, Attribute.NAME, dep.getName());
}
if (!dep.isInheritFeatures()) {
addAttribute(depE, Attribute.INHERIT_FEATURES, FALSE);
}
addFeatureGroupIncludeExclude(dep, ns, depE);
writeFeatureGroupSpecBody(depE, dep, ns);
if (dep.hasExternalFeatureGroups()) {
for (Map.Entry<String, FeatureGroup> entry : dep.getExternalFeatureGroups().entrySet()) {
final ElementNode fpE = addElement(depE, Element.ORIGIN.getLocalName(), ns);
addAttribute(fpE, Attribute.NAME, entry.getKey());
addFeatureGroupIncludeExclude(entry.getValue(), ns, fpE);
}
}
if (dep.hasPackageDeps()) {
PackageXmlWriter.writePackageDeps(dep, addElement(depE, Element.PACKAGES.getLocalName(), ns));
}
}
use of org.jboss.galleon.config.FeatureGroup in project galleon by wildfly.
the class FeatureGroupParsingTestCase method testMain.
@Test
public void testMain() throws Exception {
final FeatureGroup xmlConfig = parseConfig("feature-group.xml");
final FeatureGroup expected = FeatureGroup.builder("groupName").addFeatureGroup(FeatureGroup.builder("dep1").setInheritFeatures(true).build()).addFeatureGroup(FeatureGroup.builder("dep2").setInheritFeatures(false).build()).addFeatureGroup(FeatureGroup.builder("dep3").setInheritFeatures(false).includeSpec("spec1").includeFeature(FeatureId.fromString("spec2:p1=v1,p2=v2"), new FeatureConfig("spec2").setParam("p1", "v1").setParam("p2", "v2")).includeFeature(FeatureId.fromString("spec3:p1=v1"), new FeatureConfig("spec3").addFeatureDep(FeatureId.fromString("spec4:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec5:p1=v1,p2=v2")).setParam("p1", "v1").setParam("p2", "v2").addFeature(new FeatureConfig("spec9").setParam("p1", "v1").addFeature(FeatureConfig.newConfig("spec10").addFeature(FeatureConfig.newConfig("spec11").setParentRef("spec10-ref").setParam("p1", "v1"))))).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.forGroup("source4", "dep4")).addFeature(new FeatureConfig("spec1").setOrigin("source4").setParam("p1", "v1").setParam("p2", "v2").addFeatureDep(FeatureId.builder("spec2").setParam("p1", "v1").setParam("p2", "v2").build()).addFeatureDep(FeatureId.create("spec3", "p3", "v3"))).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec4").setParam("p1", "v1").addFeature(FeatureConfig.newConfig("spec5").addFeature(FeatureConfig.newConfig("spec6").setParentRef("spec5-ref").setParam("p1", "v1")))).addPackageDep("p1").addPackageDep("p2", true).addPackageDep("fp1", "p2").addPackageDep("fp1", "p3", true).build();
assertEquals(expected, xmlConfig);
}
Aggregations