Search in sources :

Example 6 with ProvisioningManager

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

the class ProvisioningManagerUniverseManagementTestCase method testAddRemoveUniverseToFreshDir.

@Test
public void testAddRemoveUniverseToFreshDir() throws Exception {
    Assert.assertNull(getProvisioningConfig());
    ProvisioningManager pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.addUniverse("universe1", new UniverseSpec("factory1", "location1"));
    ProvisioningConfig config = getProvisioningConfig();
    assertNotNull(config);
    assertFalse(config.hasDefaultUniverse());
    Map<String, UniverseSpec> universes = config.getUniverseNamedSpecs();
    assertEquals(1, universes.size());
    assertTrue(universes.containsKey("universe1"));
    pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.addUniverse("universe2", new UniverseSpec("factory2", "location2"));
    config = getProvisioningConfig();
    assertNotNull(config);
    assertFalse(config.hasDefaultUniverse());
    universes = config.getUniverseNamedSpecs();
    assertEquals(2, universes.size());
    assertTrue(universes.containsKey("universe1"));
    assertTrue(universes.containsKey("universe2"));
    pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.removeUniverse("universe1");
    config = getProvisioningConfig();
    assertNotNull(config);
    assertFalse(config.hasDefaultUniverse());
    universes = config.getUniverseNamedSpecs();
    assertEquals(1, universes.size());
    assertTrue(universes.containsKey("universe2"));
    pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.removeUniverse("universe2");
    config = getProvisioningConfig();
    assertFalse(config.hasDefaultUniverse());
    assertTrue(config.getUniverseNamedSpecs().isEmpty());
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningManager(org.jboss.galleon.ProvisioningManager) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) Test(org.junit.Test)

Example 7 with ProvisioningManager

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

the class ProvisioningManagerUniverseManagementTestCase method testSetUnsetDefaultUniverseOnFreshDir.

@Test
public void testSetUnsetDefaultUniverseOnFreshDir() throws Exception {
    Assert.assertNull(getProvisioningConfig());
    ProvisioningManager pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.setDefaultUniverse(new UniverseSpec("factory1", "location1"));
    ProvisioningConfig config = getProvisioningConfig();
    assertNotNull(config);
    Map<String, UniverseSpec> universes = config.getUniverseNamedSpecs();
    assertEquals(0, universes.size());
    assertTrue(config.hasDefaultUniverse());
    assertEquals(new UniverseSpec("factory1", "location1"), config.getDefaultUniverse());
    pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.setDefaultUniverse(new UniverseSpec("factory2", "location1"));
    config = getProvisioningConfig();
    assertNotNull(config);
    universes = config.getUniverseNamedSpecs();
    assertEquals(0, universes.size());
    assertTrue(config.hasDefaultUniverse());
    assertEquals(new UniverseSpec("factory2", "location1"), config.getDefaultUniverse());
    pm = ProvisioningManager.builder().setInstallationHome(home).build();
    pm.removeUniverse(null);
    config = getProvisioningConfig();
    assertNotNull(config);
    universes = config.getUniverseNamedSpecs();
    assertEquals(0, universes.size());
    assertFalse(config.hasDefaultUniverse());
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningManager(org.jboss.galleon.ProvisioningManager) UniverseSpec(org.jboss.galleon.universe.UniverseSpec) Test(org.junit.Test)

Example 8 with ProvisioningManager

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

the class UniverseManager method removeUniverse.

public void removeUniverse(Path installation, String name) throws ProvisioningException, IOException {
    ProvisioningManager mgr = getProvisioningManager(installation);
    // Remove default if name is null
    mgr.removeUniverse(name);
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager)

Example 9 with ProvisioningManager

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

the class CheckUpdatesCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation session) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(session.getPmSession());
        Updates updates = getUpdatesTable(mgr, session, includeAll, fp);
        if (updates.plan.isEmpty()) {
            session.println(UP_TO_DATE);
        } else {
            session.println(UPDATES_AVAILABLE);
            session.println(updates.t.build());
        }
    } catch (ProvisioningException ex) {
        throw new CommandExecutionException(session.getPmSession(), CliErrors.checkForUpdatesFailed(), ex);
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Example 10 with ProvisioningManager

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

the class InstalledProducerCompleter method getInstallationLocations.

public static List<FeaturePackLocation> getInstallationLocations(Path installation, PmSession session, boolean transitive, boolean patches) {
    List<FeaturePackLocation> items = new ArrayList<>();
    try {
        PathsUtils.assertInstallationDir(installation);
        ProvisioningManager mgr = session.newProvisioningManager(installation, false);
        try (ProvisioningLayout<FeaturePackLayout> layout = mgr.getLayoutFactory().newConfigLayout(mgr.getProvisioningConfig())) {
            for (FeaturePackLayout fp : layout.getOrderedFeaturePacks()) {
                if (fp.isDirectDep() || (fp.isTransitiveDep() && transitive)) {
                    items.add(fp.getFPID().getLocation());
                }
                if (patches) {
                    List<FeaturePackLayout> appliedPatches = layout.getPatches(fp.getFPID());
                    for (FeaturePackLayout patch : appliedPatches) {
                        items.add(patch.getFPID().getLocation());
                    }
                }
            }
        }
    } catch (Exception ex) {
        CliLogging.completionException(ex);
    }
    return items;
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

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