Search in sources :

Example 1 with BuildTypeContainer

use of com.android.builder.model.BuildTypeContainer in project android by JetBrains.

the class DynamicResourceValueRepository method getMap.

@Override
@NonNull
protected Map<ResourceType, ListMultimap<String, ResourceItem>> getMap() {
    if (mItems.isEmpty()) {
        // TODO: b/23032391
        AndroidModuleModel androidModel = AndroidModuleModel.get(myFacet);
        if (androidModel == null) {
            return mItems;
        }
        Variant selectedVariant = androidModel.getSelectedVariant();
        // Reverse overlay order because when processing lower order ones, we ignore keys already processed
        BuildTypeContainer buildType = androidModel.findBuildType(selectedVariant.getBuildType());
        if (buildType != null) {
            addValues(buildType.getBuildType().getResValues());
        }
        // flavors and default config:
        addValues(selectedVariant.getMergedFlavor().getResValues());
    }
    return mItems;
}
Also used : Variant(com.android.builder.model.Variant) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) BuildTypeContainer(com.android.builder.model.BuildTypeContainer) NonNull(com.android.annotations.NonNull)

Example 2 with BuildTypeContainer

use of com.android.builder.model.BuildTypeContainer in project android by JetBrains.

the class MoveToDebugManifestQuickFix method apply.

@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
    final XmlAttribute attribute = PsiTreeUtil.getParentOfType(startElement, XmlAttribute.class);
    if (attribute != null) {
        XmlTag parent = attribute.getParent();
        if (parent != null && parent.getName().equals(TAG_USES_PERMISSION)) {
            Module module = getModule(parent);
            assert MOCK_LOCATION_PERMISSION.equals(parent.getAttributeValue(ATTR_NAME, ANDROID_URI));
            parent.delete();
            if (module != null) {
                AndroidFacet facet = AndroidFacet.getInstance(module);
                if (facet != null) {
                    VirtualFile mainManifest = facet.getMainIdeaSourceProvider().getManifestFile();
                    // TODO: b/22928250
                    AndroidModuleModel androidModel = AndroidModuleModel.get(facet);
                    if (androidModel != null && mainManifest != null && mainManifest.getParent() != null && mainManifest.getParent().getParent() != null) {
                        final VirtualFile src = mainManifest.getParent().getParent();
                        for (BuildTypeContainer container : androidModel.getAndroidProject().getBuildTypes()) {
                            BuildType buildType = container.getBuildType();
                            if (buildType.isDebuggable()) {
                                addManifest(module, src, buildType.getName());
                                return;
                            }
                        }
                        Messages.showErrorDialog(module.getProject(), "Did not find a debug build type", "Move Permission");
                    }
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlAttribute(com.intellij.psi.xml.XmlAttribute) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) BuildType(com.android.builder.model.BuildType) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) XmlTag(com.intellij.psi.xml.XmlTag) BuildTypeContainer(com.android.builder.model.BuildTypeContainer)

Example 3 with BuildTypeContainer

use of com.android.builder.model.BuildTypeContainer in project android by JetBrains.

the class ContentRootSourcePaths method storeExpectedSourcePaths.

/**
   * Stores the expected paths of all the source and test directories in the given {@code AndroidProject}.
   *
   * @param androidProject the given {@code AndroidProject}.
   */
public void storeExpectedSourcePaths(@NotNull AndroidProjectStub androidProject) {
    VariantStub selectedVariant = androidProject.getFirstVariant();
    Assert.assertNotNull(selectedVariant);
    addGeneratedDirPaths(selectedVariant);
    for (String flavorName : selectedVariant.getProductFlavors()) {
        ProductFlavorContainerStub flavor = androidProject.findProductFlavor(flavorName);
        if (flavor != null) {
            addSourceDirPaths(flavor);
        }
    }
    String buildTypeName = selectedVariant.getBuildType();
    BuildTypeContainer buildType = androidProject.findBuildType(buildTypeName);
    if (buildType != null) {
        addSourceDirPaths(buildType.getSourceProvider(), false);
    }
    addSourceDirPaths(androidProject.getDefaultConfig());
}
Also used : ProductFlavorContainerStub(com.android.tools.idea.gradle.stubs.android.ProductFlavorContainerStub) VariantStub(com.android.tools.idea.gradle.stubs.android.VariantStub) BuildTypeContainer(com.android.builder.model.BuildTypeContainer)

Example 4 with BuildTypeContainer

use of com.android.builder.model.BuildTypeContainer in project android by JetBrains.

the class AndroidModuleModelTest method testFindBuildType.

public void testFindBuildType() throws Exception {
    String buildTypeName = "debug";
    BuildTypeContainer buildType = myAndroidModel.findBuildType(buildTypeName);
    assertNotNull(buildType);
    assertSame(myAndroidProject.findBuildType(buildTypeName), buildType);
}
Also used : BuildTypeContainer(com.android.builder.model.BuildTypeContainer)

Aggregations

BuildTypeContainer (com.android.builder.model.BuildTypeContainer)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 NonNull (com.android.annotations.NonNull)1 BuildType (com.android.builder.model.BuildType)1 Variant (com.android.builder.model.Variant)1 ProductFlavorContainerStub (com.android.tools.idea.gradle.stubs.android.ProductFlavorContainerStub)1 VariantStub (com.android.tools.idea.gradle.stubs.android.VariantStub)1 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlTag (com.intellij.psi.xml.XmlTag)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1