Search in sources :

Example 21 with FeaturePackConfig

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

the class AbstractFPProvisionedCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc, State session) throws IOException, ProvisioningException, CommandExecutionException {
    FeaturePackConfig cf = getProvisionedFP(invoc.getPmSession());
    runCommand(invoc, session, cf);
}
Also used : FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 22 with FeaturePackConfig

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

the class AbstractFPProvisionedDependentCompleter method getItems.

@Override
protected List<String> getItems(PmCompleterInvocation completerInvocation) {
    try {
        AbstractFPProvisionedCommand cmd = (AbstractFPProvisionedCommand) completerInvocation.getCommand();
        FeaturePackConfig fp = cmd.getProvisionedFP(completerInvocation.getPmSession());
        if (fp == null) {
            return Collections.emptyList();
        }
        return getItems(completerInvocation, fp);
    } catch (Exception ex) {
        CliLogging.completionException(ex);
        return Collections.emptyList();
    }
}
Also used : FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 23 with FeaturePackConfig

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

the class AbstractProvisionedPackageCommand method getPackage.

protected String getPackage(PmSession session) throws CommandExecutionException {
    FeaturePackConfig cf = getProvisionedFP(session);
    Set<String> ids = getTargetedPackages(cf);
    if (ids.contains(pkg)) {
        return pkg;
    }
    return null;
}
Also used : FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 24 with FeaturePackConfig

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

the class AbstractPackageCommand method getProvisionedFP.

@Override
public FeaturePackConfig getProvisionedFP(PmSession session) throws CommandExecutionException {
    FeaturePackConfig config = super.getProvisionedFP(session);
    if (config == null) {
        // Problem, the package is not directly part of the added FP. Must retrieve it in the packages of
        // its internal dependencies.
        int i = getPackage().indexOf("/");
        String orig = getPackage().substring(0, i);
        String name = getPackage().substring(i + 1);
        FeaturePackLocation.FPID fpid = null;
        FeatureContainer container = session.getContainer().getFullDependencies().get(orig);
        if (container != null) {
            if (container.getAllPackages().containsKey(Identity.fromString(orig, name))) {
                fpid = container.getFPID();
            }
        }
        if (fpid == null) {
            throw new CommandExecutionException("No package found for " + getPackage());
        }
        for (FeaturePackConfig c : session.getState().getConfig().getFeaturePackDeps()) {
            if (c.getLocation().getFPID().equals(fpid)) {
                config = c;
                break;
            }
        }
        if (config == null) {
            // reset buildID
            FeaturePackLocation noBuildLocation = new FeaturePackLocation(fpid.getUniverse(), fpid.getProducer().getName(), null, null, null);
            for (FeaturePackConfig c : session.getState().getConfig().getTransitiveDeps()) {
                if (c.getLocation().equals(c.getLocation().hasBuild() ? fpid.getLocation() : noBuildLocation)) {
                    config = c;
                    break;
                }
            }
        }
    }
    return config;
}
Also used : FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 25 with FeaturePackConfig

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

the class FeaturePackXmlWriter method toElement.

protected ElementNode toElement(FeaturePackSpec fpSpec) {
    final ElementNode fp = addElement(null, Element.FEATURE_PACK);
    addAttribute(fp, Attribute.LOCATION, fpSpec.getFPID().toString());
    ProvisioningXmlWriter.writeUniverseSpecs(fpSpec, fp);
    if (fpSpec.isPatch()) {
        final ElementNode patchFor = addElement(fp, Element.PATCH);
        addAttribute(patchFor, Attribute.FOR, fpSpec.getPatchFor().toString());
    }
    if (fpSpec.hasTransitiveDeps()) {
        final ElementNode transitives = addElement(fp, Element.TRANSITIVE);
        for (FeaturePackConfig dep : fpSpec.getTransitiveDeps()) {
            final ElementNode depElement = addElement(transitives, Element.DEPENDENCY);
            ProvisioningXmlWriter.writeFeaturePackConfig(depElement, fpSpec.getUserConfiguredLocation(dep.getLocation()), dep, fpSpec.originOf(dep.getLocation().getProducer()));
        }
    }
    if (fpSpec.hasFeaturePackDeps()) {
        final ElementNode deps = addElement(fp, Element.DEPENDENCIES);
        for (FeaturePackConfig dep : fpSpec.getFeaturePackDeps()) {
            final ElementNode depElement = addElement(deps, Element.DEPENDENCY);
            ProvisioningXmlWriter.writeFeaturePackConfig(depElement, fpSpec.getUserConfiguredLocation(dep.getLocation()), dep, fpSpec.originOf(dep.getLocation().getProducer()));
        }
    }
    ProvisioningXmlWriter.writeConfigCustomizations(fp, Element.FEATURE_PACK.getNamespace(), fpSpec);
    if (fpSpec.hasDefaultPackages()) {
        final ElementNode pkgs = addElement(fp, Element.DEFAULT_PACKAGES);
        final String[] pkgNames = fpSpec.getDefaultPackageNames().toArray(new String[0]);
        Arrays.sort(pkgNames);
        for (String name : pkgNames) {
            addAttribute(addElement(pkgs, Element.PACKAGE), Attribute.NAME, name);
        }
    }
    if (fpSpec.hasPlugins()) {
        final ElementNode plugins = addElement(fp, Element.PLUGINS);
        for (FeaturePackPlugin plugin : fpSpec.getPlugins().values()) {
            final ElementNode pluginE = addElement(plugins, Element.PLUGIN);
            addAttribute(pluginE, Attribute.ID, plugin.getId());
            addAttribute(pluginE, Attribute.LOCATION, plugin.getLocation());
        }
    }
    return fp;
}
Also used : FeaturePackPlugin(org.jboss.galleon.spec.FeaturePackPlugin) ElementNode(org.jboss.galleon.xml.util.ElementNode) 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