use of com.android.tools.idea.gradle.project.subset.ProjectSubset in project android by JetBrains.
the class DependencySetupErrors method reportModulesNotFoundIssues.
private void reportModulesNotFoundIssues(@NotNull List<MissingModule> missingModules) {
if (!missingModules.isEmpty()) {
MessageType type = ERROR;
for (MissingModule missingModule : missingModules) {
List<String> messageLines = new ArrayList<>();
StringBuilder text = new StringBuilder();
text.append(String.format("Unable to find module with Gradle path '%1$s' (needed by module", missingModule.dependencyPath));
addDependentsToText(text, missingModule.dependentNames);
text.append(".)");
messageLines.add(text.toString());
String backupLibraryName = missingModule.backupLibraryName;
if (isNotEmpty(backupLibraryName)) {
type = WARNING;
String msg = String.format("Linking to library '%1$s' instead.", backupLibraryName);
messageLines.add(msg);
}
mySyncMessages.report(new SyncMessage(MISSING_DEPENDENCIES, type, toStringArray(messageLines)));
}
// If the project is really a subset of the project, attempt to find and include missing modules.
ProjectSubset projectSubset = ProjectSubset.getInstance(myProject);
String[] selection = projectSubset.getSelection();
boolean hasSelection = selection != null && selection.length > 0;
if (type == ERROR && hasSelection && projectSubset.hasCachedModules()) {
String text = "The missing modules may have been excluded from the project subset.";
SyncMessage message = new SyncMessage(MISSING_DEPENDENCIES, MessageType.INFO, text);
message.add(new IncludeMissingModulesHyperlink(missingModules));
mySyncMessages.report(message);
}
}
}
use of com.android.tools.idea.gradle.project.subset.ProjectSubset in project android by JetBrains.
the class UniquePathModuleValidatorStrategyTest method testFixAndReportFoundIssuesWithUniquePaths.
public void testFixAndReportFoundIssuesWithUniquePaths() throws Exception {
Project project = getProject();
SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(project);
ProjectSubset projectSubset = IdeComponents.replaceServiceWithMock(project, ProjectSubset.class);
when(projectSubset.isFeatureEnabled()).thenReturn(false);
Multimap<String, Module> modulesByPath = myStrategy.getModulesByPath();
modulesByPath.putAll("path1", Lists.newArrayList(myModule1));
modulesByPath.putAll("path2", Lists.newArrayList(myModule2));
myStrategy.fixAndReportFoundIssues();
SyncMessage message = syncMessages.getFirstReportedMessage();
assertNull(message);
}
use of com.android.tools.idea.gradle.project.subset.ProjectSubset in project android by JetBrains.
the class Projects method getModulesToImport.
@NotNull
private static Collection<DataNode<ModuleData>> getModulesToImport(@NotNull Project project, @NotNull DataNode<ProjectData> projectInfo, boolean selectModulesToImport) {
Collection<DataNode<ModuleData>> modules = findAll(projectInfo, ProjectKeys.MODULE);
ProjectSubset subview = ProjectSubset.getInstance(project);
if (!ApplicationManager.getApplication().isUnitTestMode() && ProjectSubset.getInstance(project).isFeatureEnabled() && modules.size() > 1) {
if (selectModulesToImport) {
// Importing a project. Allow user to select which modules to include in the project.
Collection<DataNode<ModuleData>> selection = subview.showModuleSelectionDialog(modules);
if (selection != null) {
return selection;
}
} else {
// We got here because a project was synced with Gradle. Make sure that we don't add any modules that were not selected during
// project import (if applicable.)
String[] persistedModuleNames = subview.getSelection();
if (persistedModuleNames != null) {
int moduleCount = persistedModuleNames.length;
if (moduleCount > 0) {
List<String> moduleNames = Lists.newArrayList(persistedModuleNames);
List<DataNode<ModuleData>> selectedModules = Lists.newArrayListWithExpectedSize(moduleCount);
for (DataNode<ModuleData> module : modules) {
String name = module.getData().getExternalName();
if (moduleNames.contains(name)) {
selectedModules.add(module);
}
}
return selectedModules;
}
}
}
}
// Delete any stored module selection.
subview.clearSelection();
// Import all modules, not just subset.
return modules;
}
use of com.android.tools.idea.gradle.project.subset.ProjectSubset in project android by JetBrains.
the class UniquePathModuleValidatorStrategyTest method testFixAndReportFoundIssues.
public void testFixAndReportFoundIssues() throws Exception {
Project project = getProject();
SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(project);
ProjectSubset projectSubset = IdeComponents.replaceServiceWithMock(project, ProjectSubset.class);
when(projectSubset.isFeatureEnabled()).thenReturn(false);
Multimap<String, Module> modulesByPath = myStrategy.getModulesByPath();
modulesByPath.putAll("path", Lists.newArrayList(myModule1, myModule2));
when(myModule1.getName()).thenReturn("module1");
when(myModule2.getName()).thenReturn("module2");
myStrategy.fixAndReportFoundIssues();
SyncMessage message = syncMessages.getFirstReportedMessage();
assertNotNull(message);
assertAbout(syncMessage()).that(message).hasMessageLine("The modules ['module1', 'module2'] point to same directory in the file system.", 0);
}
Aggregations