Search in sources :

Example 16 with FeaturePackConfig

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

the class GetInfoCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation commandInvocation) throws CommandExecutionException {
    if (fpl != null && file != null) {
        throw new CommandExecutionException("File and location can't be both set");
    }
    if (fpl == null && file == null) {
        throw new CommandExecutionException("File or location must be set");
    }
    PmSession session = commandInvocation.getPmSession();
    FeaturePackLayout product = null;
    List<FeaturePackLocation> dependencies = new ArrayList<>();
    ProvisioningConfig provisioning;
    ProvisioningLayout<FeaturePackLayout> layout = null;
    try {
        try {
            if (fpl != null) {
                FeaturePackLocation loc;
                loc = session.getResolvedLocation(null, fpl);
                FeaturePackConfig config = FeaturePackConfig.forLocation(loc);
                provisioning = ProvisioningConfig.builder().addFeaturePackDep(config).build();
                layout = session.getLayoutFactory().newConfigLayout(provisioning);
            } else {
                layout = session.getLayoutFactory().newConfigLayout(file.toPath(), true);
            }
            for (FeaturePackLayout fpLayout : layout.getOrderedFeaturePacks()) {
                boolean isProduct = true;
                for (FeaturePackLayout fpLayout2 : layout.getOrderedFeaturePacks()) {
                    if (fpLayout2.getSpec().hasTransitiveDep(fpLayout.getFPID().getProducer()) || fpLayout2.getSpec().getFeaturePackDep(fpLayout.getFPID().getProducer()) != null) {
                        isProduct = false;
                        break;
                    }
                }
                if (isProduct) {
                    product = fpLayout;
                } else {
                    dependencies.add(session.getExposedLocation(null, fpLayout.getFPID().getLocation()));
                }
            }
        } catch (ProvisioningException ex) {
            throw new CommandExecutionException(commandInvocation.getPmSession(), CliErrors.infoFailed(), ex);
        }
        if (product == null) {
            throw new CommandExecutionException("No feature-pack found");
        }
        commandInvocation.println("");
        StateInfoUtil.printFeaturePack(commandInvocation, session.getExposedLocation(null, product.getFPID().getLocation()));
        try {
            final FPID patchFor = product.getSpec().getPatchFor();
            if (patchFor != null) {
                commandInvocation.println("");
                commandInvocation.println(PATCH_FOR + patchFor);
            }
        } catch (ProvisioningException e) {
            throw new CommandExecutionException(commandInvocation.getPmSession(), CliErrors.infoFailed(), e);
        }
        try {
            if (type != null) {
                commandInvocation.println("");
                switch(type) {
                    case ALL:
                        {
                            if (displayDependencies(commandInvocation, dependencies)) {
                                commandInvocation.println("");
                            }
                            if (displayConfigs(commandInvocation, layout)) {
                                commandInvocation.println("");
                            }
                            if (displayLayers(commandInvocation, layout)) {
                                commandInvocation.println("");
                            }
                            if (displayOptionalPackages(commandInvocation, layout)) {
                                commandInvocation.println("");
                            }
                            displayOptions(commandInvocation, layout);
                            break;
                        }
                    case CONFIGS:
                        {
                            if (!displayConfigs(commandInvocation, layout)) {
                                commandInvocation.println(StateInfoUtil.NO_CONFIGURATIONS);
                            }
                            break;
                        }
                    case DEPENDENCIES:
                        {
                            if (!displayDependencies(commandInvocation, dependencies)) {
                                commandInvocation.println(StateInfoUtil.NO_DEPENDENCIES);
                            }
                            break;
                        }
                    case LAYERS:
                        {
                            if (!displayLayers(commandInvocation, layout)) {
                                commandInvocation.println(StateInfoUtil.NO_LAYERS);
                            }
                            break;
                        }
                    case OPTIONS:
                        {
                            if (!displayOptions(commandInvocation, layout)) {
                                commandInvocation.println(StateInfoUtil.NO_OPTIONS);
                            }
                            break;
                        }
                    case OPTIONAL_PACKAGES:
                        {
                            if (!displayOptionalPackages(commandInvocation, layout)) {
                                commandInvocation.println(StateInfoUtil.NO_OPTIONAL_PACKAGES);
                            }
                            break;
                        }
                    default:
                        {
                            throw new CommandExecutionException(CliErrors.invalidInfoType());
                        }
                }
            }
        } catch (ProvisioningException | IOException ex) {
            throw new CommandExecutionException(commandInvocation.getPmSession(), CliErrors.infoFailed(), ex);
        }
    } finally {
        if (layout != null) {
            layout.close();
        }
    }
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) IOException(java.io.IOException) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) PmSession(org.jboss.galleon.cli.PmSession) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 17 with FeaturePackConfig

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

the class StateTestCase method installWithDependency.

public static void installWithDependency(String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, PRODUCER3, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).addFeatureSpec(FeatureSpec.builder("specA").addPackageDep("p1", true).addParam(FeatureParameterSpec.createId("p1")).build()).addConfig(ConfigModel.builder().setModel("model1").setName("name1").addFeature(new FeatureConfig("specA").setParam("p1", "1")).build(), true).newPackage("p1", false).writeContent("fp1/p1.txt", "fp1 p1").getFeaturePack().newPackage("p2", true).writeContent("fp2/p2.txt", "fp1 p2");
    FeaturePackLocation fp2 = new FeaturePackLocation(universeSpec, PRODUCER4, "1", null, version);
    FeaturePackConfig dep = FeaturePackConfig.builder(fp1).setInheritConfigs(false).setInheritPackages(false).build();
    creator.newFeaturePack(fp2.getFPID()).addDependency(dep).addFeatureSpec(FeatureSpec.builder("specB").addParam(FeatureParameterSpec.createId("p1")).build()).addConfig(ConfigModel.builder().setModel("model1").setName("name1").addFeature(new FeatureConfig("specB").setParam("p1", "1")).addFeature(new FeatureConfig("specA").setParam("p1", "1")).build(), true);
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeatureConfig(org.jboss.galleon.config.FeatureConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 18 with FeaturePackConfig

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

the class StateInfoUtil method buildDependencies.

public static String buildDependencies(List<FeaturePackLocation> dependencies, Map<FPID, FeaturePackConfig> configs) {
    if (!dependencies.isEmpty()) {
        boolean showPatches = configs == null ? false : showPatches(configs.values());
        List<String> headers = new ArrayList<>();
        headers.add(Headers.DEPENDENCY);
        headers.add(Headers.BUILD);
        if (showPatches) {
            headers.add(Headers.PATCHES);
        }
        headers.add(Headers.UPDATE_CHANNEL);
        Table table = new Table(headers);
        for (FeaturePackLocation d : dependencies) {
            List<Cell> line = new ArrayList<>();
            line.add(new Cell(d.getProducerName()));
            line.add(new Cell(d.getBuild()));
            if (showPatches) {
                FeaturePackConfig config = configs.get(d.getFPID());
                if (config != null && config.hasPatches()) {
                    Cell patches = new Cell();
                    for (FPID p : config.getPatches()) {
                        patches.addLine(p.getBuild());
                    }
                    line.add(patches);
                }
            }
            line.add(new Cell(formatChannel(d)));
            table.addCellsLine(line);
        }
        table.sort(Table.SortType.ASCENDANT);
        return table.build();
    }
    return null;
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) Cell(org.jboss.galleon.cli.cmd.Table.Cell) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 19 with FeaturePackConfig

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

the class StateInfoUtil method buildFeaturePacks.

private static String buildFeaturePacks(PmCommandInvocation commandInvocation, Path installation, Collection<FeaturePackConfig> fps) {
    boolean showPatches = showPatches(fps);
    List<String> headers = new ArrayList<>();
    headers.add(Headers.PRODUCT);
    headers.add(Headers.BUILD);
    if (showPatches) {
        headers.add(Headers.PATCHES);
    }
    headers.add(Headers.UPDATE_CHANNEL);
    Table t = new Table(headers);
    for (FeaturePackConfig c : fps) {
        FeaturePackLocation loc = commandInvocation.getPmSession().getExposedLocation(installation, c.getLocation());
        List<Cell> line = new ArrayList<>();
        line.add(new Cell(loc.getProducer().getName()));
        line.add(new Cell(loc.getBuild()));
        if (showPatches) {
            if (c.hasPatches()) {
                Cell patches = new Cell();
                for (FPID p : c.getPatches()) {
                    patches.addLine(p.getBuild());
                }
                line.add(patches);
            }
        }
        line.add(new Cell(formatChannel(loc)));
        t.addCellsLine(line);
    }
    if (!t.isEmpty()) {
        t.sort(Table.SortType.ASCENDANT);
        return t.build();
    } else {
        return null;
    }
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) Cell(org.jboss.galleon.cli.cmd.Table.Cell) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 20 with FeaturePackConfig

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

the class AbstractFPProvisionedCommand method getProvisionedFP.

public FeaturePackConfig getProvisionedFP(PmSession session) throws CommandExecutionException {
    ProducerSpec producer = getProducer(session);
    if (producer == null) {
        return null;
    }
    ProvisioningConfig config = session.getState().getConfig();
    for (FeaturePackConfig dep : config.getFeaturePackDeps()) {
        if (dep.getLocation().getProducer().equals(producer)) {
            return dep;
        }
    }
    for (FeaturePackConfig dep : config.getTransitiveDeps()) {
        if (dep.getLocation().getProducer().equals(producer)) {
            return dep;
        }
    }
    return null;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) 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