Search in sources :

Example 11 with AndroidPluginInfo

use of com.android.tools.idea.gradle.plugin.AndroidPluginInfo in project android by JetBrains.

the class GradleSyncIntegrationTest method testJarsFolderInExplodedAarIsExcluded.

// https://code.google.com/p/android/issues/detail?id=227931
public void testJarsFolderInExplodedAarIsExcluded() throws Exception {
    loadSimpleApplication();
    Module appModule = myModules.getAppModule();
    AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
    assertNotNull(androidModel);
    Collection<SyncIssue> issues = androidModel.getSyncIssues();
    assertThat(issues).isEmpty();
    AndroidPluginInfo pluginInfo = AndroidPluginInfo.find(getProject());
    assertNotNull(pluginInfo);
    assertEquals(pluginInfo.getPluginGeneration(), ORIGINAL);
    GradleVersion pluginVersion = pluginInfo.getPluginVersion();
    assertNotNull(pluginVersion);
    if (pluginVersion.compareIgnoringQualifiers("2.3.0") >= 0) {
        // it is not inside the project.
        return;
    }
    ProjectLibraries libraries = new ProjectLibraries(getProject());
    Library appCompat = libraries.findMatchingLibrary("appcompat-v7.*");
    assertNotNull(appCompat);
    File jarsFolderPath = null;
    for (String url : appCompat.getUrls(CLASSES)) {
        if (url.startsWith(JAR_PROTOCOL_PREFIX)) {
            File jarPath = getJarFromJarUrl(url);
            assertNotNull(jarPath);
            jarsFolderPath = jarPath.getParentFile();
            break;
        }
    }
    assertNotNull(jarsFolderPath);
    ContentEntry[] contentEntries = ModuleRootManager.getInstance(appModule).getContentEntries();
    assertThat(contentEntries).hasLength(1);
    ContentEntry contentEntry = contentEntries[0];
    List<String> excludeFolderUrls = contentEntry.getExcludeFolderUrls();
    assertThat(excludeFolderUrls).contains(pathToIdeaUrl(jarsFolderPath));
}
Also used : SyncIssue(com.android.builder.model.SyncIssue) ProjectLibraries(com.android.tools.idea.gradle.ProjectLibraries) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) ContentEntry(com.intellij.openapi.roots.ContentEntry) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) GradleVersion(com.android.ide.common.repository.GradleVersion) FileUtil.writeToFile(com.intellij.openapi.util.io.FileUtil.writeToFile) File(java.io.File)

Aggregations

AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)11 NotNull (org.jetbrains.annotations.NotNull)6 GradleVersion (com.android.ide.common.repository.GradleVersion)4 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)4 ArrayList (java.util.ArrayList)4 FixAndroidGradlePluginVersionHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink)3 Module (com.intellij.openapi.module.Module)3 AndroidProject (com.android.builder.model.AndroidProject)2 OpenFileHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink)2 OpenUrlHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)2 Project (com.intellij.openapi.project.Project)2 SyncIssue (com.android.builder.model.SyncIssue)1 LocalPackage (com.android.repository.api.LocalPackage)1 ProgressIndicator (com.android.repository.api.ProgressIndicator)1 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)1 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)1 ProjectLibraries (com.android.tools.idea.gradle.ProjectLibraries)1 AndroidModel (com.android.tools.idea.gradle.dsl.model.android.AndroidModel)1 AndroidDslElement (com.android.tools.idea.gradle.dsl.parser.android.AndroidDslElement)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1