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

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

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

Configuration.getDependencies介绍

暂无

代码示例

代码示例来源:origin: echocat/gradle-golang-plugin

protected void appendDependenciesOf(@Nonnull Configuration configuration, @Nonnull Collection<GolangDependency> to) {
  for (final Dependency dependency : configuration.getDependencies()) {
    final GolangDependency toAdd;
    if (dependency instanceof GolangDependency) {
      toAdd = (GolangDependency) dependency;
    } else {
      toAdd = new GolangDependency(dependency);
    }
    if (!to.contains(toAdd)) {
      to.add(toAdd);
    }
  }
}

代码示例来源:origin: gradle.plugin.org.echocat.gradle.plugins/gradle-golang-plugin

@Nonnull
public Dependency doAdd(@Nonnull String configurationName, @Nonnull Dependency dependency) {
  final Configuration configuration = _configurationContainer.getByName(configurationName);
  configuration.getDependencies().add(dependency);
  return dependency;
}

代码示例来源:origin: echocat/gradle-golang-plugin

@Nonnull
protected Dependency doAdd(@Nonnull String configurationName, @Nonnull Dependency dependency, @Nullable Closure<?> configureWith) {
  if (!_root) {
    throw new IllegalStateException("Adding of dependencies for golang is currently not support at task level.");
  }
  final Configuration configuration = _project.getConfigurations().getByName(configurationName);
  configuration.getDependencies().add(dependency);
  if (configureWith != null) {
    return configure(configureWith, dependency);
  }
  return dependency;
}

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

@Override
  public void execute(ResolvableDependencies resolvableDependencies) {
    if (config.getDependencies().isEmpty()) {
      config.getDependencies().add(project.getDependencies().create(
          "org.jacoco:org.jacoco.ant:" + jacocoVersion));
    }
  }
});

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

@Override
  public void execute(ResolvableDependencies resolvableDependencies) {
    if (config.getDependencies().isEmpty()) {
      config.getDependencies().add(project.getDependencies().create(
              "org.jacoco:org.jacoco.agent:" + jacocoVersion));
    }
  }
});

代码示例来源:origin: de.carne.common/java-gradle-plugins

private void addConfiguration(Project project, Configuration configuration) {
  configuration.getDependencies().forEach(dependency -> addDependency(project, configuration, dependency));
}

代码示例来源:origin: gradle.plugin.org.javamodularity/moduleplugin

public static Optional<TestEngine> select(Project project) {
  var configurations = project.getConfigurations();
  var testImplementation = configurations.getByName("testImplementation").getDependencies().stream();
  var testCompile = configurations.getByName("testCompile").getDependencies().stream();
  return Stream.concat(testImplementation, testCompile)
      .map(d -> TestEngine.select(d.getGroup(), d.getName()))
      .filter(Optional::isPresent)
      .map(Optional::get)
      .findAny();
}

代码示例来源:origin: org.openjfx/javafx-plugin

private void clearJavaFXDependencies() {
    var implementationConfiguration = project.getConfigurations().findByName("implementation");
    if (implementationConfiguration != null) {
      implementationConfiguration.getDependencies()
          .removeIf(dependency -> MAVEN_JAVAFX_ARTIFACT_GROUP_ID.equals(dependency.getGroup()));
    }
  }
}

代码示例来源:origin: javafxports/javafxmobile-plugin

private static VersionNumber retrolambdaVersion(Configuration retrolambdaConfig) {
  retrolambdaConfig.resolve();
  Dependency retrolambdaDep = retrolambdaConfig.getDependencies().iterator().next();
  if (retrolambdaDep.getVersion() == null) {
    // Don't know version
    return null;
  }
  return VersionNumber.parse(retrolambdaDep.getVersion());
}

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

@Override
  Set<File> getFilesOnConfiguration() {
    List<Dependency> rawPomDependencies = new ArrayList<>();
    for(org.gradle.api.artifacts.Dependency dependency: configuration.getDependencies()) {
      rawPomDependencies.add(project.getDependencies().create(dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion() + "@pom"));
    }
    return project.getConfigurations().detachedConfiguration(
        rawPomDependencies.toArray(new org.gradle.api.artifacts.Dependency[0])).resolve();
  }
}

代码示例来源:origin: gradle.plugin.com.palantir.python/gradle-miniconda-plugin

@Override
  public void execute(ResolvableDependencies resolvableDependencies) {
    // Allows custom minicondaInstaller ivy dependency override
    if (configuration.getDependencies().isEmpty()) {
      MinicondaInstaller installer = new MinicondaInstaller(os, miniconda);
      installer.addToDependencyHandler(project.getDependencies());
    }
  }
});

代码示例来源:origin: gradle.plugin.com.digitalascent/digitalascent-gradle-project

private void configureNebulaResolutionRules(Project project) {
    Configuration resolutionRulesConfiguration = project.getRootProject().getConfigurations().getAt("resolutionRules");
    resolutionRulesConfiguration.getDependencies().add(project.getDependencies().create("com.netflix.nebula:gradle-resolution-rules:0.52.0"));

    NebulaResolutionRulesExtension resolutionRulesExtension = (NebulaResolutionRulesExtension) project.getExtensions().getByName("nebulaResolutionRules");
    resolutionRulesExtension.getOptional().add("slf4j-bridge");
    project.afterEvaluate((o) -> {
      project.getLogger().lifecycle("Optional resolution rules: {}", resolutionRulesExtension.getOptional());
      resolutionRulesConfiguration.getDependencies().forEach(dependency -> project.getLogger().lifecycle("Resolution rules dependency: {}", dependency));
    });
  }
}

代码示例来源:origin: gradle.plugin.com.lazan/gradle-maven-transform

@Override
public ModelSource resolveModel(String groupId, String artifactId, String version) throws UnresolvableModelException {
  String configName = String.format("pomTransform%s", UUID.randomUUID());
  Configuration config = getProject().getConfigurations().create(configName);
  config.setTransitive(false);
  String depNotation = String.format("%s:%s:%s@pom", groupId, artifactId, version);
  org.gradle.api.artifacts.Dependency dependency = getProject().getDependencies().create(depNotation);
  config.getDependencies().add(dependency);
  File pomXml = config.getSingleFile();
  return new ModelSource() {
    @Override
    public InputStream getInputStream() throws IOException {
      return new FileInputStream(pomXml);
    }
    @Override
    public String getLocation() {
      return pomXml.getAbsolutePath();
    }
  };
}

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

private Configuration createConfiguration(List<PomReference> pomReferences) {
  Configuration configuration = this.configurationContainer.newConfiguration();
  for (PomReference pomReference: pomReferences) {
    Coordinates coordinates = pomReference.getCoordinates();
    configuration.getDependencies().add(this.dependencyHandler.create(coordinates.getGroupId() + ":"
        + coordinates.getArtifactId() + ":" + coordinates.getVersion() + "@pom"));
  }
  return configuration;
}

代码示例来源:origin: de.carne.common/java-gradle-plugins

private void executeCheckDependencyVersions(DependencyMap dependencyMap, Configuration cdvConfiguration,
    CheckDependencyVersionsReport report) {
  Set<ArtifactId> dependencyArtifactIds = dependencyMap.keySet().stream().map(DependencyKey::getArtifactId)
      .collect(Collectors.toSet());
  for (ArtifactId dependencyArtifactId : dependencyArtifactIds) {
    String dependencyArtifactIdString = dependencyArtifactId.toString();
    getProject().getLogger().info("Checking latest version for dependency {}...", dependencyArtifactIdString);
    String artifactDependencyString = dependencyArtifactIdString + ":+";
    Dependency artifactDependency = getProject().getDependencies().create(artifactDependencyString);
    cdvConfiguration.getDependencies().add(artifactDependency);
  }
  cdvConfiguration.resolutionStrategy(resolutionStrategy -> resolutionStrategy
      .componentSelection(componentSelectionRules -> componentSelectionRules
          .all(componentSelection -> filterComponentenSelection(dependencyMap, componentSelection))));
  LenientConfiguration resolvedCdvConfiguration = cdvConfiguration.getResolvedConfiguration()
      .getLenientConfiguration();
  Map<ArtifactId, ResolvedArtifact> resolvedArtifactsMap = buildResolvedArtifactsMap(
      resolvedCdvConfiguration.getArtifacts());
  evalDependencyVersions(dependencyMap, resolvedArtifactsMap, report);
}

代码示例来源:origin: gradle.plugin.com.triplequote.gradle/hydra

@Override
public FileCollection createDelegate() {
  checkRequiredSettings(project, hydraSettings);
  String scalaVersion = getScalaVersion(classpath);
  Configuration hydraConfiguration = project.getConfigurations().detachedConfiguration(
      new DefaultExternalModuleDependency("com.triplequote", "hydra_" + scalaVersion, hydraSettings.getVersion())
  );
  hydraConfiguration.exclude(excludeProperties("org.scala-lang", "scala-reflect"));
  hydraConfiguration.exclude(excludeProperties("com.triplequote", "scala-library"));
  LOGGER.debug("Hydra version: {}. Inferred Scala classpath: {}", hydraSettings.getVersion(), hydraConfiguration.getFiles());
  Configuration hydraDashboardConfiguration = project.getConfigurations().getByName(HydraBasePlugin.HYDRA_DASHBOARD_CONFIGURATION);
  if (hydraDashboardConfiguration.getDependencies().isEmpty()) {
    hydraDashboardConfiguration.getDependencies().add(
        new DefaultExternalModuleDependency("com.triplequote", "dashboard-client_2.12", hydraSettings.getMetricsServiceVersion())
    );
  }
  return hydraConfiguration;
}

代码示例来源:origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm

private Set<ResolvedDependency> doResolve(final Collection<ArtifactSpec> deps) {
  final Configuration config = this.project.getConfigurations().detachedConfiguration();
  final DependencySet dependencySet = config.getDependencies();
  deps.forEach(spec -> {
    final DefaultExternalModuleDependency d =
        new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version());
    final DefaultDependencyArtifact da =
        new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null);
    d.addArtifact(da);
    d.getExcludeRules().add(new DefaultExcludeRule());
    dependencySet.add(d);
  });
  return config.getResolvedConfiguration().getFirstLevelModuleDependencies();
}

代码示例来源:origin: gradle.plugin.com.banderous.gpm/plugin

static Set<ResolvedDependency> gatherDependencies(Project project, Set<String> repositories,
                         Set<String> dependencies) {
 for (final String r : repositories) {
  project.getRepositories().ivy(new Action<IvyArtifactRepository>() {
   @Override
   public void execute(IvyArtifactRepository ivyArtifactRepository) {
    ivyArtifactRepository.setUrl(r);
   }
  });
 }
 Configuration conf = project.getConfigurations().create("nxtTmp" + count++);
 for (String id : dependencies) {
  conf.getDependencies().add(project.getDependencies().create(id));
 }
 return gatherDependencies(conf.getResolvedConfiguration().getFirstLevelModuleDependencies());
}

代码示例来源:origin: gradle.plugin.com.banderous.getpack/plugin

static Set<ResolvedDependency> gatherDependencies(Project project, Set<String> repositories,
                         Set<String> dependencies) {
 for (final String r : repositories) {
  project.getRepositories().ivy(new Action<IvyArtifactRepository>() {
   @Override
   public void execute(IvyArtifactRepository ivyArtifactRepository) {
    ivyArtifactRepository.setUrl(r);
   }
  });
 }
 Configuration conf = project.getConfigurations().create("gpTmp" + count++);
 for (String id : dependencies) {
  conf.getDependencies().add(project.getDependencies().create(id));
 }
 return gatherDependencies(conf.getResolvedConfiguration().getFirstLevelModuleDependencies());
}

代码示例来源:origin: gradle.plugin.com.outlinegames/plugin

static Set<ResolvedDependency> gatherDependencies(Project project, Set<String> repositories,
                         Set<String> dependencies) {
 for (final String r : repositories) {
  project.getRepositories().ivy(new Action<IvyArtifactRepository>() {
   @Override
   public void execute(IvyArtifactRepository ivyArtifactRepository) {
    ivyArtifactRepository.setUrl(r);
   }
  });
 }
 Configuration conf = project.getConfigurations().create("nxtTmp" + count++);
 for (String id : dependencies) {
  conf.getDependencies().add(project.getDependencies().create(id));
 }
 return gatherDependencies(conf.getResolvedConfiguration().getFirstLevelModuleDependencies());
}

相关文章