use of com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel in project android by JetBrains.
the class GradleProjectDependencyParser method parse.
@NotNull
private static Set<String> parse(@NotNull VirtualFile moduleRoot, @NotNull Project project) {
VirtualFile buildFile = moduleRoot.findChild(FN_BUILD_GRADLE);
if (buildFile == null) {
return Collections.emptySet();
} else {
Set<String> result = Sets.newHashSet();
GradleBuildModel buildModel = parseBuildFile(buildFile, project);
DependenciesModel dependenciesModel = buildModel.dependencies();
if (dependenciesModel != null) {
for (ModuleDependencyModel dependency : dependenciesModel.modules()) {
String modulePath = dependency.path().value();
result.add(modulePath);
}
}
return result;
}
}
use of com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel in project android by JetBrains.
the class PsAndroidDependencyCollection method addModule.
private void addModule(@NotNull String gradlePath, @NotNull PsAndroidArtifact artifact, @Nullable String projectVariant) {
PsParsedDependencies parsedDependencies = myParent.getParsedDependencies();
ModuleDependencyModel matchingParsedDependency = parsedDependencies.findModuleDependency(gradlePath, artifact::contains);
Module resolvedModule = null;
PsModule module = myParent.getParent().findModuleByGradlePath(gradlePath);
if (module != null) {
resolvedModule = module.getResolvedModel();
}
PsModuleAndroidDependency dependency = findElement(gradlePath, PsModuleAndroidDependency.class);
if (dependency == null) {
dependency = new PsModuleAndroidDependency(myParent, gradlePath, artifact, projectVariant, resolvedModule, matchingParsedDependency);
myModuleDependenciesByGradlePath.put(gradlePath, dependency);
}
updateDependency(dependency, artifact, matchingParsedDependency);
}
use of com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel in project android by JetBrains.
the class PsParsedDependencies method reset.
void reset(@Nullable GradleBuildModel parsedModel) {
myParsedArtifactDependencies.clear();
myParsedModuleDependencies.clear();
if (parsedModel != null) {
ApplicationManager.getApplication().runReadAction(() -> {
for (DependencyModel parsedDependency : parsedModel.dependencies().all()) {
if (parsedDependency instanceof ArtifactDependencyModel) {
ArtifactDependencyModel artifact = (ArtifactDependencyModel) parsedDependency;
myParsedArtifactDependencies.put(createIdFrom(artifact), artifact);
} else if (parsedDependency instanceof ModuleDependencyModel) {
ModuleDependencyModel module = (ModuleDependencyModel) parsedDependency;
myParsedModuleDependencies.put(module.path().value(), module);
}
}
});
}
}
use of com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel in project android by JetBrains.
the class GradleBuildModelFixture method requireDependency.
public void requireDependency(@NotNull ExpectedModuleDependency expected) {
DependenciesModel dependenciesModel = myTarget.dependencies();
for (final ModuleDependencyModel dependency : dependenciesModel.modules()) {
String path = GuiQuery.getNonNull(() -> dependency.path().value());
if (expected.path.equals(path) && expected.configurationName.equals(dependency.configurationName())) {
return;
}
}
fail("Failed to find dependency '" + expected.path + "'");
}
Aggregations