Search in sources :

Example 6 with SyncIssue

use of com.android.builder.model.SyncIssue 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

SyncIssue (com.android.builder.model.SyncIssue)6 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 AtlasDependencyGraph (com.android.build.gradle.internal.ide.AtlasDependencyGraph)1 AndroidProject (com.android.builder.model.AndroidProject)1 DependencyGraphs (com.android.builder.model.level2.DependencyGraphs)1 GradleVersion (com.android.ide.common.repository.GradleVersion)1 ProjectLibraries (com.android.tools.idea.gradle.ProjectLibraries)1 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)1 DependencySet (com.android.tools.idea.gradle.project.sync.setup.module.dependency.DependencySet)1 LibraryDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency)1 ModuleDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.ModuleDependency)1 PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)1 PsPath (com.android.tools.idea.gradle.structure.model.PsPath)1 PsLibraryDependencyNavigationPath (com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 Library (com.intellij.openapi.roots.libraries.Library)1 FileUtil.writeToFile (com.intellij.openapi.util.io.FileUtil.writeToFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1