use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class TestArtifactSearchScopes method getSourceScope.
@NotNull
private FileRootSearchScope getSourceScope(@NotNull String artifactName) {
Set<File> roots = Collections.emptySet();
AndroidModuleModel androidModel = getAndroidModel();
if (androidModel != null) {
roots = new HashSet<>();
// TODO consider generated source
for (SourceProvider sourceProvider : androidModel.getTestSourceProviders(artifactName)) {
roots.addAll(getAllSourceFolders(sourceProvider));
}
}
return new FileRootSearchScope(myModule.getProject(), roots);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class TestArtifactSearchScopes method initializeScope.
/**
* Initialize the test scopes in the given module if the module is Gradle-based Android.
*
* @param module the given module.
*/
public static void initializeScope(@NotNull Module module) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
TestArtifactSearchScopes scopes = androidModel != null ? new TestArtifactSearchScopes(module) : null;
module.putUserData(SEARCH_SCOPES_KEY, scopes);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidRootUtil method getApkPath.
@Nullable
public static String getApkPath(@NotNull AndroidFacet facet) {
if (facet.requiresAndroidModel()) {
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(facet);
if (androidModuleModel != null) {
// For Android-Gradle projects, AndroidModel is not null.
AndroidArtifact mainArtifact = androidModuleModel.getMainArtifact();
AndroidArtifactOutput output = getOutput(mainArtifact);
File outputFile = output.getMainOutputFile().getOutputFile();
return outputFile.getAbsolutePath();
} else {
return null;
}
}
String path = facet.getProperties().APK_PATH;
if (path.length() == 0) {
return getOutputPackage(facet.getModule());
}
String moduleDirPath = getModuleDirPath(facet.getModule());
return moduleDirPath != null ? toSystemDependentName(moduleDirPath + path) : null;
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidGradleProjectResolverIdeaTest method testPopulateModuleContentRootsWithAndroidProject.
public void testPopulateModuleContentRootsWithAndroidProject() {
when(myVariantSelector.findVariantToSelect(myAndroidProject)).thenReturn(myAndroidProject.getFirstVariant());
ProjectData project = myProjectResolver.createProject();
DataNode<ProjectData> projectNode = new DataNode<>(PROJECT, project, null);
DataNode<ModuleData> moduleDataNode = myProjectResolver.createModule(myAndroidModuleModel, projectNode);
myProjectResolver.populateModuleContentRoots(myAndroidModuleModel, moduleDataNode);
// Verify module has AndroidGradleModel.
Collection<DataNode<AndroidModuleModel>> androidModelNodes = getChildren(moduleDataNode, ANDROID_MODEL);
assertThat(androidModelNodes).hasSize(1);
DataNode<AndroidModuleModel> androidModelNode = getFirstItem(androidModelNodes);
assertNotNull(androidModelNode);
assertSame(myAndroidProject, androidModelNode.getData().getAndroidProject());
// Verify module has IdeaGradleProject.
Collection<DataNode<GradleModuleModel>> gradleModelNodes = getChildren(moduleDataNode, GRADLE_MODULE_MODEL);
assertThat(gradleModelNodes).hasSize(1);
DataNode<GradleModuleModel> gradleModelNode = getFirstItem(gradleModelNodes);
assertNotNull(gradleModelNode);
assertEquals(myAndroidModuleModel.getGradleProject().getPath(), gradleModelNode.getData().getGradlePath());
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidModuleModelDataServiceTest method testImportData.
public void testImportData() throws Exception {
loadSimpleApplication();
Module appModule = myModules.getAppModule();
AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
assertNotNull(androidModel);
DataNode<AndroidModuleModel> dataNode = new DataNode<>(ANDROID_MODEL, androidModel, null);
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
myService.importData(Lists.newArrayList(dataNode), mock(ProjectData.class), project, modelsProvider);
verify(myModuleSetup).setUpModule(appModule, modelsProvider, androidModel, null, null);
verify(myValidator).validate(appModule, androidModel);
verify(myValidator).fixAndReportFoundIssues();
}
Aggregations