use of com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException in project elasticsearch-maven-plugin by alexcojocaru.
the class MyArtifactInstaller method installArtifact.
@Override
public void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException {
log.debug("Installing '" + file.getAbsolutePath() + "' in the local maven repo");
InstallRequest request = new InstallRequest();
Artifact defaultArtifact = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), artifact.getVersion(), null, file);
request.addArtifact(defaultArtifact);
log.info(String.format("Installing maven artifact: %s", artifact));
try {
repositorySystem.install(repositorySession, request);
} catch (InstallationException e) {
throw new ArtifactException(e.getMessage(), e);
}
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException in project elasticsearch-maven-plugin by alexcojocaru.
the class MyArtifactResolver method resolveArtifact.
/**
* Resolves an Artifact from the repositories.
*
* @param coordinates The artifact coordinates
* @return The local file resolved/downloaded for the given coordinates
* @throws ArtifactException If the artifact cannot be resolved
*/
@Override
public File resolveArtifact(String coordinates) throws ArtifactException {
ArtifactRequest request = new ArtifactRequest();
Artifact artifact = new DefaultArtifact(coordinates);
request.setArtifact(artifact);
request.setRepositories(remoteRepositories);
log.debug(String.format("Resolving artifact %s from %s", artifact, remoteRepositories));
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repositorySession, request);
} catch (ArtifactResolutionException e) {
throw new ArtifactException(e.getMessage(), e);
}
log.debug(String.format("Resolved artifact %s to %s from %s", artifact, result.getArtifact().getFile(), result.getRepository()));
return result.getArtifact().getFile();
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException in project elasticsearch-maven-plugin by alexcojocaru.
the class ResolveElasticsearchStep method execute.
@Override
public void execute(InstanceConfiguration config) {
File unpackDirectory = null;
try {
File artifact = new ElasticsearchArtifactResolver(config.getClusterConfiguration()).resolve();
unpackDirectory = unpackToElasticsearchDirectory(artifact, config);
setupElasticsearchConf(config);
} catch (ArtifactException | IOException e) {
throw new RuntimeException(e);
} finally {
cleanUp(unpackDirectory, config.getClusterConfiguration());
}
}
Aggregations