diff --git a/maven/meta.go b/maven/meta.go new file mode 100644 index 0000000..9df9188 --- /dev/null +++ b/maven/meta.go @@ -0,0 +1,25 @@ +package maven + +import ( + http "github.com/nothub/mrpack-install/requester" +) + +type Metadata struct { + GroupId string `xml:"groupId"` + ArtifactId string `xml:"artifactId"` + Versioning struct { + Latest string `xml:"latest"` + Release string `xml:"release"` + Versions []string `xml:"versions>version"` + LastUpdated string `xml:"lastUpdated"` // TODO: use Time type + } `xml:"versioning"` +} + +func FetchMetadata(url string) (*Metadata, error) { + m := &Metadata{} + err := http.DefaultHttpClient.GetXml(url, m, nil) + if err != nil { + return nil, err + } + return m, nil +} diff --git a/maven/meta_test.go b/maven/meta_test.go new file mode 100644 index 0000000..94369f0 --- /dev/null +++ b/maven/meta_test.go @@ -0,0 +1,16 @@ +package maven + +import ( + "testing" +) + +func TestFetchMetadata(t *testing.T) { + m, err := FetchMetadata("https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/maven-metadata.xml") + if err != nil { + t.Fatal(err.Error()) + } + if m.ArtifactId != "quilt-installer" { + t.Fatal("wrong artifact id") + } + t.Logf("%++v", m) +}