Search in sources :

Example 1 with PsProject

use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.

the class PsAndroidModuleTest method testEditableDependenciesWithPlusInVersion.

public void testEditableDependenciesWithPlusInVersion() throws Throwable {
    loadProject(PROJECT_WITH_APPAND_LIB);
    Project resolvedProject = myFixture.getProject();
    PsProject project = new PsProject(resolvedProject);
    PsAndroidModule appModule = (PsAndroidModule) project.findModuleByName("app");
    assertNotNull(appModule);
    List<PsAndroidDependency> declaredDependencies = getDeclaredDependencies(appModule);
    assertThat(declaredDependencies).hasSize(1);
    // Verify that appcompat is considered a "editable" dependency, and it was matched properly
    PsLibraryAndroidDependency appCompatV7 = (PsLibraryAndroidDependency) declaredDependencies.get(0);
    assertTrue(appCompatV7.isDeclared());
    PsArtifactDependencySpec declaredSpec = appCompatV7.getDeclaredSpec();
    assertNotNull(declaredSpec);
    assertEquals("com.android.support:appcompat-v7:+", declaredSpec.toString());
    PsArtifactDependencySpec resolvedSpec = appCompatV7.getResolvedSpec();
    assertEquals("com.android.support", resolvedSpec.group);
    assertEquals("appcompat-v7", resolvedSpec.name);
    assertThat(resolvedSpec.version).isNotEqualTo("+");
    // Verify that the variants where appcompat is are properly registered.
    Collection<String> variants = appCompatV7.getVariants();
    assertThat(variants).containsExactly("paidDebug", "paidRelease", "basicDebug", "basicRelease");
    for (String variant : variants) {
        assertNotNull(appModule.findVariant(variant));
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsArtifactDependencySpec(com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)

Example 2 with PsProject

use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.

the class PsAndroidModuleTest method testCanDependOnModules.

public void testCanDependOnModules() throws Throwable {
    loadProject(PROJECT_WITH_APPAND_LIB);
    Project resolvedProject = myFixture.getProject();
    PsProject project = new PsProject(resolvedProject);
    PsAndroidModule appModule = (PsAndroidModule) project.findModuleByName("app");
    assertNotNull(appModule);
    PsAndroidModule libModule = (PsAndroidModule) project.findModuleByName("lib");
    assertNotNull(libModule);
    assertTrue(appModule.canDependOn(libModule));
    assertFalse(libModule.canDependOn(appModule));
}
Also used : Project(com.intellij.openapi.project.Project) PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsProject(com.android.tools.idea.gradle.structure.model.PsProject)

Example 3 with PsProject

use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.

the class PsAndroidModuleTest method testProductFlavors.

public void testProductFlavors() throws Throwable {
    loadProject(PROJECT_WITH_APPAND_LIB);
    Project resolvedProject = myFixture.getProject();
    PsProject project = new PsProject(resolvedProject);
    PsAndroidModule appModule = (PsAndroidModule) project.findModuleByName("app");
    assertNotNull(appModule);
    List<PsProductFlavor> productFlavors = getProductFlavors(appModule);
    assertThat(productFlavors).hasSize(2);
    PsProductFlavor basic = appModule.findProductFlavor("basic");
    assertNotNull(basic);
    assertTrue(basic.isDeclared());
    PsProductFlavor release = appModule.findProductFlavor("paid");
    assertNotNull(release);
    assertTrue(release.isDeclared());
}
Also used : Project(com.intellij.openapi.project.Project) PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsProject(com.android.tools.idea.gradle.structure.model.PsProject)

Example 4 with PsProject

use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.

the class ModuleDependenciesForm method getModuleDependencies.

@NotNull
private static List<PsModule> getModuleDependencies(@NotNull PsModule module) {
    PsProject project = module.getParent();
    List<PsModule> dependencies = Lists.newArrayList();
    if (module instanceof PsAndroidModule) {
        ((PsAndroidModule) module).forEachModuleDependency(dependency -> {
            String name = dependency.getName();
            PsModule found = project.findModuleByName(name);
            if (found != null) {
                dependencies.add(found);
            }
        });
    }
    return dependencies;
}
Also used : PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsModule(com.android.tools.idea.gradle.structure.model.PsModule) PsAndroidModule(com.android.tools.idea.gradle.structure.model.android.PsAndroidModule) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with PsProject

use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.

the class DependenciesPerspectiveConfigurable method getExtraTopModules.

@Override
@NotNull
protected List<PsModule> getExtraTopModules() {
    if (myExtraTopModules.isEmpty()) {
        PsProject project = getContext().getProject();
        myExtraTopModules.add(new PsAllModulesFakeModule(project));
    }
    return myExtraTopModules;
}
Also used : PsProject(com.android.tools.idea.gradle.structure.model.PsProject) PsAllModulesFakeModule(com.android.tools.idea.gradle.structure.configurables.android.dependencies.PsAllModulesFakeModule) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsProject (com.android.tools.idea.gradle.structure.model.PsProject)8 Project (com.intellij.openapi.project.Project)5 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)2 PsModule (com.android.tools.idea.gradle.structure.model.PsModule)2 PsAndroidModule (com.android.tools.idea.gradle.structure.model.android.PsAndroidModule)2 NotNull (org.jetbrains.annotations.NotNull)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)1 PsAllModulesFakeModule (com.android.tools.idea.gradle.structure.configurables.android.dependencies.PsAllModulesFakeModule)1 Module (com.intellij.openapi.module.Module)1 File (java.io.File)1