Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Latest commit

 

History

History
66 lines (52 loc) · 1.75 KB

maven-repo-dependency-diff.workbook

File metadata and controls

66 lines (52 loc) · 1.75 KB
id title uti platforms packages
8500e0df-a1f6-42f1-b2fa-e51d8bdc0c21
maven-repo-dependency-diff
com.xamarin.workbook
Console
id version
MavenNet
2.0.1
id version
System.Net.Http
4.3.3
#r "MavenNet"
#r "System.Net.Http"
using MavenNet;
using System.Linq;
const string OLD_VER = "27.0.2";
const string NEW_VER = "27.1.1";
var repo = MavenNet.MavenRepository.FromGoogle(); //maven.google.com
await repo.Refresh();

var groupId = "com.android.support";

var mavenGroup = repo.Groups.FirstOrDefault(g => g.Id == groupId);

foreach (var item in mavenGroup.Artifacts) {

    var oldProj = await repo.GetProjectAsync (groupId, item.Id, OLD_VER);
    var newProj = await repo.GetProjectAsync (groupId, item.Id, NEW_VER);
    
    if (oldProj == null && newProj == null)
        continue;
    if (newProj == null) {
        Console.WriteLine (item.Id + " -> Removed");
        continue;
    }
    if (oldProj == null) {
        Console.WriteLine (item.Id + " -> Added");

        foreach (var d in newProj.Dependencies)
            Console.WriteLine ($"-> Dependency: {d.ArtifactId}");
            
        continue;
    }

    var removedDeps = oldProj.Dependencies.Where (od => !newProj.Dependencies.Any (nd => nd.GroupId == od.GroupId && nd.ArtifactId == od.ArtifactId));
    var addedDeps = newProj.Dependencies.Where (od => !oldProj.Dependencies.Any (nd => nd.GroupId == od.GroupId && nd.ArtifactId == od.ArtifactId));

    if (removedDeps.Any () || addedDeps.Any ())
        Console.WriteLine (item.Id + " dependencies changed!");

    foreach (var rm in removedDeps)
        Console.WriteLine ($"-> Removed: {rm.ArtifactId}");

    foreach (var ad in addedDeps)
        Console.WriteLine ($"-> Added: {ad.ArtifactId}");
}