Search in sources :

Example 1 with VariantStub

use of com.android.tools.idea.gradle.stubs.android.VariantStub 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 2 with VariantStub

use of com.android.tools.idea.gradle.stubs.android.VariantStub in project android by JetBrains.

the class AndroidJunitPatcherTest method setUpIdeaAndroidProject.

private void setUpIdeaAndroidProject() {
    myAndroidProject = TestProjects.createBasicProject();
    VariantStub variant = myAndroidProject.getFirstVariant();
    assertNotNull(variant);
    AndroidModuleModel androidModel = new AndroidModuleModel(myAndroidProject.getName(), myAndroidProject.getRootDir(), myAndroidProject, variant.getName());
    myFacet.setAndroidModel(androidModel);
    for (Module module : ModuleManager.getInstance(getProject()).getModules()) {
        TestArtifactSearchScopes.initializeScope(module);
    }
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) VariantStub(com.android.tools.idea.gradle.stubs.android.VariantStub) Module(com.intellij.openapi.module.Module)

Example 3 with VariantStub

use of com.android.tools.idea.gradle.stubs.android.VariantStub in project android by JetBrains.

the class ProjectResourceRepositoryTest method addArchiveLibraries.

private void addArchiveLibraries() {
    // Add in some Android projects too
    // make it a Gradle project
    myFacet.getProperties().ALLOW_USER_CONFIGURATION = false;
    AndroidProjectStub androidProject = TestProjects.createFlavorsProject();
    VariantStub variant = androidProject.getFirstVariant();
    assertNotNull(variant);
    File rootDir = androidProject.getRootDir();
    AndroidModuleModel androidModel = new AndroidModuleModel(androidProject.getName(), rootDir, androidProject, variant.getName());
    myFacet.setAndroidModel(androidModel);
    File bundle = new File(rootDir, "bundle.aar");
    File libJar = new File(rootDir, "bundle_aar" + File.separatorChar + "library.jar");
    AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar);
    variant.getMainArtifact().getDependencies().addLibrary(library);
}
Also used : AndroidProjectStub(com.android.tools.idea.gradle.stubs.android.AndroidProjectStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) VariantStub(com.android.tools.idea.gradle.stubs.android.VariantStub) AndroidLibraryStub(com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Aggregations

VariantStub (com.android.tools.idea.gradle.stubs.android.VariantStub)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 BuildTypeContainer (com.android.builder.model.BuildTypeContainer)1 AndroidLibraryStub (com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub)1 AndroidProjectStub (com.android.tools.idea.gradle.stubs.android.AndroidProjectStub)1 ProductFlavorContainerStub (com.android.tools.idea.gradle.stubs.android.ProductFlavorContainerStub)1 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 File (java.io.File)1