public static Optional < File > resolvePluginDependency ( Dependency d , List < RemoteRepository > pluginRepos , ArtifactResolver resolver , RepositorySystemSession repoSystemSession ) { Artifact a = new DefaultArtifact ( d . getGroupId ( ) , d . getArtifactId ( ) , d . getClassifier ( ) , d . getType ( ) , d . getVersion ( ) ) ; ArtifactRequest artifactRequest = new ArtifactRequest ( ) ; artifactRequest . setArtifact ( a ) ; artifactRequest . setRepositories ( pluginRepos ) ; try { ArtifactResult artifactResult = resolver . resolveArtifact ( repoSystemSession , artifactRequest ) ; if ( artifactResult . getArtifact ( ) != null ) { return Optional . fromNullable ( artifactResult . getArtifact ( ) . getFile ( ) ) ; } return Optional . absent ( ) ; } catch ( ArtifactResolutionException e ) { return Optional . absent ( ) ; } }
Uses the aether to resolve a plugin dependency and returns the file for further processing .