Search in sources :

Example 6 with FeatureGroup

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;
}
Also used : FeatureGroup(org.jboss.galleon.config.FeatureGroup) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 7 with FeatureGroup

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));
    }
}
Also used : FeatureGroup(org.jboss.galleon.config.FeatureGroup) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 8 with FeatureGroup

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);
}
Also used : FeatureGroup(org.jboss.galleon.config.FeatureGroup) FeatureConfig(org.jboss.galleon.config.FeatureConfig) Test(org.junit.Test)

Aggregations

FeatureGroup (org.jboss.galleon.config.FeatureGroup)8 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)4 Map (java.util.Map)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 ProvisioningException (org.jboss.galleon.ProvisioningException)2 BufferedReader (java.io.BufferedReader)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 UnsatisfiedPackageDependencyException (org.jboss.galleon.UnsatisfiedPackageDependencyException)1 ConfigId (org.jboss.galleon.config.ConfigId)1 ConfigModel (org.jboss.galleon.config.ConfigModel)1 FeatureConfig (org.jboss.galleon.config.FeatureConfig)1 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)1 FeaturePackDepsConfig (org.jboss.galleon.config.FeaturePackDepsConfig)1 ConfigLayerSpec (org.jboss.galleon.spec.ConfigLayerSpec)1 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)1 FeatureSpec (org.jboss.galleon.spec.FeatureSpec)1 PackageSpec (org.jboss.galleon.spec.PackageSpec)1