Search in sources :

Example 11 with ProvisioningManager

use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.

the class StateTestCase method testTransitiveWithVersion.

@Test
public void testTransitiveWithVersion() throws Exception {
    ProvisioningConfig config = ProvisioningConfig.builder().addFeaturePackDep(locWithTransitive).addTransitiveDep(transitive).build();
    Path p = cli.newDir("version_transitive", false);
    // Provision a config with a transitive with version set.
    ProvisioningManager mgr1 = cli.getSession().newProvisioningManager(p, true);
    mgr1.provision(config);
    cli.execute("state edit " + p.toFile().getAbsolutePath());
    try {
        cli.execute("get-info --type=optional-packages");
        Assert.assertTrue(cli.getOutput(), cli.getOutput().contains("p1"));
        Assert.assertTrue(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
        cli.execute("exclude-package " + transitive.getProducer() + "/p1");
        cli.execute("get-info --type=optional-packages");
        Assert.assertFalse(cli.getOutput(), cli.getOutput().contains("p1"));
        Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
        cli.execute("undo");
        // Check that we still have the transitive dep.
        ProvisioningManager mgr2 = ProvisioningManager.builder().setInstallationHome(p).build();
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().size() == 1);
        Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getExcludedPackages().isEmpty());
    } finally {
        cli.execute("leave-state");
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) Test(org.junit.Test)

Example 12 with ProvisioningManager

use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.

the class GetInfoCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier = new Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer>() {

            public FeatureContainer apply(ProvisioningLayout<FeaturePackLayout> layout) {
                try {
                    return getFeatureContainer(invoc.getPmSession(), layout);
                } catch (CommandExecutionException | ProvisioningException | IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        };
        ProvisioningManager mgr = getManager(invoc.getPmSession());
        StateInfoUtil.displayInfo(invoc, mgr.getInstallationHome(), mgr.getProvisioningConfig(), type, supplier);
    } catch (ProvisioningException | CommandExecutionException ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
    }
}
Also used : Function(java.util.function.Function) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException) ProvisioningLayout(org.jboss.galleon.layout.ProvisioningLayout)

Example 13 with ProvisioningManager

use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.

the class UndoCommand method doRunCommand.

@Override
protected void doRunCommand(PmCommandInvocation session, Map<String, String> options) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(session);
        mgr.undo();
    } catch (ProvisioningException | IOException ex) {
        throw new CommandExecutionException(session.getPmSession(), CliErrors.undoFailed(), ex);
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException)

Example 14 with ProvisioningManager

use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.

the class GetChangesCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(invoc.getPmSession());
        FsDiff diff = mgr.getFsDiff();
        if (diff.isEmpty()) {
            invoc.println("No changes detected");
        } else {
            Path workingDir = Paths.get(invoc.getConfiguration().getAeshContext().getCurrentWorkingDirectory().getAbsolutePath());
            Path installation = mgr.getInstallationHome();
            PathResolver resolver = new PathResolver() {

                @Override
                public String resolve(String relativePath) {
                    Path absPath = Paths.get(installation.toString(), relativePath);
                    return workingDir.relativize(absPath).toString();
                }
            };
            FsDiff.log(diff, new Consumer<String>() {

                @Override
                public void accept(String msg) {
                    invoc.println(msg);
                }
            }, resolver);
        }
    } catch (ProvisioningException ex) {
        throw new CommandExecutionException(ex.getMessage());
    }
}
Also used : Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) FsDiff(org.jboss.galleon.diff.FsDiff) PathResolver(org.jboss.galleon.diff.FsDiff.PathResolver) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Example 15 with ProvisioningManager

use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.

the class InstallCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation session, Map<String, String> options, FeaturePackLocation loc) throws CommandExecutionException {
    try {
        String filePath = (String) getValue(FILE_OPTION_NAME);
        final ProvisioningManager manager = getManager(session);
        String layers = (String) getValue(LAYERS_OPTION_NAME);
        if (filePath != null) {
            Path p = Util.resolvePath(session.getConfiguration().getAeshContext(), filePath);
            loc = session.getPmSession().getLayoutFactory().addLocal(p, true);
        }
        if (layers == null) {
            String configurations = (String) getValue(DEFAULT_CONFIGS_OPTION_NAME);
            if (configurations == null) {
                manager.install(loc, options);
            } else {
                FeaturePackConfig.Builder fpConfig = FeaturePackConfig.builder(loc).setInheritConfigs(false);
                for (ConfigId c : parseConfigurations(configurations)) {
                    fpConfig.includeDefaultConfig(c);
                }
                manager.install(fpConfig.build(), options);
            }
        } else {
            if (!options.containsKey(Constants.OPTIONAL_PACKAGES)) {
                options.put(Constants.OPTIONAL_PACKAGES, Constants.PASSIVE_PLUS);
            }
            String configuration = (String) getValue(CONFIG_OPTION_NAME);
            String model = null;
            String config = null;
            if (configuration != null) {
                List<ConfigId> configs = parseConfigurations(configuration);
                if (configs.size() > 1) {
                    throw new CommandExecutionException(CliErrors.onlyOneConfigurationWithlayers());
                }
                if (!configs.isEmpty()) {
                    ConfigId id = configs.get(0);
                    model = id.getModel();
                    config = id.getName();
                }
            }
            manager.provision(new LayersConfigBuilder(manager, pmSession, layers.split(",+"), model, config, loc).build(), options);
        }
        session.println("Feature pack installed.");
        if (manager.isRecordState() && !loc.isMavenCoordinates()) {
            if (!loc.hasBuild() || loc.getChannelName() == null) {
                loc = manager.getProvisioningConfig().getFeaturePackDep(loc.getProducer()).getLocation();
            }
            StateInfoUtil.printFeaturePack(session, session.getPmSession().getExposedLocation(manager.getInstallationHome(), loc));
        }
    } catch (ProvisioningException | IOException ex) {
        throw new CommandExecutionException(session.getPmSession(), CliErrors.installFailed(), ex);
    }
}
Also used : Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ConfigId(org.jboss.galleon.config.ConfigId) IOException(java.io.IOException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

ProvisioningManager (org.jboss.galleon.ProvisioningManager)25 ProvisioningException (org.jboss.galleon.ProvisioningException)11 Path (java.nio.file.Path)8 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)7 IOException (java.io.IOException)6 Test (org.junit.Test)6 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)4 MvnMessageWriter (org.jboss.galleon.maven.plugin.util.MvnMessageWriter)3 BufferedReader (java.io.BufferedReader)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 CommandException (org.aesh.command.CommandException)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)2 ConfigModel (org.jboss.galleon.config.ConfigModel)2 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)2 MavenArtifactRepositoryManager (org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager)2 RepositoryArtifactResolver (org.jboss.galleon.repo.RepositoryArtifactResolver)2 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)2