use of org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager in project wildfly-maven-plugin by wildfly.
the class StartMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Log log = getLog();
if (skip) {
log.debug("Skipping server start");
return;
}
MavenRepositoriesEnricher.enrich(mavenSession, project, repositories);
mavenRepoManager = new MavenArtifactRepositoryManager(repoSystem, session, repositories);
// Validate the environment
final Path jbossHome = provisionIfRequired(targetDir.toPath().resolve(provisioningDir));
if (!ServerHelper.isValidHomeDirectory(jbossHome)) {
throw new MojoExecutionException(String.format("JBOSS_HOME '%s' is not a valid directory.", jbossHome));
}
// Determine how stdout should be consumed
try {
final StandardOutput out = StandardOutput.parse(stdout, true);
// the maven process may have been finished
try (ModelControllerClient client = createClient()) {
if (ServerHelper.isStandaloneRunning(client) || ServerHelper.isDomainRunning(client)) {
throw new MojoExecutionException(String.format("%s server is already running?", serverType));
}
final CommandBuilder commandBuilder = createCommandBuilder(jbossHome);
log.info(String.format("%s server is starting up.", serverType));
final Launcher launcher = Launcher.of(commandBuilder).setRedirectErrorStream(true);
if (env != null) {
launcher.addEnvironmentVariables(env);
}
out.getRedirect().ifPresent(launcher::redirectOutput);
final Process process = launcher.launch();
// Note that if this thread is started and no shutdown goal is executed this stop the stdout and stderr
// from being logged any longer. The user was warned in the documentation.
out.startConsumer(process);
if (serverType == ServerType.DOMAIN) {
ServerHelper.waitForDomain(process, DomainClient.Factory.create(client), startupTimeout);
} else {
ServerHelper.waitForStandalone(process, client, startupTimeout);
}
if (!process.isAlive()) {
throw new MojoExecutionException("The process has been terminated before the start goal has completed.");
}
}
} catch (MojoExecutionException e) {
throw e;
} catch (Exception e) {
throw new MojoExecutionException("The server failed to start", e);
}
}
use of org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager 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.maven.plugin.util.MavenArtifactRepositoryManager in project galleon by wildfly.
the class CreateProducerMojo method createProducer.
private void createProducer() throws MavenUniverseException, MojoExecutionException {
final MavenArtifact producerArtifact = new MavenArtifact().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
final MavenProducerInstaller installer = new MavenProducerInstaller(name, SimplisticMavenRepoManager.getInstance(Paths.get(project.getBuild().getDirectory()).resolve("local-repo"), new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories)), producerArtifact, featurePackGroupId, featurePackArtifactId);
for (String frequency : frequencies) {
installer.addFrequency(frequency);
}
final Set<String> names = new HashSet<>(channels.size());
for (ChannelDescription channel : channels) {
if (!names.add(channel.name)) {
throw new MojoExecutionException("Duplicate channel " + channel.name);
}
try {
installer.addChannel(channel.name, channel.versionRange);
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to add channel " + channel.name, e);
}
}
try {
installer.install();
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to create producer", e);
}
projectHelper.attachArtifact(project, "jar", producerArtifact.getPath().toFile());
}
use of org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager in project galleon by wildfly.
the class CreateProducersMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping the create-producers goal.");
return;
}
final MavenArtifact artifact = new MavenArtifact().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
final MavenProducers installer = MavenProducers.getInstance(SimplisticMavenRepoManager.getInstance(Paths.get(project.getBuild().getDirectory()).resolve("local-repo"), new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories)), artifact);
for (ProducerDescription producer : producers) {
installer.addProducer(producer);
}
try {
installer.install();
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to create producers artifact", e);
}
projectHelper.attachArtifact(project, "jar", artifact.getPath().toFile());
}
use of org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager in project galleon by wildfly.
the class CreateUniverseMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping the create-universe goal.");
return;
}
final MavenArtifact universeArtifact = new MavenArtifact().setGroupId(groupId).setArtifactId(artifactId).setVersion(version);
final MavenUniverseInstaller installer = new MavenUniverseInstaller(SimplisticMavenRepoManager.getInstance(Paths.get(project.getBuild().getDirectory()).resolve("local-repo"), new MavenArtifactRepositoryManager(repoSystem, repoSession, repositories)), universeArtifact);
final Set<String> names = new HashSet<>(producers.size());
for (ProducerSpec producer : producers) {
if (!names.add(producer.name)) {
throw new MojoExecutionException("Duplicate producer " + producer.name);
}
try {
installer.addProducer(producer.name, producer.groupId, producer.artifactId, producer.versionRange);
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to add producer " + producer.name, e);
}
}
try {
installer.install();
} catch (MavenUniverseException e) {
throw new MojoExecutionException("Failed to create universe", e);
}
projectHelper.attachArtifact(project, "jar", universeArtifact.getPath().toFile());
}
Aggregations