private Artifact resolveArtifact ( Artifact artifact ) throws MojoExecutionException { final ArtifactResolutionRequest artifactResolutionRequest = new ArtifactResolutionRequest ( ) ; artifactResolutionRequest . setArtifact ( artifact ) ; if ( remoteArtifactRepositories != null && ! remoteArtifactRepositories . isEmpty ( ) ) { artifactResolutionRequest . setRemoteRepositories ( remoteArtifactRepositories ) ; } final ArtifactResolutionResult resolutionResult = this . artifactResolver . resolve ( artifactResolutionRequest ) ; log . debug ( "Resolving : " + artifact ) ; if ( resolutionResult . getArtifacts ( ) . size ( ) == 0 ) { throw new MojoExecutionException ( "Could not resolve artifact " + artifact + ". Please install it with \"mvn install:install-file ...\" or deploy it to a repository " + "with \"mvn deploy:deploy-file ...\"" ) ; } if ( resolutionResult . getArtifacts ( ) . size ( ) > 1 ) { log . debug ( "Resolved artifacts : " + resolutionResult . getArtifacts ( ) ) ; throw new MojoExecutionException ( "Could not resolve artifact " + artifact + " to single target. Found the following possible options : " + resolutionResult . getArtifacts ( ) ) ; } final Artifact resolvedArtifact = resolutionResult . getArtifacts ( ) . iterator ( ) . next ( ) ; log . debug ( "Resolved : " + resolvedArtifact ) ; return resolvedArtifact ; }
Resolves an artifact to a particular repository .