Search in sources :

Example 1 with ResolveException

use of org.gradle.api.artifacts.ResolveException in project gradle by gradle.

the class DependencyResolvingClasspath method getBuildDependencies.

@Override
public TaskDependency getBuildDependencies() {
    ensureResolved(false);
    final List<Object> taskDependencies = new ArrayList<Object>();
    final List<Throwable> failures = new ArrayList<Throwable>();
    resolveResult.artifactsResults.getArtifacts().collectBuildDependencies(new BuildDependenciesVisitor() {

        @Override
        public void visitDependency(Object dep) {
            taskDependencies.add(dep);
        }

        @Override
        public void visitFailure(Throwable failure) {
            failures.add(failure);
        }
    });
    if (!failures.isEmpty()) {
        throw new ResolveException(getDisplayName(), failures);
    }
    return TaskDependencies.of(taskDependencies);
}
Also used : LibraryResolveException(org.gradle.language.base.internal.resolve.LibraryResolveException) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ResolveException(org.gradle.api.artifacts.ResolveException) ArrayList(java.util.ArrayList) BuildDependenciesVisitor(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.BuildDependenciesVisitor)

Example 2 with ResolveException

use of org.gradle.api.artifacts.ResolveException in project gradle by gradle.

the class ErrorHandlingConfigurationResolver method resolveGraph.

@Override
public void resolveGraph(ConfigurationInternal configuration, ResolverResults results) throws ResolveException {
    try {
        delegate.resolveGraph(configuration, results);
    } catch (Exception e) {
        results.failed(wrapException(e, configuration));
        BrokenResolvedConfiguration broken = new BrokenResolvedConfiguration(e, configuration);
        results.artifactsResolved(broken, broken);
        return;
    }
    ResolutionResult wrappedResult = new ErrorHandlingResolutionResult(results.getResolutionResult(), configuration);
    results.graphResolved(wrappedResult, results.getResolvedLocalComponents(), results.getVisitedArtifacts());
}
Also used : ResolutionResult(org.gradle.api.artifacts.result.ResolutionResult) ResolveException(org.gradle.api.artifacts.ResolveException)

Example 3 with ResolveException

use of org.gradle.api.artifacts.ResolveException 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)

Example 4 with ResolveException

use of org.gradle.api.artifacts.ResolveException in project gradle by gradle.

the class DownloadingScalaToolChain method select.

@Override
public ToolProvider select(ScalaPlatform targetPlatform) {
    try {
        Configuration scalaClasspath = resolveDependency("org.scala-lang:scala-compiler:" + targetPlatform.getScalaVersion());
        Configuration zincClasspath = resolveDependency("com.typesafe.zinc:zinc:" + DefaultScalaToolProvider.DEFAULT_ZINC_VERSION);
        Set<File> resolvedScalaClasspath = scalaClasspath.resolve();
        Set<File> resolvedZincClasspath = zincClasspath.resolve();
        return new DefaultScalaToolProvider(gradleUserHomeDir, daemonWorkingDir, workerDaemonFactory, fileResolver, resolvedScalaClasspath, resolvedZincClasspath);
    } catch (ResolveException resolveException) {
        return new NotFoundScalaToolProvider(resolveException);
    }
}
Also used : ResolveException(org.gradle.api.artifacts.ResolveException) Configuration(org.gradle.api.artifacts.Configuration) File(java.io.File)

Example 5 with ResolveException

use of org.gradle.api.artifacts.ResolveException in project gradle by gradle.

the class ErrorHandlingConfigurationResolver method resolveArtifacts.

@Override
public void resolveArtifacts(ConfigurationInternal configuration, ResolverResults results) throws ResolveException {
    try {
        delegate.resolveArtifacts(configuration, results);
    } catch (Exception e) {
        BrokenResolvedConfiguration broken = new BrokenResolvedConfiguration(e, configuration);
        results.artifactsResolved(broken, broken);
        return;
    }
    ResolvedConfiguration wrappedConfiguration = new ErrorHandlingResolvedConfiguration(results.getResolvedConfiguration(), configuration);
    results.artifactsResolved(wrappedConfiguration, results.getVisitedArtifacts());
}
Also used : ResolvedConfiguration(org.gradle.api.artifacts.ResolvedConfiguration) ResolveException(org.gradle.api.artifacts.ResolveException)

Aggregations

ResolveException (org.gradle.api.artifacts.ResolveException)5 File (java.io.File)2 ArrayList (java.util.ArrayList)1 Configuration (org.gradle.api.artifacts.Configuration)1 Dependency (org.gradle.api.artifacts.Dependency)1 ResolvedConfiguration (org.gradle.api.artifacts.ResolvedConfiguration)1 RepositoryHandler (org.gradle.api.artifacts.dsl.RepositoryHandler)1 MavenArtifactRepository (org.gradle.api.artifacts.repositories.MavenArtifactRepository)1 ResolutionResult (org.gradle.api.artifacts.result.ResolutionResult)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 BuildDependenciesVisitor (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.BuildDependenciesVisitor)1 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)1 LibraryResolveException (org.gradle.language.base.internal.resolve.LibraryResolveException)1