use of com.android.tools.idea.gradle.ProjectLibraries in project android by JetBrains.
the class GradleSyncIntegrationTest method testWithUserDefinedLibrarySources.
// Disabled until the prebuilt Maven repo has all dependencies.
public void testWithUserDefinedLibrarySources() throws Exception {
if (SystemInfo.isWindows) {
// Do not run tests on Windows (see http://b.android.com/222904)
return;
}
loadSimpleApplication();
ProjectLibraries libraries = new ProjectLibraries(getProject());
String libraryNameRegex = "guava-.*";
Library library = libraries.findMatchingLibrary(libraryNameRegex);
assertNotNull(library);
String url = "jar://$USER_HOME$/fake-dir/fake-sources.jar!/";
// add an extra source path.
Library.ModifiableModel libraryModel = library.getModifiableModel();
libraryModel.addRoot(url, SOURCES);
ApplicationManager.getApplication().runWriteAction(libraryModel::commit);
requestSyncAndWait();
library = libraries.findMatchingLibrary(libraryNameRegex);
assertNotNull(library);
String[] urls = library.getUrls(SOURCES);
assertThat(urls).asList().contains(url);
}
use of com.android.tools.idea.gradle.ProjectLibraries 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));
}
Aggregations