Search in sources :

Example 1 with AndDependencyFilter

use of org.eclipse.aether.util.filter.AndDependencyFilter in project grails-maven by grails.

the class AbstractGrailsMojo method resolveArtifacts.

protected List<File> resolveArtifacts(MavenProject mavenProject, Collection<String> scopes, DependencyFilter filter) throws MojoExecutionException {
    try {
        DefaultDependencyResolutionRequest request = new DefaultDependencyResolutionRequest(mavenProject, repoSession);
        if (filter != null) {
            request.setResolutionFilter(new AndDependencyFilter(new ScopeDependencyFilter(scopes, Collections.<String>emptyList()), filter));
        } else {
            request.setResolutionFilter(new ScopeDependencyFilter(scopes, Collections.<String>emptyList()));
        }
        DependencyResolutionResult result = projectDependenciesResolver.resolve(request);
        List<org.eclipse.aether.graph.Dependency> dependencies = result.getDependencies();
        final List<File> files = new ArrayList<File>();
        for (org.eclipse.aether.graph.Dependency d : dependencies) {
            org.eclipse.aether.artifact.Artifact artifact = d.getArtifact();
            File file = artifact.getFile();
            if (file != null) {
                String name = file.getName();
                if (!name.contains("xml-apis") && !name.contains("commons-logging"))
                    files.add(file);
            }
        }
        return files;
    } catch (DependencyResolutionException e) {
        throw new MojoExecutionException("Dependency resolution failure: " + e.getMessage(), e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Dependency(org.apache.maven.model.Dependency) AndDependencyFilter(org.eclipse.aether.util.filter.AndDependencyFilter) ScopeDependencyFilter(org.eclipse.aether.util.filter.ScopeDependencyFilter) File(java.io.File)

Aggregations

File (java.io.File)1 Dependency (org.apache.maven.model.Dependency)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 AndDependencyFilter (org.eclipse.aether.util.filter.AndDependencyFilter)1 ScopeDependencyFilter (org.eclipse.aether.util.filter.ScopeDependencyFilter)1