Esempio n. 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));
        }
Esempio n. 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));
        }