static MavenService() { MonkeyCache.FileStore.Barrel.ApplicationId = "mavenrepobrowser"; repository = MavenNet.MavenRepository.FromGoogle(); }
public IEnumerable <Models.Repository> LoadMavenRepositories(IEnumerable <string> repos) { MavenNet.MavenRepository mr = MavenNet.MavenRepository.FromGoogle(); if (repos == null) { mr.Refresh(); repos = new string[] { "Google Full Download" }; } foreach (string r in repos) { Trace.WriteLine($" repository = {r}"); Task.WaitAll(mr.Refresh(r)); Models.Repository repository = new Models.Repository() { Id = r }; foreach (MavenNet.Models.Group g in mr.Groups) { Trace.WriteLine($" group = {g}"); string g_id = g.Id; Models.Group group = new Models.Group() { Id = g_id }; foreach (MavenNet.Models.Artifact a in g.Artifacts) { string a_id = a.Id; Trace.WriteLine($" artifact = {a_id}"); if (!ArtifactsToBind.Exists(id => id == a_id)) { Trace.WriteLine($" skipped - not listed for bindings"); continue; } Models.Artifact artifact = new Models.Artifact() { Id = a_id }; foreach (string v in a.Versions.OrderByDescending(i => i)) { Trace.WriteLine($" version = {v}"); Models.Version version = new Models.Version() { Value = v }; try { MavenNet.Models.Project mp = mr.GetProjectAsync ( g.Id, a.Id, v ).Result; this.Projects.Add(mp); (string ArtifactId, string Version)dependency; foreach (var d in mp.Dependencies) { dependency = (ArtifactId : d.ArtifactId, Version : d.Version); version.Dependencies.Add(dependency); Trace.WriteLine($" dependency = {d.ArtifactId}"); Trace.WriteLine($" versoin = {d.Version}"); } } catch (Exception exc) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine($"GoogleMavenData.LoadMavenRepositories Exception"); sb.AppendLine($" Message : {exc.Message}"); sb.AppendLine($" Not found {g.Id} {a.Id} {v}"); System.Diagnostics.Trace.WriteLine(sb.ToString()); } artifact.Versions.Add(version); } group.Artifacts.Add(artifact); } repository.Groups.Add(group); } //Repositories.Add(mr); this.Configurator.Repositories.Add(repository); yield return(repository); } }