Search in sources :

Example 56 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class AbstractPluginsCommand method getDynamicOptions.

@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
    List<DynamicOption> options = new ArrayList<>();
    FeaturePackLocation fpl = pmSession.getResolvedLocation(getInstallationDirectory(pmSession.getAeshContext()), getId(pmSession));
    Set<ProvisioningOption> pluginOptions = getPluginOptions(fpl);
    for (ProvisioningOption opt : pluginOptions) {
        DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
        options.add(dynOption);
    }
    return options;
}
Also used : ArrayList(java.util.ArrayList) ProvisioningOption(org.jboss.galleon.ProvisioningOption) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 57 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class AbstractFPProvisioningCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc, State session) throws IOException, ProvisioningException, CommandExecutionException {
    FeaturePackLocation fpl = invoc.getPmSession().getResolvedLocation(null, this.fpl);
    runCommand(invoc, session, fpl);
}
Also used : FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 58 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation 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 59 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class ProvisionedConfigXmlParser30 method parseSource.

private static FeaturePackLocation parseSource(XMLExtendedStreamReader reader) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    FeaturePackLocation fps = null;
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case LOCATION:
                try {
                    fps = FeaturePackLocation.fromString(reader.getAttributeValue(i));
                } catch (IllegalArgumentException e) {
                    throw new XMLStreamException("Failed to parse feature-pack location", e);
                }
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    if (fps == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
    }
    return fps;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 60 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class ProvisioningXmlParser30 method doReadFeaturePackDep.

private static void doReadFeaturePackDep(XMLExtendedStreamReader reader, FeaturePackDepsConfigBuilder<?> builder, boolean transitive) throws XMLStreamException {
    FeaturePackLocation location = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
        switch(attribute) {
            case LOCATION:
                location = parseFpl(reader, i);
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    if (location == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
    }
    location = resolveUniverse(builder, location);
    String origin = null;
    final FeaturePackConfig.Builder depBuilder = transitive ? FeaturePackConfig.transitiveBuilder(location) : FeaturePackConfig.builder(location);
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                {
                    try {
                        builder.addFeaturePackDep(origin, depBuilder.build());
                    } catch (ProvisioningDescriptionException e) {
                        final StringBuilder buf = new StringBuilder();
                        buf.append("Failed to add ").append(location).append(" as a ");
                        if (transitive) {
                            buf.append("transitive ");
                        }
                        buf.append(" feature-pack dependency");
                        throw new XMLStreamException(ParsingUtils.error(buf.toString(), reader.getLocation()), e);
                    }
                    return;
                }
            case XMLStreamConstants.START_ELEMENT:
                {
                    final Element element = Element.of(reader.getName().getLocalPart());
                    switch(element) {
                        case PACKAGES:
                            try {
                                FeaturePackPackagesConfigParser10.readPackages(reader, depBuilder);
                            } catch (ProvisioningDescriptionException e) {
                                throw new XMLStreamException("Failed to parse " + Element.PACKAGES.getLocalName() + ": " + e.getLocalizedMessage(), reader.getLocation(), e);
                            }
                            break;
                        case ORIGIN:
                            origin = reader.getElementText();
                            break;
                        case DEFAULT_CONFIGS:
                            ProvisioningXmlParser30.parseDefaultConfigs(reader, depBuilder);
                            break;
                        case CONFIG:
                            final ConfigModel.Builder config = ConfigModel.builder();
                            ConfigXml.readConfig(reader, config);
                            try {
                                depBuilder.addConfig(config.build());
                            } catch (ProvisioningDescriptionException e) {
                                throw new XMLStreamException("Failed to parse config element", reader.getLocation(), e);
                            }
                            break;
                        case PATCHES:
                            readPatches(reader, depBuilder, builder);
                            break;
                        default:
                            throw ParsingUtils.unexpectedContent(reader);
                    }
                    break;
                }
            default:
                {
                    throw ParsingUtils.unexpectedContent(reader);
                }
        }
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) FeaturePackDepsConfigBuilder(org.jboss.galleon.config.FeaturePackDepsConfigBuilder) ConfigCustomizationsBuilder(org.jboss.galleon.config.ConfigCustomizationsBuilder) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)111 Test (org.junit.Test)46 Path (java.nio.file.Path)23 ProvisioningException (org.jboss.galleon.ProvisioningException)18 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)18 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)16 ArrayList (java.util.ArrayList)13 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)13 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)12 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)9 XMLStreamException (javax.xml.stream.XMLStreamException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)8 IOException (java.io.IOException)7 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)7 HashMap (java.util.HashMap)6 CommandException (org.aesh.command.CommandException)6 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)6 FeatureConfig (org.jboss.galleon.config.FeatureConfig)6 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)6 Set (java.util.Set)5