use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class GradleBuildInvoker method generateSources.
public void generateSources(boolean cleanProject) {
BuildMode buildMode = SOURCE_GEN;
setProjectBuildMode(buildMode);
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
List<String> tasks = findTasksToExecute(moduleManager.getModules(), buildMode, TestCompileType.NONE);
if (cleanProject) {
tasks.add(0, CLEAN_TASK_NAME);
}
executeTasks(tasks, Collections.singletonList(createGenerateSourcesOnlyProperty()));
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class MakeBeforeRunTaskProvider method createAvailableTasks.
private List<String> createAvailableTasks() {
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
List<String> gradleTasks = Lists.newArrayList();
for (Module module : moduleManager.getModules()) {
GradleFacet facet = GradleFacet.getInstance(module);
if (facet == null) {
continue;
}
GradleModuleModel gradleModuleModel = facet.getGradleModuleModel();
if (gradleModuleModel == null) {
continue;
}
gradleTasks.addAll(gradleModuleModel.getTaskNames());
}
return gradleTasks;
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class ThemeEditorUtils method findAndroidModules.
@NotNull
public static ImmutableList<Module> findAndroidModules(@NotNull Project project) {
final ModuleManager manager = ModuleManager.getInstance(project);
final ImmutableList.Builder<Module> builder = ImmutableList.builder();
for (Module module : manager.getModules()) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
builder.add(module);
}
}
return builder.build();
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class ConflictSet method findConflicts.
@NotNull
public static ConflictSet findConflicts(@NotNull Project project) {
Map<String, Conflict> selectionConflicts = Maps.newHashMap();
Map<String, Conflict> structureConflicts = Maps.newHashMap();
ModuleManager moduleManager = ModuleManager.getInstance(project);
for (Module module : moduleManager.getModules()) {
AndroidModuleModel currentAndroidModel = AndroidModuleModel.get(module);
if (currentAndroidModel == null || currentAndroidModel.getProjectType() == PROJECT_TYPE_APP) {
continue;
}
String gradlePath = GradleUtil.getGradlePath(module);
if (gradlePath == null) {
continue;
}
String selectedVariant = currentAndroidModel.getSelectedVariant().getName();
for (Module dependent : ModuleUtilCore.getAllDependentModules(module)) {
AndroidModuleModel dependentAndroidModel = AndroidModuleModel.get(dependent);
if (dependentAndroidModel == null) {
continue;
}
String expectedVariant = getExpectedVariant(dependentAndroidModel, gradlePath);
if (StringUtil.isEmpty(expectedVariant)) {
continue;
}
addConflict(structureConflicts, module, selectedVariant, dependent, expectedVariant);
if (!selectedVariant.equals(expectedVariant)) {
addConflict(selectionConflicts, module, selectedVariant, dependent, expectedVariant);
}
}
}
// Structural conflicts are the ones that have more than one group of modules depending on different variants of another module.
List<Conflict> filteredStructureConflicts = Lists.newArrayList();
for (Conflict conflict : structureConflicts.values()) {
if (conflict.getVariants().size() > 1) {
filteredStructureConflicts.add(conflict);
}
}
return new ConflictSet(project, selectionConflicts.values(), filteredStructureConflicts);
}
use of com.intellij.openapi.module.ModuleManager in project android by JetBrains.
the class ModuleVariantsInfoDialog method createDependentsTree.
@NotNull
private static JTree createDependentsTree(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
VariantCheckboxTreeCellRenderer renderer = new VariantCheckboxTreeCellRenderer() {
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof DefaultMutableTreeNode) {
Object data = ((DefaultMutableTreeNode) value).getUserObject();
if (data instanceof String) {
appendVariant((String) data);
} else if (data instanceof DependentTreeElement) {
DependentTreeElement dependent = (DependentTreeElement) data;
String variant = null;
if (!dependent.myVariants.isEmpty()) {
variant = Joiner.on(", ").join(dependent.myVariants);
}
appendModule(dependent.myModule, variant);
}
}
}
};
//noinspection ConstantConditions
CheckedTreeNode root = new CheckedTreeNode(null);
AndroidProject androidProject = GradleUtil.getAndroidProject(module);
assert androidProject != null;
String gradlePath = GradleUtil.getGradlePath(module);
assert gradlePath != null;
Multimap<String, DependentTreeElement> dependentsByVariant = HashMultimap.create();
ModuleManager moduleManager = ModuleManager.getInstance(module.getProject());
for (Module dependent : moduleManager.getModuleDependentModules(module)) {
AndroidProject dependentProject = GradleUtil.getAndroidProject(dependent);
if (dependentProject == null) {
continue;
}
DependentTreeElement element = new DependentTreeElement(dependent);
for (Variant variant : dependentProject.getVariants()) {
for (AndroidLibrary library : GradleUtil.getDirectLibraryDependencies(variant, androidModel)) {
if (gradlePath.equals(library.getProject())) {
element.addVariant(variant.getName());
String projectVariant = library.getProjectVariant();
if (StringUtil.isNotEmpty(projectVariant)) {
dependentsByVariant.put(projectVariant, element);
}
}
}
}
}
List<String> variantNames = Lists.newArrayList(dependentsByVariant.keySet());
Collections.sort(variantNames);
for (String variantName : variantNames) {
Collection<DependentTreeElement> dependents = dependentsByVariant.get(variantName);
if (!dependents.isEmpty()) {
List<DependentTreeElement> sortedDependents = Lists.newArrayList(dependents);
Collections.sort(sortedDependents);
DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(variantName);
for (DependentTreeElement dependent : dependents) {
variantNode.add(new DefaultMutableTreeNode(dependent));
}
root.add(variantNode);
}
}
CheckboxTree tree = new CheckboxTree(renderer, root);
tree.setRootVisible(false);
TreeUtil.expandAll(tree);
return tree;
}
Aggregations