Skip to content

Commit

Permalink
read mvn meta
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed May 15, 2023
1 parent 9363378 commit a5d2f9a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
25 changes: 25 additions & 0 deletions maven/meta.go
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions maven/meta_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit a5d2f9a

Please sign in to comment.