org.gradle.api.artifacts.result.ResolutionResult Java Examples

The following examples show how to use org.gradle.api.artifacts.result.ResolutionResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompileDependenciesFileGenerator.java    From Phantom with Apache License 2.0 6 votes vote down vote up
private Set<String> getCompileArtifactsForAgp2x() {
    Set<String> compileLibs = new HashSet<>();

    Configuration configuration = project.getConfigurations().getByName("compile");
    if (configuration.isCanBeResolved()) {
        ResolvableDependencies incoming = configuration.getIncoming();
        ResolutionResult resolutionResult = incoming.getResolutionResult();
        Set<ResolvedComponentResult> components = resolutionResult.getAllComponents();

        for (ResolvedComponentResult result : components) {
            ModuleVersionIdentifier identifier = result.getModuleVersion();
            if (identifier != null && !"unspecified".equals(identifier.getVersion())) {
                compileLibs.add(
                        String.join(":", identifier.getGroup(), identifier.getName(), identifier.getVersion()));
            }
        }
    }

    return compileLibs;
}
 
Example #2
Source File: ErrorHandlingArtifactDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    ModuleMetadataProcessor metadataProcessor,
                    ResolverResults results) throws ResolveException {
    try {
        dependencyResolver.resolve(configuration, repositories, metadataProcessor, results);
    } catch (final Throwable e) {
        results.failed(new BrokenResolvedConfiguration(e, configuration), wrapException(e, configuration));
        return;
    }
    ResolvedConfiguration wrappedConfiguration = new ErrorHandlingResolvedConfiguration(results.getResolvedConfiguration(), configuration);
    ResolutionResult wrappedResult = new ErrorHandlingResolutionResult(results.getResolutionResult(), configuration);
    results.resolved(wrappedConfiguration, wrappedResult);
}
 
Example #3
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    GlobalDependencyResolutionRules metadataHandler,
                    ResolverResults results) throws ResolveException {
    if (configuration.getAllDependencies().isEmpty()) {
        ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule());
        ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule());
        ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete();
        results.resolved(new EmptyResolvedConfiguration(), emptyResult);
    } else {
        dependencyResolver.resolve(configuration, repositories, metadataHandler, results);
    }
}
 
Example #4
Source File: ErrorHandlingArtifactDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    GlobalDependencyResolutionRules metadataHandler,
                    ResolverResults results) throws ResolveException {
    try {
        dependencyResolver.resolve(configuration, repositories, metadataHandler, results);
    } catch (final Throwable e) {
        results.failed(new BrokenResolvedConfiguration(e, configuration), wrapException(e, configuration));
        return;
    }
    ResolvedConfiguration wrappedConfiguration = new ErrorHandlingResolvedConfiguration(results.getResolvedConfiguration(), configuration);
    ResolutionResult wrappedResult = new ErrorHandlingResolutionResult(results.getResolutionResult(), configuration);
    results.resolved(wrappedConfiguration, wrappedResult);
}
 
Example #5
Source File: StreamingResolutionResultBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult complete() {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(DONE);
        }
    });
    BinaryStore.BinaryData data = store.done();
    RootFactory rootSource = new RootFactory(data, failures, cache);
    return new DefaultResolutionResult(rootSource);
}
 
Example #6
Source File: ResolverResults.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult getResolutionResult() {
    assertHasResult();
    if (fatalFailure != null) {
        throw fatalFailure;
    }
    return resolutionResult;
}
 
Example #7
Source File: ResolverResults.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult getResolutionResult() {
    assertHasResult();
    if (fatalFailure != null) {
        throw fatalFailure;
    }
    return resolutionResult;
}
 
Example #8
Source File: StreamingResolutionResultBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult complete() {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(DONE);
        }
    });
    BinaryStore.BinaryData data = store.done();
    RootFactory rootSource = new RootFactory(data, failures, cache);
    return new DefaultResolutionResult(rootSource);
}
 
Example #9
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    ModuleMetadataProcessor metadataProcessor,
                    ResolverResults results) throws ResolveException {
    if (configuration.getAllDependencies().isEmpty()) {
        ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule());
        ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule());
        ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete();
        results.resolved(new EmptyResolvedConfiguration(), emptyResult);
    } else {
        dependencyResolver.resolve(configuration, repositories, metadataProcessor, results);
    }
}
 
Example #10
Source File: ErrorHandlingArtifactDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    ModuleMetadataProcessor metadataProcessor,
                    ResolverResults results) throws ResolveException {
    try {
        dependencyResolver.resolve(configuration, repositories, metadataProcessor, results);
    } catch (final Throwable e) {
        results.failed(new BrokenResolvedConfiguration(e, configuration), wrapException(e, configuration));
        return;
    }
    ResolvedConfiguration wrappedConfiguration = new ErrorHandlingResolvedConfiguration(results.getResolvedConfiguration(), configuration);
    ResolutionResult wrappedResult = new ErrorHandlingResolutionResult(results.getResolutionResult(), configuration);
    results.resolved(wrappedConfiguration, wrappedResult);
}
 
Example #11
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    ModuleMetadataProcessor metadataProcessor,
                    ResolverResults results) throws ResolveException {
    if (configuration.getAllDependencies().isEmpty()) {
        ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule());
        ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule());
        ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete();
        results.resolved(new EmptyResolvedConfiguration(), emptyResult);
    } else {
        dependencyResolver.resolve(configuration, repositories, metadataProcessor, results);
    }
}
 
Example #12
Source File: StreamingResolutionResultBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult complete() {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(DONE);
        }
    });
    BinaryStore.BinaryData data = store.done();
    RootFactory rootSource = new RootFactory(data, failures, cache);
    return new DefaultResolutionResult(rootSource);
}
 
Example #13
Source File: ResolverResults.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult getResolutionResult() {
    assertHasResult();
    if (fatalFailure != null) {
        throw fatalFailure;
    }
    return resolutionResult;
}
 
Example #14
Source File: ResolverResults.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult getResolutionResult() {
    assertHasResult();
    if (fatalFailure != null) {
        throw fatalFailure;
    }
    return resolutionResult;
}
 
Example #15
Source File: StreamingResolutionResultBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolutionResult complete() {
    store.write(new BinaryStore.WriteAction() {
        public void write(Encoder encoder) throws IOException {
            encoder.writeByte(DONE);
        }
    });
    BinaryStore.BinaryData data = store.done();
    RootFactory rootSource = new RootFactory(data, failures, cache);
    return new DefaultResolutionResult(rootSource);
}
 
Example #16
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    GlobalDependencyResolutionRules metadataHandler,
                    ResolverResults results) throws ResolveException {
    if (configuration.getAllDependencies().isEmpty()) {
        ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule());
        ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule());
        ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete();
        results.resolved(new EmptyResolvedConfiguration(), emptyResult);
    } else {
        dependencyResolver.resolve(configuration, repositories, metadataHandler, results);
    }
}
 
Example #17
Source File: ErrorHandlingArtifactDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(ConfigurationInternal configuration,
                    List<? extends ResolutionAwareRepository> repositories,
                    GlobalDependencyResolutionRules metadataHandler,
                    ResolverResults results) throws ResolveException {
    try {
        dependencyResolver.resolve(configuration, repositories, metadataHandler, results);
    } catch (final Throwable e) {
        results.failed(new BrokenResolvedConfiguration(e, configuration), wrapException(e, configuration));
        return;
    }
    ResolvedConfiguration wrappedConfiguration = new ErrorHandlingResolvedConfiguration(results.getResolvedConfiguration(), configuration);
    ResolutionResult wrappedResult = new ErrorHandlingResolutionResult(results.getResolutionResult(), configuration);
    results.resolved(wrappedConfiguration, wrappedResult);
}
 
Example #18
Source File: ErrorHandlingArtifactDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ErrorHandlingResolutionResult(ResolutionResult resolutionResult, Configuration configuration) {
    this.resolutionResult = resolutionResult;
    this.configuration = configuration;
}
 
Example #19
Source File: ErrorHandlingArtifactDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ErrorHandlingResolutionResult(ResolutionResult resolutionResult, Configuration configuration) {
    this.resolutionResult = resolutionResult;
    this.configuration = configuration;
}
 
Example #20
Source File: DefaultConfiguration.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ResolutionResult getResolutionResult() {
    DefaultConfiguration.this.resolveNow();
    return DefaultConfiguration.this.cachedResolverResults.getResolutionResult();
}
 
Example #21
Source File: AsciiDependencyReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void render(Configuration configuration) throws IOException {
    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    RenderableDependency root = new RenderableModuleResult(result.getRoot());
    renderNow(root);
}
 
Example #22
Source File: AsciiDependencyReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void render(Configuration configuration) throws IOException {
    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    RenderableDependency root = new RenderableModuleResult(result.getRoot());
    renderNow(root);
}
 
Example #23
Source File: ResolverResults.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void resolved(ResolvedConfiguration resolvedConfiguration, ResolutionResult resolutionResult) {
    this.resolvedConfiguration = resolvedConfiguration;
    this.resolutionResult = resolutionResult;
    this.fatalFailure = null;
}
 
Example #24
Source File: DefaultConfiguration.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ResolutionResult getResolutionResult() {
    DefaultConfiguration.this.resolveNow();
    return DefaultConfiguration.this.cachedResolverResults.getResolutionResult();
}
 
Example #25
Source File: ResolverResults.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void resolved(ResolvedConfiguration resolvedConfiguration, ResolutionResult resolutionResult) {
    this.resolvedConfiguration = resolvedConfiguration;
    this.resolutionResult = resolutionResult;
    this.fatalFailure = null;
}
 
Example #26
Source File: DependencyInspector.java    From play-services-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void afterResolve(ResolvableDependencies resolvableDependencies) {
  String taskName = resolvableDependencies.getName();

  // Use of Product Flavors can change task names so skip tasks without compile in the name (case
  // in-sensitive).
  if (!taskName.contains("ompile")) {
    return;
  }

  // Phase 1: register all the dependency information from the project globally.
  logger.info("Registered task dependencies: " + projectName + ":" + taskName);
  if (resolvableDependencies.getResolutionResult() != null &&
      resolvableDependencies.getResolutionResult().getAllDependencies() != null) {
    registerDependencies(resolvableDependencies, projectName, taskName);
  }

  // Phase 2: take the resolved versions of Artifacts, go get the dependencies that
  // apply to those specific versions, and then ensure all are being honored.
  logger.info("Starting dependency analysis");
  ResolutionResult resolutionResult = resolvableDependencies.getResolutionResult();

  // Create an Artifact to ArtifactVersion mapping for resolved components.
  HashMap<Artifact, ArtifactVersion> resolvedVersions = new HashMap<>();
  for (ResolvedComponentResult resolvedComponentResult :
      resolutionResult.getAllComponents()) {
    ArtifactVersion version = ArtifactVersion.Companion.fromGradleRefOrNull(
        resolvedComponentResult.getId().toString());
    if (version != null) {
      resolvedVersions.put(version.getArtifact(), version);
    }
  }

  // Quick no-op when no versions.
  if (resolvedVersions.size() < 1) {
    return;
  }

  // Retrieve dependencies that apply to the resolved dep set.
  Collection<Dependency> activeDeps = dependencyAnalyzer.getActiveDependencies(
      resolvedVersions.values());
  // Validate each of the dependencies that should apply.
  for (Dependency dep : activeDeps) {
    ArtifactVersion resolvedVersion = resolvedVersions.get(dep.getToArtifact());

    // Check whether dependency is still valid.
    if (!dep.isVersionCompatible(resolvedVersion.getVersion())) {
      // This means a resolved version failed a dependency rule.

      logger.warn("Dependency resolved to an incompatible version: " + dep);

      // TODO: Warn, not fail, when the Major version boundaries are breached.
      // TODO: Experiment with collecting all issues and reporting them at once.
      Collection<Node> depsPaths = dependencyAnalyzer.getPaths(
          resolvedVersion.getArtifact());

      // Print extended path information at INFO level.
      logger.info("Dependency Resolution Help: Displaying all currently known " +
          "paths to any version of the dependency: " + dep.getToArtifact());
      logger.info("NOTE: com.google.android.gms translated to c.g.a.g for brevity. " +
          "Same for com.google.firebase -> c.g.f");
      // TODO: The depPaths nodes need to be consolidated prior to display.
      for (Node n : depsPaths) {
        printNode(1, n);
      }

      throw new GradleException(getErrorMessage(dep, resolvedVersion, depsPaths));
    }
  }
}
 
Example #27
Source File: DefaultConfiguration.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ResolutionResult getResolutionResult() {
    DefaultConfiguration.this.resolveNow();
    return DefaultConfiguration.this.cachedResolverResults.getResolutionResult();
}
 
Example #28
Source File: ResolverResults.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void resolved(ResolvedConfiguration resolvedConfiguration, ResolutionResult resolutionResult) {
    this.resolvedConfiguration = resolvedConfiguration;
    this.resolutionResult = resolutionResult;
    this.fatalFailure = null;
}
 
Example #29
Source File: AsciiDependencyReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void render(Configuration configuration) throws IOException {
    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    RenderableDependency root = new RenderableModuleResult(result.getRoot());
    renderNow(root);
}
 
Example #30
Source File: AsciiDependencyReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void render(Configuration configuration) throws IOException {
    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    RenderableDependency root = new RenderableModuleResult(result.getRoot());
    renderNow(root);
}