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

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

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

Configuration.resolve介绍

暂无

代码示例

代码示例来源: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: 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: com.netflix.nebula/nebula-dependency-recommender

Set<File> getFilesOnConfiguration() {
    return configuration.resolve();
  }
}

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

@NonNull
private List<Path> getClasspath() {
  ImmutableList.Builder<Path> classpathEntries = ImmutableList.builder();
  classpathEntries.addAll(androidRuntime.resolve().stream()
      .map(File::toPath)
      .iterator());
  List<Path> l = classpathEntries.build();
  l.forEach(System.out::println);
  return l;
}

代码示例来源:origin: gradle.plugin.com.jonaslasauskas.capsule/gradle-capsule-plugin

private void mergeContentOf(Configuration configuration, Project project) {
 Set<File> capsuleArtifacts = configuration.resolve();
 from(capsuleArtifacts.stream().map(project::zipTree).toArray());
}

代码示例来源:origin: gradle.plugin.com.enonic.xp/xp-gradle-plugin

private File resolveDependency()
  {
    return getProject().getConfigurations().getByName( DISTRO_CONFIG ).resolve().iterator().next();
  }
}

代码示例来源:origin: gradle.plugin.com.enonic.gradle/xp-gradle-plugin

private File resolveDependency()
  {
    return getProject().getConfigurations().getByName( DISTRO_CONFIG ).resolve().iterator().next();
  }
}

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

private FileModelSource resolveModel(String coordinates) {
  Dependency dependency = this.project.getDependencies().create(coordinates);
  Configuration configuration = this.configurationContainer.newConfiguration(dependency);
  return new FileModelSource(configuration.resolve().iterator().next());
}

代码示例来源:origin: gradle.plugin.com.enonic.gradle/xp-gradle-plugin

@Input
public Set<File> getFiles()
{
  return getProject().getConfigurations().getByName( APP_CONFIG ).resolve();
}

代码示例来源:origin: gradle.plugin.com.enonic.xp/xp-gradle-plugin

@Input
public Set<File> getFiles()
{
  return getProject().getConfigurations().getByName( APP_CONFIG ).resolve();
}

代码示例来源:origin: CoffeePartner/capt

void initClassLoader(TransformInvocation invocation, List<File> bootClasspath, Configuration target) {
  URL[] runnerUrls = target.resolve().stream()
      .map(f -> {
        try {

代码示例来源:origin: baratine/baratine

private void writeDependencies(JarOutputStream zOs)
 throws IOException
{
 Configuration targetConfig;
 
 targetConfig = _project.getConfigurations().getByName("runtime");
 
 for (File lib : targetConfig.resolve()) {
  if (isBootJar(lib)) {
   copyBootJar(zOs, lib);
  }
  
  String name = lib.getName();
  
  zOs.setLevel(0);
  
  ZipEntry entry = new ZipEntry("lib/" + name);
  
  entry.setMethod(ZipEntry.STORED);
  entry.setSize(lib.length());
  entry.setCrc(calculateCrc(lib.toPath()));
  
  zOs.putNextEntry(entry);
  
  Files.copy(lib.toPath(), zOs);
 }
}

代码示例来源: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: 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: gradle.plugin.com.triplequote.gradle/hydra

Set<File> jars = project.getConfigurations().getByName(HYDRA_DASHBOARD_CONFIGURATION).resolve();
List<String> classpath = new ArrayList<>();
jars.forEach(dependency -> classpath.add(dependency.getAbsolutePath()));

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

@Override
protected FileSignature calculateState() throws Exception {
  Set<File> files = new LinkedHashSet<>();
  for (Object o : projConfigMaven) {
    if (o instanceof Project) {
      Project project = (Project) o;
      Jar jar = taskFor(project);
      files.add(jar.getArchivePath());
      files.addAll(project.getConfigurations().getByName(JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME).resolve());
    } else if (o instanceof Configuration) {
      Configuration config = (Configuration) o;
      files.addAll(config.resolve());
    } else if (o instanceof String) {
      String mavenCoord = (String) o;
      Dependency dep = setupTask.getProject().getDependencies().create(mavenCoord);
      files.addAll(setupTask.getProject().getConfigurations()
          .detachedConfiguration(dep)
          .setDescription(mavenCoord)
          .setTransitive(false)
          .resolve());
    } else {
      throw Unhandled.classException(o);
    }
  }
  return FileSignature.signAsList(files);
}

代码示例来源:origin: gradle.plugin.com.github.SeelabFhdo/CodeGeneratorPlugin

try {
  Configuration byName = project.getConfigurations().getByName("compileOnly");
  resolve = byName.resolve();
} catch (Exception ex) {
  log.debug("Error while resolving compileOnly", ex);

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

@Override
  public void execute(DesugarTask desugarTask) {
    String bcp = System.getProperty("sun.boot.class.path");
    desugarTask.androidJarClasspath = () -> androidExtension.getProject().getConfigurations().getByName("androidBootclasspath").resolve();
    if (bcp != null) {
      desugarTask.compilationBootclasspath = PathUtils.getClassPathItems(System.getProperty("sun.boot.class.path"));
    } else {
      desugarTask.compilationBootclasspath = Collections.emptyList();
    }
    desugarTask.userCache = androidExtension.getBuildCache();
    desugarTask.setMinSdk(Integer.parseInt(androidExtension.getMinSdkVersion()));
    desugarTask.androidRuntime = androidExtension.getProject().getConfigurations().getByName("androidRuntime");
    desugarTask.setInputDir(inputLocation);
    desugarTask.setTmpDir(androidExtension.getTemporaryDirectory());
    desugarTask.setOutputDir(outputLocation);
    desugarTask.verbose = androidExtension.getProject().getLogger().isInfoEnabled();
    desugarTask.executor = androidExtension.getAndroidBuilder().getJavaProcessExecutor();
  }
}

相关文章