use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class BuildVariantUpdater method ensureVariantIsSelected.
private void ensureVariantIsSelected(@NotNull Project project, @NotNull String moduleGradlePath, @NotNull String variant, @NotNull List<AndroidFacet> affectedFacets) {
Module module = findModuleByGradlePath(project, moduleGradlePath);
if (module == null) {
logAndShowUpdateFailure(variant, String.format("Cannot find module with Gradle path '%1$s'.", moduleGradlePath));
return;
}
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null) {
logAndShowUpdateFailure(variant, String.format("Cannot find 'Android' facet in module '%1$s'.", module.getName()));
return;
}
AndroidModuleModel androidModel = getAndroidModel(facet, variant);
if (androidModel == null) {
return;
}
if (!updateSelectedVariant(facet, androidModel, variant, affectedFacets)) {
return;
}
affectedFacets.add(facet);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class BuildVariantView method getVariantNames.
@Nullable
private static Collection<String> getVariantNames(@NotNull Module module) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
return androidModel.getVariantNames();
}
NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
if (ndkModuleModel != null) {
return ndkModuleModel.getVariantNames();
}
return null;
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidTestRunConfiguration method findInstrumentationRunner.
@Nullable
public static String findInstrumentationRunner(@NotNull AndroidFacet facet) {
String runner = getRunnerFromManifest(facet);
// TODO: Resolve direct AndroidGradleModel dep (b/22596984)
AndroidModuleModel androidModel = AndroidModuleModel.get(facet);
if (runner == null && androidModel != null) {
Variant selectedVariant = androidModel.getSelectedVariant();
String testRunner = selectedVariant.getMergedFlavor().getTestInstrumentationRunner();
if (testRunner != null) {
runner = testRunner;
}
}
return runner;
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidGradleClassJarProvider method findModuleClassFile.
@Override
@Nullable
public VirtualFile findModuleClassFile(@NotNull String className, @NotNull Module module) {
AndroidModuleModel model = AndroidModuleModel.get(module);
if (model == null) {
return null;
}
VirtualFile outputDir = getCompilerOutputRoot(model);
if (outputDir == null) {
return null;
}
return ClassJarProvider.findClassFileInPath(outputDir, className);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class PsAndroidModuleAnalyzer method doAnalyze.
@Override
protected void doAnalyze(@NotNull PsAndroidModule module, @NotNull PsIssueCollection issueCollection) {
Multimap<String, SyncIssue> issuesByData = ArrayListMultimap.create();
AndroidModuleModel gradleModel = module.getGradleModel();
Collection<SyncIssue> syncIssues = gradleModel.getAndroidProject().getSyncIssues();
for (SyncIssue syncIssue : syncIssues) {
String data = nullToEmpty(syncIssue.getData());
issuesByData.put(data, syncIssue);
}
PsModulePath modulePath = new PsModulePath(module);
module.forEachDependency(dependency -> {
if (dependency instanceof PsLibraryDependency && dependency.isDeclared()) {
PsLibraryDependency libraryDependency = (PsLibraryDependency) dependency;
PsPath path = new PsLibraryDependencyNavigationPath(getContext(), libraryDependency);
PsArtifactDependencySpec resolvedSpec = libraryDependency.getResolvedSpec();
String issueKey = resolvedSpec.group + GRADLE_PATH_SEPARATOR + resolvedSpec.name;
Collection<SyncIssue> librarySyncIssues = issuesByData.get(issueKey);
for (SyncIssue syncIssue : librarySyncIssues) {
PsIssue issue = createIssueFrom(syncIssue, path, modulePath);
issueCollection.add(issue);
}
analyzeDeclaredDependency(libraryDependency, modulePath, issueCollection);
}
});
}
Aggregations