Search in sources :

Example 31 with FeaturePackConfig

use of org.jboss.galleon.config.FeaturePackConfig 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 32 with FeaturePackConfig

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

the class ProvisioningRuntimeBuilder method resolveModelOnlyConfig.

private ConfigModelStack resolveModelOnlyConfig(FeaturePackConfig fpConfig, ConfigModelStack modelOnlyStack, ConfigId configId) throws ProvisioningException {
    final FeaturePackRuntimeBuilder fp = layout.getFeaturePack(fpConfig.getLocation().getProducer());
    if (!setFlag(fp, FeaturePackRuntimeBuilder.RESOLVE_MODEL_ONLY_CONFIG)) {
        return modelOnlyStack;
    }
    final FeaturePackRuntimeBuilder prevOrigin = currentOrigin;
    try {
        int pushedCount = 0;
        ConfigModel config = fpConfig.getDefinedConfig(configId);
        if (config != null) {
            if (modelOnlyStack == null) {
                modelOnlyStack = new ConfigModelStack(configId, this);
            }
            modelOnlyStack.pushConfig(config);
            ++pushedCount;
        }
        config = fp.getSpec().getDefinedConfig(configId);
        if (config != null) {
            if (modelOnlyStack == null) {
                modelOnlyStack = new ConfigModelStack(configId, this);
            }
            modelOnlyStack.pushConfig(config);
            ++pushedCount;
        }
        config = fp.getConfig(configId);
        if (config != null) {
            if (modelOnlyStack == null) {
                modelOnlyStack = new ConfigModelStack(configId, this);
            }
            modelOnlyStack.pushConfig(config);
            ++pushedCount;
        }
        boolean extendedStackLevel = false;
        if (fp.getSpec().hasTransitiveDeps()) {
            for (FeaturePackConfig fpDep : fp.getSpec().getTransitiveDeps()) {
                extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
            }
        }
        if (fp.getSpec().hasFeaturePackDeps()) {
            for (FeaturePackConfig fpDep : fp.getSpec().getFeaturePackDeps()) {
                extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
                if (fpDep.isConfigModelExcluded(configId) || !fpDep.isInheritModelOnlyConfigs() && !fpDep.isConfigModelIncluded(configId)) {
                    continue;
                }
                modelOnlyStack = resolveModelOnlyConfig(fpDep, modelOnlyStack, configId);
            }
        }
        while (pushedCount > 0) {
            setOrigin(fp);
            processConfig(modelOnlyStack, popConfig(modelOnlyStack));
            --pushedCount;
        }
        if (extendedStackLevel) {
            fpConfigStack.popLevel();
        }
    } finally {
        setOrigin(prevOrigin);
    }
    return modelOnlyStack;
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 33 with FeaturePackConfig

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

the class ProvisioningRuntimeBuilder method resolveConfigLayer.

private ConfigModelStack resolveConfigLayer(ConfigId layerId) throws ProvisioningException {
    ConfigModelStack layerStack = layers.get(layerId);
    if (layerStack == null) {
        layerStack = new ConfigModelStack(layerId, this);
        boolean resolved = false;
        for (FeaturePackConfig fpConfig : config.getFeaturePackDeps()) {
            resolved |= resolveConfigLayer(fpConfig.getLocation().getProducer(), layerStack, layerId);
        }
        clearFlag(FeaturePackRuntimeBuilder.RESOLVE_LAYER);
        if (!resolved) {
            throw new ProvisioningException(Errors.layerNotFound(layerId));
        }
        layers = CollectionUtils.put(layers, layerId, layerStack);
    }
    return layerStack;
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 34 with FeaturePackConfig

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

the class ProvisioningDiffProvider method getFpcBuilder.

private FeaturePackConfig.Builder getFpcBuilder(FPID fpid) {
    FeaturePackConfig.Builder fpcBuilder = updatedDirectFps.get(fpid);
    if (fpcBuilder != null) {
        return fpcBuilder;
    }
    fpcBuilder = updatedTransitiveFps.get(fpid);
    if (fpcBuilder != null) {
        return fpcBuilder;
    }
    fpcBuilder = addedTransitiveFps.get(fpid);
    if (fpcBuilder != null) {
        return fpcBuilder;
    }
    FeaturePackConfig fpc = provisionedConfig.getFeaturePackDep(fpid.getProducer());
    if (fpc != null) {
        fpcBuilder = FeaturePackConfig.builder(fpc);
        updatedDirectFps = CollectionUtils.put(updatedDirectFps, fpid, fpcBuilder);
        return fpcBuilder;
    }
    fpc = provisionedConfig.getTransitiveDep(fpid.getProducer());
    if (fpc != null) {
        fpcBuilder = FeaturePackConfig.builder(fpc);
        updatedTransitiveFps = CollectionUtils.put(updatedTransitiveFps, fpid, fpcBuilder);
        return fpcBuilder;
    }
    fpcBuilder = FeaturePackConfig.transitiveBuilder(fpid.getLocation());
    addedTransitiveFps = CollectionUtils.putLinked(addedTransitiveFps, fpid, fpcBuilder);
    return fpcBuilder;
}
Also used : FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 35 with FeaturePackConfig

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

the class ProvisioningLayout method addFpDeps.

protected void addFpDeps(final ProvisioningConfig.Builder builder, Collection<FeaturePackConfig> deps) throws ProvisioningDescriptionException {
    for (FeaturePackConfig fpConfig : deps) {
        final ProducerSpec producer = fpConfig.getLocation().getProducer();
        final FeaturePackLocation resolvedFpl = resolvedVersions.remove(producer);
        if (resolvedFpl != null) {
            builder.addFeaturePackDep(config.originOf(producer), FeaturePackConfig.builder(resolvedFpl).init(fpConfig).build());
        } else {
            builder.addFeaturePackDep(config.originOf(producer), fpConfig);
        }
    }
}
Also used : ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)40 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)12 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)12 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)11 ProvisioningException (org.jboss.galleon.ProvisioningException)9 ArrayList (java.util.ArrayList)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 Path (java.nio.file.Path)6 HashMap (java.util.HashMap)6 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)6 Test (org.junit.Test)5 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CommandException (org.aesh.command.CommandException)3 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 ConfigModel (org.jboss.galleon.config.ConfigModel)3 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)3