org.gradle.api.artifacts.Configuration.getAllDependencies()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中org.gradle.api.artifacts.Configuration.getAllDependencies()方法的一些代码示例,展示了Configuration.getAllDependencies()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getAllDependencies()方法的具体详情如下:
包路径:org.gradle.api.artifacts.Configuration
类名称:Configuration
方法名:getAllDependencies

Configuration.getAllDependencies介绍

暂无

代码示例

代码示例来源:origin: uber/okbuck

/**
 * Checks if the configuration has any empty annotation processors.
 *
 * @param project project on which the configuration is defined.
 * @param configuration Configuration which is used to query the deps.
 * @return A boolean whether the configuration has any empty annotation processors.
 */
public boolean hasEmptyAnnotationProcessors(Project project, Configuration configuration) {
 Map<Set<Dependency>, Scope> depToScope =
   createProcessorScopes(project, configuration.getAllDependencies(), false);
 return depToScope
   .values()
   .stream()
   .anyMatch(scope -> scope.getAnnotationProcessors().isEmpty());
}

代码示例来源:origin: uber/okbuck

createProcessorScopes(project, configuration.getAllDependencies(), false);

代码示例来源:origin: uber/okbuck

DependencySet dependencies = configuration.getAllDependencies();
String processorsUID =
  dependencies

代码示例来源:origin: uber/okbuck

Set<VersionlessDependency> firstLevelDependencies =
  configuration
    .getAllDependencies()
    .stream()
    .map(

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-js-transpiler

public static Iterable<TaskDependency> getTaskDependencies(
  Configuration configuration) {
  Set<TaskDependency> taskDependencies = new HashSet<>();
  DependencySet dependencySet = configuration.getAllDependencies();
  for (ProjectDependency projectDependency :
      dependencySet.withType(ProjectDependency.class)) {
    taskDependencies.add(projectDependency.getBuildDependencies());
  }
  return taskDependencies;
}

代码示例来源:origin: spring-gradle-plugins/dependency-management-plugin

private boolean isDirectDependency(DependencyResolveDetails details) {
  if (this.directDependencies == null) {
    Set<String> directDependencies = new HashSet<String>();
    for (Dependency dependency : this.configuration.getAllDependencies()) {
      directDependencies.add(dependency.getGroup() + ":" + dependency.getName());
    }
    this.directDependencies = directDependencies;
  }
  return this.directDependencies.contains(details.getRequested().getGroup() + ":"
      + details.getRequested().getName());
}

代码示例来源:origin: org.shipkit/shipkit

public void createDependencyInfoFile(CreateDependencyInfoFileTask task) {
  String result = "# Description" + NEWLINE
    + DESCRIPTION + NEWLINE
    + "# Dependencies";
  //sorting dependencies to assure that they are always in the same order
  //without depending on Gradle implementation
  SortedSet<String> dependencies = new TreeSet<>();
  for (Dependency dependency: task.getConfiguration().getAllDependencies()) {
    if (dependency instanceof ModuleDependency) {
      String dep = getDependencyWithArtifacts(task, (ModuleDependency) dependency);
      dependencies.add(dep);
    }
  }
  result += DEPENDENCY_INDENT + StringUtil.join(dependencies, DEPENDENCY_INDENT);
  IOUtil.writeFile(task.getOutputFile(), result.toString());
}

代码示例来源:origin: mockito/shipkit

public void createDependencyInfoFile(CreateDependencyInfoFileTask task) {
  String result = "# Description" + NEWLINE
    + DESCRIPTION + NEWLINE
    + "# Dependencies";
  //sorting dependencies to assure that they are always in the same order
  //without depending on Gradle implementation
  SortedSet<String> dependencies = new TreeSet<>();
  for (Dependency dependency: task.getConfiguration().getAllDependencies()) {
    if (dependency instanceof ModuleDependency) {
      String dep = getDependencyWithArtifacts(task, (ModuleDependency) dependency);
      dependencies.add(dep);
    }
  }
  result += DEPENDENCY_INDENT + StringUtil.join(dependencies, DEPENDENCY_INDENT);
  IOUtil.writeFile(task.getOutputFile(), result.toString());
}

代码示例来源:origin: EvoSuite/evosuite

System.out.println("Conf: "+c);
for(Dependency d: c.getAllDependencies()){
  System.out.println("Dep: "+d);
System.out.println("Conf: "+c);
for(Dependency d: c.getAllDependencies()){
  System.out.println("Dep: "+d);

代码示例来源:origin: org.gradle/gradle-core

@Override
public void resolve(DependencyResolveContext context) {
  boolean transitive = isTransitive() && context.isTransitive();
  if (transitive) {
    for (Dependency dependency : findProjectConfiguration().getAllDependencies()) {
      context.add(dependency);
    }
  }
}

代码示例来源:origin: com.netflix.nebula/nebula-dependency-recommender

private void applyRecommendationToDependency(final RecommendationStrategyFactory factory, Dependency dependency, List<ProjectDependency> visited) {
  if (dependency instanceof ExternalModuleDependency) {
    factory.getRecommendationStrategy().inspectDependency(dependency);
  } else if (dependency instanceof ProjectDependency) {
    ProjectDependency projectDependency = (ProjectDependency) dependency;
    if (!visited.contains(projectDependency)) {
      visited.add(projectDependency);
      Configuration configuration;
      try {
        ProjectDependency.class.getMethod("getTargetConfiguration");
        String targetConfiguration = projectDependency.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : projectDependency.getTargetConfiguration();
        configuration = projectDependency.getDependencyProject().getConfigurations().getByName(targetConfiguration);
      } catch (NoSuchMethodException ignore) {
        try {
          Method method = ProjectDependency.class.getMethod("getProjectConfiguration");
          configuration = (Configuration) method.invoke(dependency);
        } catch (Exception e) {
          throw new RuntimeException("Unable to retrieve configuration for project dependency", e);
        }
      }
      DependencySet dependencies = configuration.getAllDependencies();
      for (Dependency dep : dependencies) {
        applyRecommendationToDependency(factory, dep, visited);
      }
    }
  }
}

代码示例来源:origin: com.amazon.device.tools.build/gradle-core

private void ensureConfigured(Configuration config) {
  for (Dependency dependency : config.getAllDependencies()) {
    if (dependency instanceof ProjectDependency) {
      ProjectDependency projectDependency = (ProjectDependency) dependency;
      project.evaluationDependsOn(projectDependency.getDependencyProject().getPath());
      try {
        ensureConfigured(projectDependency.getProjectConfiguration());
      } catch (Throwable e) {
        throw new UnknownProjectException(String.format(
            "Cannot evaluate module %s : %s",
            projectDependency.getName(), e.getMessage()),
            e);
      }
    }
  }
}

代码示例来源:origin: typelead/gradle-eta

@Override
  public List<Buildable> call() {
    return getProject().getConfigurations()
      .getByName(getTargetConfiguration())
      .getAllDependencies().stream()
      .filter(dependency -> dependency instanceof ProjectDependency)
      .flatMap(dependency -> {
          final ProjectDependency projectDependency =
            (ProjectDependency) dependency;
          final Project project =
            projectDependency.getDependencyProject();
          final String configurationName =
            projectDependency.getTargetConfiguration();
          return ConfigurationUtils.getConfiguration
            (project, configurationName)
            .getAllArtifacts().stream();
        })
      .collect(Collectors.toList());
  }
});

代码示例来源:origin: typelead/gradle-eta

public static List<String> searchForEtaProjectDependencies
    (final Project project, final Configuration configuration) {

    List<String> allMavenDependencies = new ArrayList<String>();
    for (Dependency dependency : configuration.getAllDependencies()) {
      if (dependency instanceof ProjectDependency) {
        final ProjectDependency projectDependency =
          (ProjectDependency) dependency;
        final Project targetProject = projectDependency.getDependencyProject();
        final String  targetConfiguration =
          projectDependency.getTargetConfiguration();
        List<String> mavenDependencies;
        if (targetProject.getPlugins().hasPlugin(EtaBasePlugin.class)) {
          mavenDependencies = ConfigurationUtils.getEtaConfiguration
            (targetProject, targetConfiguration)
            .getAllResolvedDependencies(project);
        } else {
          mavenDependencies = searchForEtaProjectDependencies
            (project, ConfigurationUtils.getConfiguration
             (targetProject, targetConfiguration));
        }
        allMavenDependencies.addAll(mavenDependencies);
      }
    }

    return allMavenDependencies;
  }
}

代码示例来源:origin: com.android.tools.build/gradle-core

@NonNull
public Set<File> resolveAndGetJackPluginClassPath(
    @NonNull ErrorReporter errorReporter) {
  if (getJackPluginConfiguration().getAllDependencies().isEmpty()) {
    return Collections.emptySet();
  }
  ResolvedConfiguration resolvedConfiguration =
      getJackPluginConfiguration().getResolvedConfiguration();
  if (resolvedConfiguration.hasError()) {
    try {
      resolvedConfiguration.rethrowFailure();
    } catch (Exception e) {
      errorReporter.handleSyncError(
          "jackPlugin",
          SyncIssue.TYPE_UNRESOLVED_DEPENDENCY,
          "Unable to find Jack plugin. " + e.getMessage());
      return Collections.emptySet();
    }
  }
  return getJackPluginConfiguration().getFiles();
}

代码示例来源:origin: Putnami/putnami-gradle-plugin

private Collection<File> listProjectDepsSrcDirs(Project project) {
  ConfigurationContainer configs = project.getConfigurations();
  Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
  DependencySet depSet = compileConf.getAllDependencies();
  List<File> result = Lists.newArrayList();
  for (Dependency dep : depSet) {
    if (dep instanceof ProjectDependency) {
      Project projectDependency = ((ProjectDependency) dep).getDependencyProject();
      if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) {
        JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class);
        SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
        result.addAll(mainSourceSet.getAllSource().getSrcDirs());
      }
    }
  }
  return result;
}

代码示例来源:origin: gradle.plugin.de.esoco.gwt/gwt-gradle-plugin

private Collection<File> listProjectDepsSrcDirs(Project project) {
  ConfigurationContainer configs = project.getConfigurations();
  Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
  DependencySet depSet = compileConf.getAllDependencies();
  List<File> result = Lists.newArrayList();
  for (Dependency dep : depSet) {
    if (dep instanceof ProjectDependency) {
      Project projectDependency = ((ProjectDependency) dep).getDependencyProject();
      if (projectDependency.getPlugins().hasPlugin(GwtLibPlugin.class)) {
        JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class);
        SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
        result.addAll(mainSourceSet.getAllSource().getSrcDirs());
      }
    }
  }
  return result;
}

代码示例来源:origin: spring-gradle-plugins/dependency-management-plugin

private Set<DependencyCandidate> findExcludedDependencies() {
  DependencySet allDependencies = this.configuration.getAllDependencies();
  Configuration configurationCopy = this.configurationContainer.newConfiguration(
      this.configurationConfigurer,

代码示例来源:origin: gradle.plugin.com.github.krs.xrepo-gradle-plugin/xrepo-gradle-plugin

private static DependencyOverwrites collectDependenciesToOverwrite(final Configuration compileClasspath, final Configuration testCompile,
                                  final XRepoConfiguration config, final Project project) {
  final Configuration groupDeps = dependenciesWithinProjectGroup(testCompile, project);
  debug(project, "Found {} dependencies with group {}", groupDeps.getAllDependencies().size(), project.getGroup());
  useSuffixedVersions(groupDeps, config, project);
  final DependencyOverwrites result = new DependencyOverwrites();
  compileClasspath.getIncoming().beforeResolve((deps) -> {
    groupDeps.getResolvedConfiguration().getLenientConfiguration().getAllModuleDependencies().forEach(dep -> {
      if (isInSameGroup(dep.getModuleGroup(), project)) {
        debug(project, "Found overwritten dependency {}:{}:{}", dep.getModuleGroup(), dep.getModuleName(), dep.getModuleVersion());
        result.add(dep);
      }
    });
  });
  return result;
}

代码示例来源:origin: gradle.plugin.de.esoco.gwt/gwt-gradle-plugin

compileClasspath.getAllDependencies().withType(ProjectDependency.class, new Action<ProjectDependency>() {
  @Override
  public void execute(ProjectDependency dep) {

相关文章