use of com.android.tools.idea.gradle.AndroidGradleModel in project kotlin by JetBrains.
the class IntellijLintProject method createModuleProject.
/** Creates a new module project */
@Nullable
private static LintModuleProject createModuleProject(@NonNull LintClient client, @NonNull Module module) {
AndroidFacet facet = AndroidFacet.getInstance(module);
File dir;
if (facet != null) {
final VirtualFile mainContentRoot = AndroidRootUtil.getMainContentRoot(facet);
if (mainContentRoot == null) {
return null;
}
dir = new File(FileUtil.toSystemDependentName(mainContentRoot.getPath()));
} else {
String moduleDirPath = AndroidRootUtil.getModuleDirPath(module);
if (moduleDirPath == null) {
return null;
}
dir = new File(FileUtil.toSystemDependentName(moduleDirPath));
}
LintModuleProject project = null;
if (facet == null) {
project = new LintModuleProject(client, dir, dir, module);
AndroidFacet f = findAndroidFacetInProject(module.getProject());
if (f != null) {
project.mGradleProject = f.requiresAndroidModel();
}
} else if (facet.requiresAndroidModel()) {
AndroidModel androidModel = facet.getAndroidModel();
if (androidModel instanceof AndroidGradleModel) {
project = new LintGradleProject(client, dir, dir, facet, (AndroidGradleModel) androidModel);
} else {
project = new LintAndroidModelProject(client, dir, dir, facet, androidModel);
}
} else {
project = new LintAndroidProject(client, dir, dir, facet);
}
if (project != null) {
client.registerProject(dir, project);
}
return project;
}
use of com.android.tools.idea.gradle.AndroidGradleModel in project kotlin by JetBrains.
the class IntellijLintProject method addProjects.
/**
* Recursively add lint projects for the given module, and any other module or library it depends on, and also
* populate the reverse maps so we can quickly map from a lint project to a corresponding module/library (used
* by the lint client
*/
private static void addProjects(@NonNull LintClient client, @NonNull Module module, @Nullable List<VirtualFile> files, @NonNull Map<Module, Project> moduleMap, @NonNull Map<AndroidLibrary, Project> libraryMap, @NonNull Map<Project, Module> projectMap, @NonNull List<Project> projects) {
if (moduleMap.containsKey(module)) {
return;
}
LintModuleProject project = createModuleProject(client, module);
if (project == null) {
// It's possible for the module to *depend* on Android code, e.g. in a Gradle
// project there will be a top-level non-Android module
List<AndroidFacet> dependentFacets = AndroidUtils.getAllAndroidDependencies(module, false);
for (AndroidFacet dependentFacet : dependentFacets) {
addProjects(client, dependentFacet.getModule(), files, moduleMap, libraryMap, projectMap, projects);
}
return;
}
projects.add(project);
moduleMap.put(module, project);
projectMap.put(project, module);
if (processFileFilter(module, files, project)) {
// No need to process dependencies when doing single file analysis
return;
}
List<Project> dependencies = Lists.newArrayList();
// No, this shouldn't use getAllAndroidDependencies; we may have non-Android dependencies that this won't include
// (e.g. Java-only modules)
List<AndroidFacet> dependentFacets = AndroidUtils.getAllAndroidDependencies(module, true);
for (AndroidFacet dependentFacet : dependentFacets) {
Project p = moduleMap.get(dependentFacet.getModule());
if (p != null) {
dependencies.add(p);
} else {
addProjects(client, dependentFacet.getModule(), files, moduleMap, libraryMap, projectMap, dependencies);
}
}
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
AndroidGradleModel androidGradleModel = AndroidGradleModel.get(facet);
if (androidGradleModel != null) {
addGradleLibraryProjects(client, files, libraryMap, projects, facet, androidGradleModel, project, projectMap, dependencies);
}
}
project.setDirectLibraries(dependencies);
}
Aggregations