-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaven.go
38 lines (33 loc) · 848 Bytes
/
maven.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package installer
import (
"encoding/xml"
"net/url"
)
type (
MavenMetadataVersioning struct {
Release string `xml:"release"`
Latest string `xml:"latest"`
LastUpdated string `xml:"lastUpdated"`
Versions []string `xml:"versions>version"`
}
MavenMetadata struct {
GroupId string `xml:"groupId"`
ArtifactId string `xml:"artifactId"`
Versioning MavenMetadataVersioning `xml:"versioning"`
}
)
func DecodeMavenMetadata(body []byte) (data MavenMetadata, err error) {
if err = xml.Unmarshal(body, &data); err != nil {
return
}
return
}
func GetMavenMetadata(link string) (data MavenMetadata, err error) {
if link, err = url.JoinPath(link, "maven-metadata.xml"); err != nil {
return
}
if err = DefaultHTTPClient.GetXml(link, &data); err != nil {
return
}
return
}