Java Code Examples for org.gradle.api.artifacts.Configuration#resolve()
The following examples show how to use
org.gradle.api.artifacts.Configuration#resolve() .
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: RetrolambdaExec.java From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()); }
Example 2
Source File: GradlePackageTask.java From baratine with GNU General Public License v2.0 | 5 votes |
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); } }
Example 3
Source File: DependencyResolvingClasspathProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ClassPath create() { Configuration configuration = dependencyResolutionServices.getConfigurationContainer().detachedConfiguration(dependency); repositoriesConfigurer.execute(dependencyResolutionServices.getResolveRepositoryHandler()); return new DefaultClassPath(configuration.resolve()); }
Example 4
Source File: GenerateProtoTask.java From curiostack with MIT License | 4 votes |
private Map<String, File> downloadTools(List<String> artifacts) { RepositoryHandler repositories = getProject().getRepositories(); List<ArtifactRepository> currentRepositories = ImmutableList.copyOf(repositories); // Make sure Maven Central is present as a repository since it's the usual place to // get protoc, even for non-Java projects. We restore to the previous state after the task. repositories.mavenCentral(); List<Dependency> dependencies = artifacts.stream() .map( artifact -> { checkArgument(!artifact.isEmpty(), "artifact must not be empty"); List<String> coordinateParts = COORDINATE_SPLITTER.splitToList(artifact); List<String> artifactParts = ARTIFACT_SPLITTER.splitToList(coordinateParts.get(0)); ImmutableMap.Builder<String, String> depParts = ImmutableMap.builderWithExpectedSize(5); // Do a loose matching to allow for the possibility of dependency management // manipulation. if (artifactParts.size() > 0) { depParts.put("group", artifactParts.get(0)); } if (artifactParts.size() > 1) { depParts.put("name", artifactParts.get(1)); } if (artifactParts.size() > 2) { depParts.put("version", artifactParts.get(2)); } if (artifactParts.size() > 3) { depParts.put("classifier", artifactParts.get(3)); } else { depParts.put( "classifier", getProject().getExtensions().getByType(OsDetector.class).getClassifier()); } if (coordinateParts.size() > 1) { depParts.put("ext", coordinateParts.get(1)); } else { depParts.put("ext", "exe"); } return getProject().getDependencies().create(depParts.build()); }) .collect(toImmutableList()); Configuration configuration = getProject().getConfigurations().getByName("protobufTools"); configuration.getDependencies().addAll(dependencies); // Resolve once to download all tools in parallel. configuration.resolve(); // This will not re-download. ResolvedConfiguration resolved = configuration.getResolvedConfiguration(); Map<String, File> downloaded = Streams.zip( artifacts.stream(), dependencies.stream(), (artifact, dep) -> { Set<File> files = resolved.getFiles( d -> { // Dependency.contentEquals doesn't match for some reason... return Objects.equals(dep.getGroup(), d.getGroup()) && dep.getName().equals(d.getName()) && Objects.equals(dep.getVersion(), d.getVersion()); }); checkState(files.size() == 1); File file = Iterables.getOnlyElement(files); if (!file.canExecute()) { if (!file.setExecutable(true)) { throw new IllegalStateException( "Could not set proto tool to executable: " + file.getAbsolutePath()); } } return new SimpleImmutableEntry<>(artifact, file); }) .collect(toImmutableMap(Entry::getKey, Entry::getValue)); repositories.clear(); repositories.addAll(currentRepositories); return downloaded; }
Example 5
Source File: DependencyResolvingClasspathProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ClassPath create() { Configuration configuration = dependencyResolutionServices.getConfigurationContainer().detachedConfiguration(dependency); repositoriesConfigurer.execute(dependencyResolutionServices.getResolveRepositoryHandler()); return new DefaultClassPath(configuration.resolve()); }