use of com.android.tools.idea.gradle.structure.model.repositories.search.ArtifactRepository in project android by JetBrains.
the class PsAndroidModule method getArtifactRepositories.
@Override
@NotNull
public List<ArtifactRepository> getArtifactRepositories() {
List<ArtifactRepository> repositories = Lists.newArrayList();
populateRepositories(repositories);
ArtifactRepository repository = AndroidSdkRepositories.getAndroidRepository();
if (repository != null) {
repositories.add(repository);
}
repository = AndroidSdkRepositories.getGoogleRepository();
if (repository != null) {
repositories.add(repository);
}
return repositories;
}
use of com.android.tools.idea.gradle.structure.model.repositories.search.ArtifactRepository in project android by JetBrains.
the class PsLibraryUpdateCheckerDaemon method search.
private void search(@NotNull Collection<ArtifactRepository> repositories, @NotNull Collection<LibraryUpdateId> ids) {
myRunning.set(true);
getAvailableUpdates().clear();
int resultCount = repositories.size() * ids.size();
List<Future<SearchResult>> jobs = Lists.newArrayListWithExpectedSize(resultCount);
Set<SearchRequest> requests = Sets.newHashSet();
ids.forEach(id -> {
SearchRequest request = new SearchRequest(id.getName(), id.getGroupId(), 1, 0);
requests.add(request);
});
Set<SearchResult> results = Sets.newHashSet();
List<Exception> errors = Lists.newArrayList();
Application application = ApplicationManager.getApplication();
application.executeOnPooledThread(() -> {
for (ArtifactRepository repository : repositories) {
for (SearchRequest request : requests) {
jobs.add(application.executeOnPooledThread(() -> repository.search(request)));
}
}
for (Future<SearchResult> job : jobs) {
try {
SearchResult result = Futures.getChecked(job, Exception.class);
List<FoundArtifact> artifacts = result.getArtifacts();
if (artifacts.size() == 1) {
FoundArtifact artifact = artifacts.get(0);
if (!artifact.getVersions().isEmpty()) {
results.add(result);
}
}
} catch (Exception e) {
errors.add(e);
}
}
AvailableLibraryUpdates updates = getAvailableUpdates();
for (SearchResult result : results) {
List<FoundArtifact> artifacts = result.getArtifacts();
updates.add(artifacts.get(0));
}
updates.lastSearchTimeMillis = System.currentTimeMillis();
myResultsUpdaterQueue.queue(new UpdatesAvailable());
});
}
Aggregations