Search in sources :

Example 1 with ArtifactException

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);
    }
}
Also used : ArtifactException(com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException) InstallRequest(org.eclipse.aether.installation.InstallRequest) InstallationException(org.eclipse.aether.installation.InstallationException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 2 with ArtifactException

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();
}
Also used : ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) ArtifactException(com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 3 with ArtifactException

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());
    }
}
Also used : ElasticsearchArtifactResolver(com.github.alexcojocaru.mojo.elasticsearch.v2.step.resolveartifact.ElasticsearchArtifactResolver) ArtifactException(com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException) IOException(java.io.IOException) File(java.io.File)

Aggregations

ArtifactException (com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ArtifactException)3 Artifact (org.eclipse.aether.artifact.Artifact)2 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)2 ElasticsearchArtifactResolver (com.github.alexcojocaru.mojo.elasticsearch.v2.step.resolveartifact.ElasticsearchArtifactResolver)1 File (java.io.File)1 IOException (java.io.IOException)1 InstallRequest (org.eclipse.aether.installation.InstallRequest)1 InstallationException (org.eclipse.aether.installation.InstallationException)1 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)1