use of org.gradle.api.artifacts.Dependency in project atlas by alibaba.
the class TDependencyManager method gatherDependencies.
@NonNull
private DependencyContainer gatherDependencies(@NonNull Configuration configuration, @NonNull final VariantDependencies variantDeps, @NonNull Multimap<AndroidLibrary, Configuration> reverseLibMap, @NonNull Set<String> currentUnresolvedDependencies, @Nullable String testedProjectPath, @NonNull Set<String> artifactSet, @NonNull ScopeType scopeType) {
// collect the artifacts first.
Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts = Maps.newHashMap();
configuration = collectArtifacts(configuration, artifacts);
// keep a map of modules already processed so that we don't go through sections of the
// graph that have been seen elsewhere.
Map<ModuleVersionIdentifier, List<LibraryDependency>> foundLibraries = Maps.newHashMap();
Map<ModuleVersionIdentifier, List<JarDependency>> foundJars = Maps.newHashMap();
// get the graph for the Android and Jar dependencies. This does not include
// local jars.
List<LibraryDependency> libraryDependencies = Lists.newArrayList();
List<JarDependency> jarDependencies = Lists.newArrayList();
Set<? extends DependencyResult> dependencyResultSet = configuration.getIncoming().getResolutionResult().getRoot().getDependencies();
for (DependencyResult dependencyResult : dependencyResultSet) {
if (dependencyResult instanceof ResolvedDependencyResult) {
addDependency(((ResolvedDependencyResult) dependencyResult).getSelected(), variantDeps, configuration, libraryDependencies, jarDependencies, foundLibraries, foundJars, artifacts, reverseLibMap, currentUnresolvedDependencies, testedProjectPath, Collections.emptyList(), artifactSet, scopeType, false, /*forceProvided*/
0);
} else if (dependencyResult instanceof UnresolvedDependencyResult) {
ComponentSelector attempted = ((UnresolvedDependencyResult) dependencyResult).getAttempted();
if (attempted != null) {
currentUnresolvedDependencies.add(attempted.toString());
}
}
}
// also need to process local jar files, as they are not processed by the
// resolvedConfiguration result. This only includes the local jar files for this project.
List<JarDependency> localJars = Lists.newArrayList();
for (Dependency dependency : configuration.getAllDependencies()) {
if (dependency instanceof SelfResolvingDependency && !(dependency instanceof ProjectDependency)) {
Set<File> files = ((SelfResolvingDependency) dependency).resolve();
for (File localJarFile : files) {
if (DEBUG_DEPENDENCY) {
System.out.println("LOCAL " + configuration.getName() + ": " + localJarFile.getName());
}
// only accept local jar, no other types.
if (!localJarFile.getName().toLowerCase(Locale.getDefault()).endsWith(DOT_JAR)) {
variantDeps.getChecker().handleIssue(localJarFile.getAbsolutePath(), SyncIssue.TYPE_NON_JAR_LOCAL_DEP, SyncIssue.SEVERITY_ERROR, String.format("Project %s: Only Jar-type local dependencies are supported. Cannot handle: %s", project.getName(), localJarFile.getAbsolutePath()));
} else {
JarDependency localJar;
switch(scopeType) {
case PACKAGE:
localJar = new JarDependency(localJarFile);
artifactSet.add(computeVersionLessCoordinateKey(localJar.getResolvedCoordinates()));
break;
case COMPILE:
MavenCoordinates coord = JarDependency.getCoordForLocalJar(localJarFile);
boolean provided = !artifactSet.contains(computeVersionLessCoordinateKey(coord));
localJar = new JarDependency(localJarFile, ImmutableList.of(), coord, null, provided);
break;
case COMPILE_ONLY:
// if we only have the compile scope, ignore computation of the
// provided bits.
localJar = new JarDependency(localJarFile);
break;
default:
throw new RuntimeException("unsupported ProvidedComputationAction");
}
localJars.add(localJar);
}
}
}
}
return new DependencyContainerImpl(libraryDependencies, jarDependencies, localJars);
}
use of org.gradle.api.artifacts.Dependency in project atlas by alibaba.
the class DependencyManager method ensureConfigured.
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);
}
}
}
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class DefaultSelfResolvingDependencyTest method contentsAreEqualWhenFileSetsAreEqual.
@Test
public void contentsAreEqualWhenFileSetsAreEqual() {
SelfResolvingDependency equalDependency = new DefaultSelfResolvingDependency(source);
SelfResolvingDependency differentSource = new DefaultSelfResolvingDependency(context.mock(FileCollectionInternal.class, "other"));
Dependency differentType = context.mock(Dependency.class);
assertTrue(dependency.contentEquals(dependency));
assertTrue(dependency.contentEquals(equalDependency));
assertFalse(dependency.contentEquals(differentSource));
assertFalse(dependency.contentEquals(differentType));
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class CoffeeScriptBasePlugin method addJsConfiguration.
private Configuration addJsConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final CoffeeScriptExtension extension) {
Configuration configuration = configurations.create(CoffeeScriptExtension.JS_CONFIGURATION_NAME);
configuration.defaultDependencies(new Action<DependencySet>() {
@Override
public void execute(DependencySet configDependencies) {
String notation = CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_GROUP + ":" + CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js";
Dependency dependency = dependencies.create(notation);
configDependencies.add(dependency);
}
});
return configuration;
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class ArtifactRepositoryPluginResolver method exists.
/*
* Checks whether the implementation artifact exists in the backing artifact repository.
*/
private boolean exists(PluginRequestInternal request) {
Dependency dependency = resolution.getDependencyHandler().create(getMarkerDependency(request));
ConfigurationContainer configurations = resolution.getConfigurationContainer();
Configuration configuration = configurations.detachedConfiguration(dependency);
configuration.setTransitive(false);
return !configuration.getResolvedConfiguration().hasError();
}
Aggregations