use of com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec 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