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");
}
}
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);
}
}
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);
}
}
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());
}
}
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);
}
}
Aggregations