use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class ApplicationRunParameters method onModuleChanged.
public void onModuleChanged() {
Module currentModule = myModuleSelector.getModule();
if (currentModule == null) {
return;
}
// Lock and hide subset of UI when attached to an instantApp
AndroidModuleModel model = AndroidModuleModel.get(currentModule);
boolean isInstantApp = false;
if (model != null && model.getProjectType() == PROJECT_TYPE_INSTANTAPP) {
myLaunchOptionCombo.setSelectedItem(LAUNCH_DEEP_LINK);
myDeployOptionCombo.setSelectedItem(InstallOption.DEFAULT_APK);
isInstantApp = true;
}
myDeployOptionCombo.setEnabled(!isInstantApp);
myCustomArtifactLabeledComponent.setEnabled(!isInstantApp);
myLaunchOptionCombo.setEnabled(!isInstantApp);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class NewVectorAssetAction method createWizard.
@Nullable
@Override
protected ModelWizard createWizard(@NotNull AndroidFacet facet) {
Module module = facet.getModule();
Project project = module.getProject();
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
AndroidVersion minSdkVersion = androidModel.getMinSdkVersion();
String version = androidModel.getAndroidProject().getModelVersion();
GradleVersion revision = GradleVersion.parse(version);
if (revision.compareIgnoringQualifiers(VECTOR_ASSET_GENERATION_REVISION) < 0 && (minSdkVersion == null || minSdkVersion.getApiLevel() < VECTOR_DRAWABLE_API_LEVEL)) {
Messages.showErrorDialog(project, ERROR_MESSAGE, ERROR_TITLE);
return null;
}
}
ModelWizard.Builder wizardBuilder = new ModelWizard.Builder();
wizardBuilder.addStep(new NewVectorAssetStep(new GenerateVectorIconModel(facet), facet));
return wizardBuilder.build();
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel 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.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class Projects method storePluginVersionsPerModule.
public static void storePluginVersionsPerModule(@NotNull Project project) {
Map<String, GradleVersion> pluginVersionsPerModule = Maps.newHashMap();
for (Module module : ModuleManager.getInstance(project).getModules()) {
AndroidModuleModel model = AndroidModuleModel.get(module);
if (model != null) {
GradleFacet facet = GradleFacet.getInstance(module);
if (facet != null) {
GradleVersion modelVersion = model.getModelVersion();
if (modelVersion != null) {
pluginVersionsPerModule.put(facet.getConfiguration().GRADLE_PROJECT_PATH, modelVersion);
}
}
}
}
project.putUserData(PLUGIN_VERSIONS_BY_MODULE, pluginVersionsPerModule);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class BuildVariantUpdater method doUpdate.
@Nullable
private Module doUpdate(@NotNull Project project, @NotNull String moduleName, @NotNull String variant, @NotNull List<AndroidFacet> affectedAndroidFacets, @NotNull List<NdkFacet> affectedNativeAndroidFacets) {
Module moduleToUpdate = findModule(project, moduleName);
if (moduleToUpdate == null) {
logAndShowUpdateFailure(variant, String.format("Cannot find module '%1$s'.", moduleName));
return null;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(moduleToUpdate);
NdkFacet ndkFacet = NdkFacet.getInstance(moduleToUpdate);
if (androidFacet == null && ndkFacet == null) {
String msg = String.format("Cannot find 'Android' or 'Native-Android-Gradle' facets in module '%1$s'.", moduleToUpdate.getName());
logAndShowUpdateFailure(variant, msg);
}
if (ndkFacet != null) {
NdkModuleModel ndkModuleModel = getNativeAndroidModel(ndkFacet, variant);
if (ndkModuleModel == null || !updateSelectedVariant(ndkFacet, ndkModuleModel, variant)) {
return null;
}
affectedNativeAndroidFacets.add(ndkFacet);
}
if (androidFacet != null) {
AndroidModuleModel androidModel = getAndroidModel(androidFacet, variant);
if (androidModel == null || !updateSelectedVariant(androidFacet, androidModel, variant, affectedAndroidFacets)) {
return null;
}
affectedAndroidFacets.add(androidFacet);
}
return moduleToUpdate;
}
Aggregations