Search in sources :

Example 1 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project wildfly-maven-plugin by wildfly.

the class AbstractProvisionServerMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (skip) {
        getLog().debug(String.format("Skipping " + getGoal() + " of %s:%s", project.getGroupId(), project.getArtifactId()));
        return;
    }
    Path targetPath = Paths.get(project.getBuild().getDirectory());
    wildflyDir = targetPath.resolve(provisioningDir).normalize();
    if (!overwriteProvisionedServer && Files.exists(wildflyDir)) {
        getLog().info(String.format("A server already exists in " + wildflyDir + ", skipping " + getGoal() + " of %s:%s", project.getGroupId(), project.getArtifactId()));
        return;
    }
    enrichRepositories();
    artifactResolver = offlineProvisioning ? new MavenArtifactRepositoryManager(repoSystem, repoSession) : new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories);
    if (!Paths.get(provisioningDir).isAbsolute() && (targetPath.equals(wildflyDir) || !wildflyDir.startsWith(targetPath))) {
        throw new MojoExecutionException("provisioning-dir " + provisioningDir + " must be an absolute path or a child directory relative to the project build directory.");
    }
    IoUtils.recursiveDelete(wildflyDir);
    try {
        try {
            provisionServer(wildflyDir);
        } catch (ProvisioningException | IOException | XMLStreamException ex) {
            throw new MojoExecutionException("Provisioning failed", ex);
        }
        serverProvisioned(wildflyDir);
    } finally {
        // Although cli and embedded are run in their own classloader,
        // the module.path system property has been set and needs to be cleared for
        // in same JVM next execution.
        System.clearProperty("module.path");
    }
}
Also used : Path(java.nio.file.Path) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) XMLStreamException(javax.xml.stream.XMLStreamException) MavenArtifactRepositoryManager(org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager) ProvisioningException(org.jboss.galleon.ProvisioningException) IOException(java.io.IOException)

Example 2 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project wildfly-maven-plugin by wildfly.

the class RunMojo method provisionIfRequired.

private Path provisionIfRequired(final Path installDir) throws MojoFailureException {
    if (jbossHome != null) {
        // we do not need to download WildFly
        return Paths.get(jbossHome);
    }
    try {
        if (!Files.exists(installDir)) {
            getLog().info("Provisioning default WildFly server in " + installDir);
            GalleonUtils.provision(installDir, version, mavenRepoManager);
        }
        return installDir;
    } catch (ProvisioningException ex) {
        throw new MojoFailureException(ex.getLocalizedMessage(), ex);
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 3 with ProvisioningException

use of org.jboss.galleon.ProvisioningException in project wildfly-maven-plugin by wildfly.

the class StartMojo method provisionIfRequired.

private Path provisionIfRequired(final Path installDir) throws MojoFailureException {
    if (jbossHome != null) {
        // we do not need to download WildFly
        return Paths.get(jbossHome);
    }
    try {
        if (!Files.exists(installDir)) {
            getLog().info("Provisioning default WildFly server in " + installDir);
            GalleonUtils.provision(installDir, version, mavenRepoManager);
        }
        return installDir;
    } catch (ProvisioningException ex) {
        throw new MojoFailureException(ex.getLocalizedMessage(), ex);
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 4 with ProvisioningException

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

the class ProvisionStateMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (skip) {
        getLog().info("Skipping the provision goal.");
        return;
    }
    if (featurePacks.isEmpty()) {
        throw new MojoExecutionException("No feature-packs to install.");
    }
    final String originalMavenRepoLocal = System.getProperty(MAVEN_REPO_LOCAL);
    System.setProperty(MAVEN_REPO_LOCAL, session.getSettings().getLocalRepository());
    try {
        doProvision();
    } catch (ProvisioningException e) {
        throw new MojoExecutionException("Provisioning failed", e);
    } finally {
        if (originalMavenRepoLocal == null) {
            System.clearProperty(MAVEN_REPO_LOCAL);
        } else {
            System.setProperty(MAVEN_REPO_LOCAL, originalMavenRepoLocal);
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 5 with ProvisioningException

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

the class ChangesTestCase method overwrite.

protected void overwrite(Path home, ProvisionedConfig config) throws ProvisioningException {
    Path p = home.resolve(Constants.CONFIGS);
    if (config.getModel() != null) {
        p = p.resolve(config.getModel());
    }
    p = p.resolve(config.getName());
    try {
        Files.createDirectories(p.getParent());
    } catch (IOException e1) {
        throw new ProvisioningException(Errors.mkdirs(p.getParent()), e1);
    }
    try (BufferedWriter writer = Files.newBufferedWriter(p)) {
        ProvisionedConfigXmlWriter.getInstance().write(config, writer);
    } catch (IOException | XMLStreamException e) {
        throw new ProvisioningException("Failed to store " + new ConfigId(config.getModel(), config.getName()) + " in a string", e);
    }
}
Also used : Path(java.nio.file.Path) XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningException(org.jboss.galleon.ProvisioningException) IOException(java.io.IOException) ConfigId(org.jboss.galleon.config.ConfigId) BufferedWriter(java.io.BufferedWriter)

Aggregations

ProvisioningException (org.jboss.galleon.ProvisioningException)101 IOException (java.io.IOException)45 Path (java.nio.file.Path)35 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)24 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)15 XMLStreamException (javax.xml.stream.XMLStreamException)13 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)10 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)10 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)9 ProvisioningManager (org.jboss.galleon.ProvisioningManager)9 BufferedReader (java.io.BufferedReader)8 HashMap (java.util.HashMap)8 ConfigId (org.jboss.galleon.config.ConfigId)8 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)8 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)7 BufferedWriter (java.io.BufferedWriter)6