org.gradle.api.artifacts.Configuration类的使用及代码示例

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

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

Configuration介绍

暂无

代码示例

代码示例来源:origin: diffplug/spotless

public static Provisioner fromProject(Project project) {
  Objects.requireNonNull(project);
  return (withTransitives, mavenCoords) -> {
    try {
      Dependency[] deps = mavenCoords.stream()
          .map(project.getBuildscript().getDependencies()::create)
          .toArray(Dependency[]::new);
      Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration(deps);
      config.setDescription(mavenCoords.toString());
      config.setTransitive(withTransitives);
      return config.resolve();
    } catch (Exception e) {
      logger.log(Level.SEVERE,
          StringPrinter.buildStringFromLines("You probably need to add a repository containing the '" + mavenCoords + "' artifact in the 'build.gradle' of your root project.",
              "E.g.: 'buildscript { repositories { mavenCentral() }}'",
              "Note that included buildscripts (using 'apply from') do not share their buildscript repositories with the underlying project.",
              "You have to specify the missing repository explicitly in the buildscript of the root project."),
          e);
      throw e;
    }
  };
}

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

public void setupBuckBinary() {
 OkBuckExtension okbuckExt = ProjectUtil.getOkBuckExtension(rootProject);
 // Create dependency cache for buck binary if needed
 if (okbuckExt.buckBinary != null) {
  Configuration buckConfig =
    rootProject.getConfigurations().maybeCreate(BUCK_BINARY_CONFIGURATION);
  rootProject
    .getRepositories()
    .maven(mavenArtifactRepository -> mavenArtifactRepository.setUrl(JITPACK_URL));
  rootProject.getDependencies().add(BUCK_BINARY_CONFIGURATION, okbuckExt.buckBinary);
  Set<File> resolvedFiles = buckConfig.getResolvedConfiguration().getFiles();
  Preconditions.checkArgument(resolvedFiles.size() == 1);
  realBuckBinaryPath = resolvedFiles.iterator().next().toPath();
 }
}

代码示例来源:origin: jooby-project/jooby

public Set<File> classpath() {
 SourceSet sourceSet = sourceSet(project);
 // conf & public
 Set<File> cp = new LinkedHashSet<>(sourceSet.getResources().getSrcDirs());
 // classes/main, resources/main + jars
 cp.addAll(sourceSet.getRuntimeClasspath().getFiles());
 // provided?
 Configuration provided = project.getConfigurations().findByName("provided");
 if (provided != null) {
  cp.addAll(provided.getFiles());
 }
 return cp;
}

代码示例来源:origin: ManbangGroup/Phantom

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;
}

代码示例来源:origin: alipay/sofa-boot

private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
  UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
  project.getConfigurations().all((configuration) -> {
    ResolvableDependencies incoming = configuration.getIncoming();
    incoming.afterResolve((resolvableDependencies) -> {
      if (incoming.equals(resolvableDependencies)) {
        unresolvedDependenciesAnalyzer.analyze(configuration
            .getResolvedConfiguration().getLenientConfiguration()
            .getUnresolvedModuleDependencies());
      }
    });
  });
  project.getGradle().buildFinished(
      (buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
}

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

@Override
  public void execute(Configuration files) {
    files.setVisible(false);
    files.setTransitive(true);
    files.setDescription("The Jacoco agent to use to get coverage data.");
  }
});

代码示例来源:origin: gradle.plugin.hu.advanceweb/scott-gradle-plugin

private Configuration configureAgentDependencies(Project project, ScottPluginExtension extension) {
  Configuration agentConf = project.getConfigurations().create(AGENT_CONFIGURATION_NAME);
  agentConf.setVisible(false);
  agentConf.setTransitive(true);
  agentConf.setDescription("The Scott agent to use detailed failure reports and hassle free assertions for Java tests");
  agentConf.defaultDependencies(dependencies ->
    dependencies.add(project.getDependencies().create("hu.advancedweb:scott:" + extension.getToolVersion()))
  );
  return agentConf;
}

代码示例来源:origin: google/play-services-plugins

@Test
public void testGetResolvedArtifacts_returnArtifact() {
 Set<ResolvedArtifact> artifactSet = (Set<ResolvedArtifact>) mock(Set.class);
 ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class);
 when(resolvedConfiguration.getResolvedArtifacts()).thenReturn(artifactSet);
 Configuration configuration = mock(Configuration.class);
 when(configuration.getName()).thenReturn("compile");
 when(configuration.isCanBeResolved()).thenReturn(true);
 when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);
 assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
}

代码示例来源: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: io.github.udaychandra.susel/susel-gradle-plugin

private Configuration addToolDependency(Project project) {
  Configuration config = project.getConfigurations().create("susel")
      .setVisible(false)
      .setDescription("Process and create metadata for all service providers.");
  config.defaultDependencies(dependencies ->
      dependencies.add(project.getDependencies().create("io.github.udaychandra.susel:tool:0.1.2")));
  return config;
}

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

private Configuration _addConfigurationJSCompile(Project project) {
  Configuration configuration = GradleUtil.addConfiguration(
    project, JS_COMPILE_CONFIGURATION_NAME);
  configuration.setDescription(
    "Configures additional JavaScript dependencies.");
  configuration.setVisible(false);
  return configuration;
}

代码示例来源:origin: com.github.moritzzimmer/fsm-gradle-plugin

private void configureConfigurations(
    ConfigurationContainer configurationContainer) {
  Configuration provideCompileConfiguration = configurationContainer
      .create(PROVIDED_COMPILE_CONFIGURATION_NAME)
      .setVisible(false)
      .setDescription(
          "Additional compile classpath for libraries that should not be part of the FSM archive.");
  Configuration provideRuntimeConfiguration = configurationContainer
      .create(PROVIDED_RUNTIME_CONFIGURATION_NAME)
      .setVisible(false)
      .extendsFrom(provideCompileConfiguration)
      .setDescription(
          "Additional runtime classpath for libraries that should not be part of the FSM archive.");
  configurationContainer.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME)
      .extendsFrom(provideCompileConfiguration);
  configurationContainer.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME)
      .extendsFrom(provideRuntimeConfiguration);
}

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

@Override
  public void execute(Configuration configuration) {
    if (container.getExcludedConfigurations().contains(configuration.getName())) {
      return;
    }

    if (configuration.getState() == Configuration.State.UNRESOLVED) {
      Configuration toExtend = bom;
      if (!project.getRootProject().equals(project)) {
        toExtend = bom.copy();
        toExtend.setVisible(false);
        project.getConfigurations().add(toExtend);
      }
      configuration.extendsFrom(toExtend);
    } else {
      logger.info("Configuration '" + configuration.getName() + "' has already been resolved and cannot be included for recommendation");
    }
  }
}

代码示例来源: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: diffplug/spotless

/**
 * Creates a Provisioner for the given repositories.
 *
 * The first time a project is created, there are ~7 seconds of configuration
 * which will go away for all subsequent runs.
 *
 * Every call to resolve will take about 1 second, even when all artifacts are resolved.
 */
private static Supplier<Provisioner> createLazyWithRepositories(Consumer<RepositoryHandler> repoConfig) {
  // Running this takes ~3 seconds the first time it is called. Probably because of classloading.
  return Suppliers.memoize(() -> {
    Project project = ProjectBuilder.builder().build();
    repoConfig.accept(project.getRepositories());
    return (withTransitives, mavenCoords) -> {
      Dependency[] deps = mavenCoords.stream()
          .map(project.getDependencies()::create)
          .toArray(Dependency[]::new);
      Configuration config = project.getConfigurations().detachedConfiguration(deps);
      config.setTransitive(withTransitives);
      config.setDescription(mavenCoords.toString());
      try {
        return config.resolve();
      } catch (ResolveException e) {
        /* Provide Maven coordinates in exception message instead of static string 'detachedConfiguration' */
        throw new ResolveException(config.getDescription(), e);
      }
    };
  });
}

代码示例来源: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.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: uber/okbuck

public Scope build() {
  Configuration useful = DependencyUtils.useful(configuration);
  String key = useful != null ? useful.getName() : "--none--";
  return ProjectCache.getScopeCache(project)
    .computeIfAbsent(
      key,
      t ->
        new Scope(
          project, useful, sourceDirs, javaResourceDirs, compilerOptions, depCache));
 }
}

代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin

private void configureToolsConfigurations(Project project) {
 Configuration tools = project.getConfigurations().create(TOOLS_CONFIGURATION_NAME);
 tools.defaultDependencies(deps -> {
  deps.add(project.getDependencies().create("io.github.gradle-clojure:gradle-clojure-tools:" + getVersion()));
 });
 // TODO does this JAR get included via shadow or application plugins?
 project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
  project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName()).extendsFrom(tools);
  project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName()).extendsFrom(tools);
 });
}

代码示例来源:origin: gradle.plugin.ca.coglinc2/javacc-gradle-plugin

private void configureDefaultJavaccDependency(final Project project, Configuration configuration) {
  configuration.defaultDependencies(new Action<DependencySet>() {
    @Override
    public void execute(DependencySet dependencies) {
      dependencies.add(project.getDependencies().create("net.java.dev.javacc:javacc:6.1.2"));
    }
  });
}

相关文章

微信公众号

最新文章

更多