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 void FixIncompletePackageReference(PackageReference pr, MavenDownloader.Options options)
 {
     if (string.IsNullOrEmpty(pr.Version) || pr.Version == $"${{{pr.ArtifactId}.version}}")
     {
         pr.Version = FillLatestVersion(pr, options);
     }
 }
Esempio n. 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);
        }
Esempio n. 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)));
        }
Esempio n. 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));
        }