Search in sources :

Example 26 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class ProvisioningWithConfigTestCase method testMainAdvanced.

@Test
public void testMainAdvanced() throws Exception {
    ProvisioningConfig found = validator.validateAndParse("xml/provisioning/provisioning-config2.xml", null, null);
    ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep("foo", FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final")).setInheritConfigs(false).addPatch(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0-patch.Final").getFPID()).addPatch(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.1-patch.Final").getFPID()).includeConfigModel("model1").excludeConfigModel("model2").excludeDefaultConfig("model1", "name1").includeDefaultConfig("model2", "name2").addConfig(ConfigModel.builder().setName("main").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")).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")).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.builder("dep4").setOrigin("source4").build()).addFeature(new FeatureConfig("spec1").setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v3").setParam("p2", "v4")).setInheritLayers(false).includeLayer("layer1").excludeLayer("layer2").includeLayer("layer3").excludeLayer("layer4").setProperty("prop1", "value1").setProperty("prop2", "value2").setConfigDep("id1", new ConfigId("model1", "name1")).setConfigDep("id2", new ConfigId("model2", null)).setConfigDep("id3", new ConfigId(null, "name3")).build()).build()).build();
    Assert.assertEquals(expected, found);
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeatureConfig(org.jboss.galleon.config.FeatureConfig) ConfigId(org.jboss.galleon.config.ConfigId) Test(org.junit.Test)

Example 27 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method includeLayer.

private void includeLayer(ConfigModelStack configStack, ConfigId layerId) throws ProvisioningException {
    if (!configStack.addLayer(layerId)) {
        return;
    }
    final ConfigModelStack layerStack = resolveConfigLayer(layerId);
    if (layerStack.hasLayerDeps()) {
        for (ConfigLayerDependency layerDep : layerStack.getLayerDeps()) {
            if (configStack.isLayerExcluded(layerDep.getName())) {
                if (layerDep.isOptional()) {
                    continue;
                }
                throw new ProvisioningException(Errors.unsatisfiedLayerDependency(layerId.getName(), layerDep.getName()));
            }
            includeLayer(configStack, new ConfigId(configStack.id.getModel(), layerDep.getName()));
        }
    }
    configStack.includedLayer(layerId);
    for (ResolvedFeature feature : layerStack.orderFeatures(false)) {
        if (configStack.isFilteredOut(feature.getSpecId(), feature.getId())) {
            continue;
        }
        configStack.includeFeature(feature.id, feature.spec, feature.params, feature.deps, feature.unsetParams, feature.resetParams);
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency) ConfigId(org.jboss.galleon.config.ConfigId)

Example 28 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method buildConfigs.

private void buildConfigs(List<ProvisionedConfig> configList, Set<Map.Entry<ConfigId, ConfigModelStack>> configStacks) throws ProvisioningException {
    for (Map.Entry<ConfigId, ConfigModelStack> entry : configStacks) {
        final ConfigId id = entry.getKey();
        if (id.getName() == null || contains(configList, id)) {
            continue;
        }
        orderConfig(entry.getValue(), configList, Collections.emptySet());
    }
}
Also used : ConfigId(org.jboss.galleon.config.ConfigId) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 29 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method collectDefaultConfigs.

private void collectDefaultConfigs(FeaturePackConfig fpConfig) throws ProvisioningException {
    thisOrigin = layout.getFeaturePack(fpConfig.getLocation().getProducer());
    final FeaturePackRuntimeBuilder parentFp = setOrigin(thisOrigin);
    try {
        if (fpConfig.hasDefinedConfigs()) {
            for (ConfigModel config : fpConfig.getDefinedConfigs()) {
                final ConfigId id = config.getId();
                if (id.isModelOnly() || fpConfigStack.isFilteredOut(thisOrigin.producer, id, true)) {
                    continue;
                }
                ConfigModelStack configStack = configsToBuild.get(id);
                if (configStack == null) {
                    configStack = getConfigStack(id);
                    configsToBuild = CollectionUtils.putLinked(configsToBuild, id, configStack);
                }
            }
        }
        if (!fpConfig.isTransitive()) {
            if (fpConfig.hasIncludedConfigs()) {
                for (ConfigId id : fpConfig.getIncludedConfigs()) {
                    collectConfigIfNotFiltered(thisOrigin.producer, id);
                }
            }
            final FeaturePackSpec currentSpec = currentOrigin.getSpec();
            if (currentSpec.hasDefinedConfigs()) {
                for (ConfigModel config : currentSpec.getDefinedConfigs()) {
                    collectConfigIfNotFiltered(thisOrigin.producer, config.getId());
                }
            }
            if (currentSpec.hasFeaturePackDeps()) {
                boolean extendedStackLevel = false;
                if (currentSpec.hasTransitiveDeps()) {
                    for (FeaturePackConfig fpDep : currentSpec.getTransitiveDeps()) {
                        extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
                    }
                }
                for (FeaturePackConfig fpDep : currentSpec.getFeaturePackDeps()) {
                    extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
                }
                if (extendedStackLevel) {
                    while (fpConfigStack.hasNext()) {
                        collectDefaultConfigs(fpConfigStack.next());
                    }
                }
                if (extendedStackLevel) {
                    fpConfigStack.popLevel();
                }
            }
        }
    } finally {
        this.thisOrigin = parentFp;
        setOrigin(parentFp);
    }
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) FeaturePackSpec(org.jboss.galleon.spec.FeaturePackSpec) ConfigId(org.jboss.galleon.config.ConfigId) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 30 with ConfigId

use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method processFpConfig.

private void processFpConfig(FeaturePackConfig fpConfig) throws ProvisioningException {
    thisOrigin = layout.getFeaturePack(fpConfig.getLocation().getProducer());
    final FeaturePackRuntimeBuilder parentFp = setOrigin(thisOrigin);
    try {
        List<ConfigModelStack> fpConfigStacks = Collections.emptyList();
        List<ConfigModelStack> specConfigStacks = Collections.emptyList();
        for (Map.Entry<ConfigId, ConfigModelStack> entry : configsToBuild.entrySet()) {
            final ConfigId configId = entry.getKey();
            configStack = entry.getValue();
            final ConfigModel config = fpConfig.getDefinedConfig(configId);
            if (config != null && !fpConfigStack.isFilteredOut(thisOrigin.producer, configId, true)) {
                fpConfigStacks = pushConfig(fpConfigStacks, config);
            }
            if (fpConfig.isTransitive()) {
                continue;
            }
            if (fpConfigStack.isIncludedInTransitiveDeps(thisOrigin.producer, configId) || !fpConfigStack.isFilteredOutFromDeps(thisOrigin.producer, configId, false) && (thisOrigin.getSpec().hasDefinedConfig(configId) || configStack.size() > 1 || thisOrigin.getConfig(configId) != null)) {
                specConfigStacks = pushFpConfig(specConfigStacks, configId);
            }
        }
        configStack = null;
        boolean extendedStackLevel = false;
        if (!fpConfig.isTransitive()) {
            extendedStackLevel = processFpDepConfigs(currentOrigin.getSpec());
            if (currentOrigin.getSpec().hasDefaultPackages()) {
                for (String packageName : currentOrigin.getSpec().getDefaultPackageNames()) {
                    if (fpConfigStack.isPackageFilteredOut(currentOrigin.producer, packageName)) {
                        continue;
                    }
                    resolvePackage(packageName, null, PackageDependencySpec.REQUIRED);
                }
            }
        }
        if (!specConfigStacks.isEmpty()) {
            for (int i = specConfigStacks.size() - 1; i >= 0; --i) {
                final ConfigModelStack configStack = specConfigStacks.get(i);
                processConfig(configStack, popConfig(configStack));
            }
        }
        if (fpConfig.hasIncludedPackages()) {
            for (String pkgName : fpConfig.getIncludedPackages()) {
                if (fpConfigStack.isPackageFilteredOut(currentOrigin.producer, pkgName)) {
                    continue;
                }
                resolvePackage(pkgName, null, PackageDependencySpec.REQUIRED);
            }
        }
        if (!fpConfigStacks.isEmpty()) {
            for (int i = fpConfigStacks.size() - 1; i >= 0; --i) {
                final ConfigModelStack configStack = fpConfigStacks.get(i);
                processConfig(configStack, popConfig(configStack));
            }
        }
        if (extendedStackLevel) {
            fpConfigStack.popLevel();
        }
    } finally {
        this.thisOrigin = parentFp;
        setOrigin(parentFp);
    }
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) ConfigId(org.jboss.galleon.config.ConfigId) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ConfigId (org.jboss.galleon.config.ConfigId)39 ConfigModel (org.jboss.galleon.config.ConfigModel)12 Path (java.nio.file.Path)11 Map (java.util.Map)10 ProvisioningException (org.jboss.galleon.ProvisioningException)9 IOException (java.io.IOException)7 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)6 HashMap (java.util.HashMap)5 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)5 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)3 ElementNode (org.jboss.galleon.xml.util.ElementNode)3 BufferedWriter (java.io.BufferedWriter)2 FileVisitResult (java.nio.file.FileVisitResult)2