use of org.gradle.api.artifacts.SelfResolvingDependency 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.SelfResolvingDependency 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.SelfResolvingDependency in project gradle by gradle.
the class DependencyClassPathNotationConverter method convert.
public void convert(DependencyFactory.ClassPathNotation notation, NotationConvertResult<? super SelfResolvingDependency> result) throws TypeConversionException {
SelfResolvingDependency dependency = internCache.get(notation);
if (dependency == null) {
internCacheWriteLock.lock();
try {
dependency = maybeCreateUnderLock(notation);
} finally {
internCacheWriteLock.unlock();
}
}
result.converted(dependency);
}
use of org.gradle.api.artifacts.SelfResolvingDependency in project gradle by gradle.
the class DependencyClassPathNotationConverter method maybeCreateUnderLock.
private SelfResolvingDependency maybeCreateUnderLock(DependencyFactory.ClassPathNotation notation) {
SelfResolvingDependency dependency = internCache.get(notation);
if (dependency == null) {
Collection<File> classpath = classPathRegistry.getClassPath(notation.name()).getAsFiles();
boolean runningFromInstallation = currentGradleInstallation.getInstallation() != null;
FileCollectionInternal files;
if (runningFromInstallation && notation.equals(GRADLE_API)) {
files = gradleApiFileCollection(classpath);
} else if (runningFromInstallation && notation.equals(GRADLE_TEST_KIT)) {
files = gradleTestKitFileCollection(classpath);
} else {
files = fileResolver.resolveFiles(classpath);
}
dependency = instantiator.newInstance(DefaultSelfResolvingDependency.class, new OpaqueComponentIdentifier(notation.displayName), files);
internCache.put(notation, dependency);
}
return dependency;
}
use of org.gradle.api.artifacts.SelfResolvingDependency in project gradle by gradle.
the class DefaultIdeDependencyResolver method getIdeLocalFileDependencies.
/**
* Gets IDE local file dependencies.
*
* @param configuration Configuration
* @return IDE local file dependencies
*/
public List<IdeLocalFileDependency> getIdeLocalFileDependencies(Configuration configuration) {
List<SelfResolvingDependency> externalDependencies = new ArrayList<SelfResolvingDependency>();
findAllExternalDependencies(externalDependencies, new ArrayList<Dependency>(), configuration);
List<IdeLocalFileDependency> ideLocalFileDependencies = new ArrayList<IdeLocalFileDependency>();
for (SelfResolvingDependency externalDependency : externalDependencies) {
Set<File> resolvedFiles = externalDependency.resolve(configuration.isTransitive());
for (File resolvedFile : resolvedFiles) {
IdeLocalFileDependency ideLocalFileDependency = new IdeLocalFileDependency(resolvedFile);
ideLocalFileDependencies.add(ideLocalFileDependency);
}
}
return ideLocalFileDependencies;
}
Aggregations