Search in sources :

Example 1 with DependencyResolutionServices

use of org.gradle.api.internal.artifacts.DependencyResolutionServices in project gradle by gradle.

the class PluginResolutionServiceResolver method resolvePluginDependencies.

private ClassPath resolvePluginDependencies(final PluginUseMetaData metadata) {
    DependencyResolutionServices resolution = dependencyResolutionServicesFactory.create();
    RepositoryHandler repositories = resolution.getResolveRepositoryHandler();
    final String repoUrl = metadata.implementation.get("repo");
    repositories.maven(new Action<MavenArtifactRepository>() {

        public void execute(MavenArtifactRepository mavenArtifactRepository) {
            mavenArtifactRepository.setUrl(repoUrl);
        }
    });
    Dependency dependency = resolution.getDependencyHandler().create(metadata.implementation.get("gav"));
    ConfigurationContainerInternal configurations = (ConfigurationContainerInternal) resolution.getConfigurationContainer();
    ConfigurationInternal configuration = configurations.detachedConfiguration(dependency);
    try {
        Set<File> files = configuration.getResolvedConfiguration().getFiles(Specs.satisfyAll());
        return new DefaultClassPath(files);
    } catch (ResolveException e) {
        throw new DependencyResolutionException("Failed to resolve all plugin dependencies from " + repoUrl, e.getCause());
    }
}
Also used : ConfigurationContainerInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationContainerInternal) Dependency(org.gradle.api.artifacts.Dependency) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ResolveException(org.gradle.api.artifacts.ResolveException) DependencyResolutionServices(org.gradle.api.internal.artifacts.DependencyResolutionServices) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) RepositoryHandler(org.gradle.api.artifacts.dsl.RepositoryHandler) File(java.io.File) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath)

Aggregations

File (java.io.File)1 Dependency (org.gradle.api.artifacts.Dependency)1 ResolveException (org.gradle.api.artifacts.ResolveException)1 RepositoryHandler (org.gradle.api.artifacts.dsl.RepositoryHandler)1 MavenArtifactRepository (org.gradle.api.artifacts.repositories.MavenArtifactRepository)1 DependencyResolutionServices (org.gradle.api.internal.artifacts.DependencyResolutionServices)1 ConfigurationContainerInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationContainerInternal)1 ConfigurationInternal (org.gradle.api.internal.artifacts.configurations.ConfigurationInternal)1 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)1