Beispiel #1
0
 public static string BuildDownloadUrl(string baseUrl, PackageReference pkg, PomComponentKind kind)
 {
     if (kind == PomComponentKind.MavenMetadataXml)
     {
         return(string.Concat($"{baseUrl}{pkg.GroupId?.Replace ('.', '/')}/{pkg.ArtifactId}/maven-metadata.xml"));
     }
     return(string.Concat($"{baseUrl}{pkg.GroupId?.Replace ('.', '/')}/{pkg.ArtifactId}/{pkg.Version}/{pkg.ArtifactId}-{pkg.Version}{kind.ToFileSuffix (pkg)}"));
 }
Beispiel #2
0
        public virtual async Task <Stream> GetStreamAsync(PackageReference pkg, PomComponentKind kind, MavenDownloader.Options options, Func <PackageReference, string> getPomSavedPath)
        {
            getPomSavedPath = getPomSavedPath ?? (_pr => MavenDownloader.BuildLocalCachePath(options.OutputPath, _pr, PomComponentKind.PomXml));
            var pr  = RetrievePomContent(pkg, options, getPomSavedPath);
            var url = BuildDownloadUrl(pr, kind);

            options.LogMessage($"Downloading {url} ...");
            return(await GetStreamFromUrlAsync(url));
        }
Beispiel #3
0
        public override Task <Stream> GetStreamAsync(PackageReference pkg, PomComponentKind kind, MavenDownloader.Options options, Func <PackageReference, string> getPomsavedPath)
        {
            string basePath = $"{android_sdk}/extras/android/m2repository/{pkg.GroupId.Replace ('.', '/')}/{pkg.ArtifactId}";
            string file     = kind == PomComponentKind.PomXml ?
                              Path.Combine(basePath, "maven-metadata.xml") :
                              Path.Combine(basePath, pkg.Version, $"{pkg.ArtifactId}-{pkg.Version}{kind.ToFileSuffix (pkg)}");

            options.LogMessage($"Retrieving file from {file} ...");
            return(Task.FromResult((Stream)File.OpenRead(file)));
        }
Beispiel #4
0
        public override string BuildDownloadUrl(PackageReference pkg, PomComponentKind kind)
        {
            string basePath = BaseUrl + $"{pkg.GroupId.Replace ('.', '/')}/{pkg.ArtifactId}";

            if (kind == PomComponentKind.PomXml)
            {
                return($"{basePath}/maven-metadata.xml");
            }
            else
            {
                return($"{basePath}/{pkg.Version}/{pkg.ArtifactId}-{pkg.Version}{kind.ToFileSuffix (pkg)}");
            }
        }
Beispiel #5
0
        public static string ToFileSuffix(this PomComponentKind kind, PackageReference pr)
        {
            switch (kind)
            {
            case PomComponentKind.PomXml: return(".pom");

            case PomComponentKind.Binary: return("." + pr.Packaging);

            case PomComponentKind.JavadocJar: return("-javadoc.jar");

            case PomComponentKind.SourcesJar: return("-sources.jar");
            }
            throw new NotSupportedException();
        }
Beispiel #6
0
 /// <summary>
 /// constructs a download URL, or throw <see cref="T:RepositoryDownloadException" />
 /// </summary>
 /// <returns>The download URL.</returns>
 /// <param name="pkg">Package.</param>
 /// <param name="kind">Pom component kind.</param>
 public virtual string BuildDownloadUrl(PackageReference pkg, PomComponentKind kind)
 {
     return(BuildDownloadUrl(BaseUrl, pkg, kind));
 }
Beispiel #7
0
 public static string BuildLocalCachePath(string basePath, PackageReference pr, PomComponentKind kind)
 {
     if (string.IsNullOrEmpty(pr.GroupId))
     {
         throw new ArgumentException("groupId is empty for " + pr);
     }
     if (string.IsNullOrEmpty(pr.ArtifactId))
     {
         throw new ArgumentException("artifactId is empty for " + pr);
     }
     if (string.IsNullOrEmpty(pr.Version))
     {
         throw new ArgumentException("version is empty for " + pr);
     }
     return(Path.Combine(basePath ?? "", pr.GroupId, pr.ArtifactId, pr.Version, $"{pr.ArtifactId}-{pr.Version}{kind.ToFileSuffix (pr)}"));
 }
Beispiel #8
0
 public Entry Find(PackageReference package, PomComponentKind kind)
 {
     return(Entries.FirstOrDefault(e => e.ComponentKind == kind && e.Package.Equals(package)));
 }
Beispiel #9
0
 public bool Exists(PackageReference package, PomComponentKind kind)
 {
     return(Find(package, kind) != null);
 }
Beispiel #10
0
 public Entry(PackageReference package, PomComponentKind kind, string localFile)
 {
     Package       = package;
     ComponentKind = kind;
     LocalFile     = localFile;
 }