Example usage for org.apache.maven.artifact.resolver ArtifactResolutionResult toString

List of usage examples for org.apache.maven.artifact.resolver ArtifactResolutionResult toString

Introduction

In this page you can find the example usage for org.apache.maven.artifact.resolver ArtifactResolutionResult toString.

Prototype

public String toString() 

Source Link

Usage

From source file:com.comoyo.maven.plugins.emjar.EmJarMojo.java

License:Apache License

/**
 * Get artifact containing the EmJar class loader itself.
 *///from   w  w w.  ja  v  a  2s.  com
private Artifact getEmJarArtifact() throws MojoExecutionException {
    final Artifact artifact = repositorySystem.createArtifact(pluginDescriptor.getGroupId(), "emjar",
            pluginDescriptor.getVersion(), "jar");

    getLog().info("Using emjar " + artifact);
    ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact(artifact)
            .setRemoteRepositories(remoteRepositories);
    ArtifactResolutionResult result = repositorySystem.resolve(request);
    if (!result.isSuccess()) {
        throw new MojoExecutionException(
                "Unable to resolve dependency on EmJar loader artifact, sorry: " + result.toString());
    }

    Set<Artifact> artifacts = result.getArtifacts();
    if (artifacts.size() != 1) {
        throw new MojoExecutionException("Unexpected number of artifacts returned when resolving EmJar loader ("
                + artifacts.size() + ")");
    }
    return artifacts.iterator().next();
}