Search in sources :

Example 1 with ModuleDependencyModel

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;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ModuleDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel) DependenciesModel(com.android.tools.idea.gradle.dsl.model.dependencies.DependenciesModel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ModuleDependencyModel

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);
}
Also used : PsModule(com.android.tools.idea.gradle.structure.model.PsModule) ModuleDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel) PsParsedDependencies(com.android.tools.idea.gradle.structure.model.PsParsedDependencies) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) Module(com.intellij.openapi.module.Module)

Example 3 with ModuleDependencyModel

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);
                }
            }
        });
    }
}
Also used : ModuleDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel) ArtifactDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel) DependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.DependencyModel) ArtifactDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel) ModuleDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel)

Example 4 with ModuleDependencyModel

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 + "'");
}
Also used : ModuleDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel) DependenciesModel(com.android.tools.idea.gradle.dsl.model.dependencies.DependenciesModel)

Aggregations

ModuleDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ModuleDependencyModel)4 DependenciesModel (com.android.tools.idea.gradle.dsl.model.dependencies.DependenciesModel)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)1 DependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.DependencyModel)1 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)1 PsParsedDependencies (com.android.tools.idea.gradle.structure.model.PsParsedDependencies)1 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NotNull (org.jetbrains.annotations.NotNull)1