// Versions ... func (d *Dep) Versions() (*VersionInfo, error) { res, err := util.GetWithCheck(fmt.Sprintf("%s/maven-metadata.xml", d.BaseURL())) if err != nil { return nil, err } defer res.Body.Close() nfo := &VersionInfo{} if err := xml.NewDecoder(res.Body).Decode(nfo); err != nil { return nil, err } return nfo, nil }
func depsOf(d *Dep, ver string) ([]*Dep, error) { res, err := util.GetWithCheck( fmt.Sprintf("%s/%s/%s-%s.pom", d.BaseURL(), ver, d.Artifact, ver)) if err != nil { return nil, err } defer res.Body.Close() var p struct { Deps []*struct { Org string `xml:"groupId"` Artifact string `xml:"artifactId"` Version string `xml:"version"` Optional bool `xml:"optional"` Scope string `xml:"scope"` } `xml:"dependencies>dependency"` } if err := xml.NewDecoder(res.Body).Decode(&p); err != nil { return nil, err } var deps []*Dep for _, dep := range p.Deps { if dep.Optional { continue } if dep.Scope != "" && dep.Scope != "runtime" { continue } dc := &Dep{ Org: dep.Org, Artifact: dep.Artifact, Version: dep.Version, } resolveVarsHackily(d, dc) deps = append(deps, dc) } return deps, nil }