Search in sources :

Example 21 with ProvisioningManager

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);
    }
}
Also used : Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) RepositoryArtifactResolver(org.jboss.galleon.repo.RepositoryArtifactResolver) MavenArtifactRepositoryManager(org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager) MvnMessageWriter(org.jboss.galleon.maven.plugin.util.MvnMessageWriter)

Example 22 with ProvisioningManager

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");
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) ConfigModel(org.jboss.galleon.config.ConfigModel) XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningException(org.jboss.galleon.ProvisioningException) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 23 with ProvisioningManager

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");
    }
}
Also used : Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) CommandException(org.aesh.command.CommandException) ProvisioningException(org.jboss.galleon.ProvisioningException) Test(org.junit.Test)

Example 24 with ProvisioningManager

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");
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Path(java.nio.file.Path) ProvisioningManager(org.jboss.galleon.ProvisioningManager) CommandException(org.aesh.command.CommandException) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig) Test(org.junit.Test)

Example 25 with ProvisioningManager

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;
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager)

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