use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class ProvisionFileStateMojo method doProvision.
private void doProvision() throws MojoExecutionException, ProvisioningException {
final RepositoryArtifactResolver artifactResolver = offline ? new MavenArtifactRepositoryManager(repoSystem, repoSession) : new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories);
final Path home = installDir.toPath();
if (!recordState) {
IoUtils.recursiveDelete(home);
}
try (ProvisioningManager pm = ProvisioningManager.builder().addArtifactResolver(artifactResolver).setInstallationHome(home).setMessageWriter(new MvnMessageWriter(getLog())).setLogTime(logTime).setRecordState(recordState).build()) {
pm.provision(provisioningFile.toPath(), pluginOptions);
}
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class FeaturePackInstaller method install.
public void install() {
try (ProvisioningManager manager = ProvisioningManager.builder().addArtifactResolver(LegacyGalleon1RepositoryManager.newInstance(repoHome)).setInstallationHome(installationDir).setRecordState(recordState).build()) {
System.setProperty("org.wildfly.logging.skipLogManagerCheck", "true");
ConfigModel config = null;
if (customConfig != null && Files.exists(customConfig)) {
try (BufferedReader reader = Files.newBufferedReader(customConfig)) {
config = ConfigXmlParser.getInstance().parse(reader);
} catch (XMLStreamException | IOException ex) {
throw new IllegalArgumentException("Couldn't load the customization configuration " + customConfig, ex);
}
}
if (localPath != null) {
fpl = manager.getLayoutFactory().addLocal(localPath, false);
}
FeaturePackConfig.Builder fpConfigBuilder = FeaturePackConfig.builder(fpl).setInheritPackages(inheritPackages).setInheritConfigs(inheritConfigs);
if (includedConfigs != null && !includedConfigs.isEmpty()) {
for (ConfigurationId configId : includedConfigs) {
if (configId.isModelOnly()) {
fpConfigBuilder.includeConfigModel(configId.getId().getModel());
} else {
fpConfigBuilder.includeDefaultConfig(configId.getId());
}
}
}
if (config != null) {
fpConfigBuilder.addConfig(config);
}
if (includedPackages != null && !includedPackages.isEmpty()) {
for (String includedPackage : includedPackages) {
fpConfigBuilder.includePackage(includedPackage);
}
}
if (excludedPackages != null && !excludedPackages.isEmpty()) {
for (String excludedPackage : excludedPackages) {
fpConfigBuilder.excludePackage(excludedPackage);
}
}
manager.install(fpConfigBuilder.build(), pluginOptions);
} catch (ProvisioningException ex) {
throw new IllegalArgumentException("Couldn't install feature-pack " + fpl, ex);
} finally {
System.clearProperty("org.wildfly.logging.skipLogManagerCheck");
}
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class StateTestCase method testTransitivePackages.
@Test
public void testTransitivePackages() throws Exception {
cli.execute("state new");
try {
cli.execute("add-dependency " + locWithTransitive + " --default-configs-inherit");
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));
Path p1 = cli.newDir("exported-transitive1", false);
cli.execute("provision --dir=" + p1.toFile().getAbsolutePath());
ProvisioningManager mgr1 = ProvisioningManager.builder().setInstallationHome(p1).build();
Assert.assertTrue(mgr1.getProvisioningConfig().getTransitiveDeps().size() == 1);
Assert.assertTrue(mgr1.getProvisioningConfig().getTransitiveDeps().iterator().next().getExcludedPackages().contains("p1"));
cli.execute("undo");
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("remove-excluded-package p1");
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("undo");
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("remove-excluded-package p1");
Path p2 = cli.newDir("exported-transitive2", false);
cli.execute("provision --dir=" + p2.toFile().getAbsolutePath());
ProvisioningManager mgr2 = ProvisioningManager.builder().setInstallationHome(p2).build();
Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().isEmpty());
boolean failed = false;
try {
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
} catch (Exception ex) {
// expected.
failed = true;
}
if (!failed) {
throw new Exception("Package p2 shouldn't be present");
}
cli.execute("include-package " + transitive.getProducer() + "/p2");
Path p3 = cli.newDir("exported-transitive3", false);
cli.execute("provision --dir=" + p3.toFile().getAbsolutePath());
ProvisioningManager mgr3 = ProvisioningManager.builder().setInstallationHome(p3).build();
Assert.assertTrue(mgr3.getProvisioningConfig().getTransitiveDeps().size() == 1);
Assert.assertTrue(mgr3.getProvisioningConfig().getTransitiveDeps().iterator().next().getIncludedPackages().contains("p2"));
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
cli.execute("undo");
failed = false;
try {
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
} catch (Exception ex) {
// expected.
failed = true;
}
if (!failed) {
throw new Exception("Package p2 shouldn't be present");
}
cli.execute("include-package " + transitive.getProducer() + "/p2");
cli.execute("remove-included-package p2");
failed = false;
try {
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
} catch (Exception ex) {
// expected.
failed = true;
}
if (!failed) {
throw new Exception("Package p2 shouldn't be present");
}
cli.execute("undo");
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
cli.execute("remove-included-package p2");
Path p4 = cli.newDir("exported-transitive4", false);
cli.execute("provision --dir=" + p4.toFile().getAbsolutePath());
ProvisioningManager mgr4 = ProvisioningManager.builder().setInstallationHome(p4).build();
Assert.assertTrue(mgr4.getProvisioningConfig().getTransitiveDeps().isEmpty());
} finally {
cli.execute("leave-state");
}
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class StateTestCase method testTransitiveWithExistingPackages.
@Test
public void testTransitiveWithExistingPackages() throws Exception {
FeaturePackConfig transitiveConfig = FeaturePackConfig.transitiveBuilder(transitive).excludePackage("p1").includePackage("p2").build();
FeaturePackConfig topLevelConfig = FeaturePackConfig.builder(locWithTransitive).setInheritPackages(false).build();
ProvisioningConfig config = ProvisioningConfig.builder().addFeaturePackDep(topLevelConfig).addFeaturePackDep(transitiveConfig).build();
Path p = cli.newDir("transitive_packages", false);
// Provision a config with a transitive with already excluded package
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.assertFalse(cli.getOutput(), cli.getOutput().contains("p1"));
Assert.assertFalse(cli.getOutput(), cli.getOutput().contains(PRODUCER3));
cli.execute("remove-excluded-package p1");
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("undo");
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
cli.execute("remove-included-package p2");
boolean failed = false;
try {
cli.execute("ls /packages/" + transitive.getProducer() + "/p2");
} catch (Exception ex) {
// expected.
failed = true;
}
if (!failed) {
throw new Exception("Package p2 shouldn't be present");
}
cli.execute("undo");
Path p2 = cli.newDir("transitive_packages_reprovisioned", false);
cli.execute("provision --dir=" + p2.toFile().getAbsolutePath());
// Check that we still have the transitive dep and its original content.
ProvisioningManager mgr2 = ProvisioningManager.builder().setInstallationHome(p2).build();
Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().size() == 1);
Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getExcludedPackages().contains("p1"));
Assert.assertTrue(mgr2.getProvisioningConfig().getTransitiveDeps().iterator().next().getIncludedPackages().contains("p2"));
} finally {
cli.execute("leave-state");
}
}
use of org.jboss.galleon.ProvisioningManager in project galleon by wildfly.
the class InstallFpUsingDefaultUniverseTestCase method getPm.
@Override
protected ProvisioningManager getPm() throws ProvisioningException {
ProvisioningManager pm = super.getPm();
pm.setDefaultUniverse(LegacyGalleon1Universe.getUniverseSpec());
return pm;
}
Aggregations