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