use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.
the class ModuleDependencyNode method setUp.
private void setUp(@NotNull PsModuleAndroidDependency moduleDependency) {
myName = moduleDependency.toText(PLAIN_TEXT);
PsAndroidModule dependentModule = moduleDependency.getParent();
PsProject project = dependentModule.getParent();
PsModule referred = project.findModuleByGradlePath(moduleDependency.getGradlePath());
if (referred instanceof PsAndroidModule) {
PsAndroidModule androidModule = (PsAndroidModule) referred;
androidModule.forEachDependency(dependency -> {
if (!dependency.isDeclared()) {
return;
}
String moduleVariant = moduleDependency.getConfigurationName();
if (!dependency.isIn(ARTIFACT_MAIN, moduleVariant)) {
return;
}
AbstractPsModelNode<?> child = AbstractDependencyNode.createNode(this, dependency);
if (child != null) {
myChildren.add(child);
}
});
}
}
use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.
the class PsAndroidModuleTest method testVariants.
public void testVariants() throws Throwable {
loadProject(PROJECT_WITH_APPAND_LIB);
Project resolvedProject = myFixture.getProject();
PsProject project = new PsProject(resolvedProject);
PsAndroidModule appModule = (PsAndroidModule) project.findModuleByName("app");
assertNotNull(appModule);
Collection<PsVariant> variants = getVariants(appModule);
assertThat(variants).hasSize(4);
PsVariant paidDebug = appModule.findVariant("paidDebug");
assertNotNull(paidDebug);
List<String> flavors = paidDebug.getProductFlavors();
assertThat(flavors).containsExactly("paid");
PsVariant paidRelease = appModule.findVariant("paidRelease");
assertNotNull(paidRelease);
flavors = paidRelease.getProductFlavors();
assertThat(flavors).containsExactly("paid");
PsVariant basicDebug = appModule.findVariant("basicDebug");
assertNotNull(basicDebug);
flavors = basicDebug.getProductFlavors();
assertThat(flavors).containsExactly("basic");
PsVariant basicRelease = appModule.findVariant("basicRelease");
assertNotNull(basicRelease);
flavors = basicRelease.getProductFlavors();
assertThat(flavors).containsExactly("basic");
}
use of com.android.tools.idea.gradle.structure.model.PsProject in project android by JetBrains.
the class PsAndroidModuleTest method testEditableDependencies.
public void testEditableDependencies() throws Throwable {
loadProject(PROJECT_WITH_APPAND_LIB);
Project resolvedProject = myFixture.getProject();
Module appModule = ModuleManager.getInstance(resolvedProject).findModuleByName("app");
assertNotNull(appModule);
// Make sure 'app' has an artifact dependency with version not including a '+'
GradleBuildModel buildModel = GradleBuildModel.get(appModule);
assertNotNull(buildModel);
for (ArtifactDependencyModel dependency : buildModel.dependencies().artifacts("compile")) {
if ("com.android.support".equals(dependency.group().value()) && "appcompat-v7".equals(dependency.name().value())) {
dependency.setVersion("23.1.1");
break;
}
}
runWriteCommandAction(resolvedProject, buildModel::applyChanges);
//noinspection ConstantConditions
importProject(resolvedProject.getName(), new File(resolvedProject.getBasePath()), null);
PsProject project = new PsProject(resolvedProject);
PsAndroidModule module = (PsAndroidModule) project.findModuleByName("app");
assertNotNull(module);
List<PsAndroidDependency> declaredDependencies = getDeclaredDependencies(module);
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 resolvedSpec = appCompatV7.getResolvedSpec();
assertEquals("com.android.support", resolvedSpec.group);
assertEquals("appcompat-v7", resolvedSpec.name);
// 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(module.findVariant(variant));
}
}
Aggregations