示例#1
0
        public virtual PackageReference RetrievePomContent(PackageReference pr, MavenDownloader.Options options, Func <PackageReference, string> getPomSavedPath)
        {
            options = options ?? new MavenDownloader.Options();

            var pomUrl = BuildDownloadUrl(pr, PomComponentKind.PomXml);

            options.LogMessage("Downloading pom: " + pomUrl);

            getPomSavedPath = getPomSavedPath ?? (_pr => MavenDownloader.BuildLocalCachePath(options.OutputPath, _pr, PomComponentKind.PomXml));
            var pomSavedPath = getPomSavedPath(pr);

            if (pomSavedPath != null && !Directory.Exists(Path.GetDirectoryName(pomSavedPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(pomSavedPath));
            }
            var ms = Download(pomUrl);

            if (pomSavedPath != null)
            {
                using (var pomFile = File.Create(pomSavedPath))
                    ms.CopyTo(pomFile);
                ms.Position = 0;
            }
            var pom = XElement.Load(ms);

            return(PackageReference.Load(pom));
        }
示例#2
0
 public virtual void FixIncompletePackageReference(PackageReference pr, MavenDownloader.Options options)
 {
     if (string.IsNullOrEmpty(pr.Version) || pr.Version == $"${{{pr.ArtifactId}.version}}")
     {
         pr.Version = FillLatestVersion(pr, options);
     }
 }
示例#3
0
        string FillLatestVersion(PackageReference pr, MavenDownloader.Options options)
        {
            var dlUrl = BuildDownloadUrl(pr, PomComponentKind.MavenMetadataXml);

            options.LogMessage("Version number is missing. Trying to download " + dlUrl + " to get the latest version nuumber.");
            var ms  = Download(dlUrl);
            var doc = XDocument.Load(ms);

            return((doc.Root.Element("versioning")?.Element("release")?.FirstNode as XText)?.Value);
        }
示例#4
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)));
        }
示例#5
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));
        }