77 "encoding/xml"
88 "io"
99
10+ "code.gitea.io/gitea/modules/util"
1011 "code.gitea.io/gitea/modules/validation"
1112
1213 "golang.org/x/net/html/charset"
@@ -31,18 +32,27 @@ type Dependency struct {
3132}
3233
3334type pomStruct struct {
34- XMLName xml.Name `xml:"project"`
35- GroupID string `xml:"groupId"`
36- ArtifactID string `xml:"artifactId"`
37- Version string `xml:"version"`
38- Name string `xml:"name"`
39- Description string `xml:"description"`
40- URL string `xml:"url"`
41- Licenses []struct {
35+ XMLName xml.Name `xml:"project"`
36+
37+ Parent struct {
38+ GroupID string `xml:"groupId"`
39+ ArtifactID string `xml:"artifactId"`
40+ Version string `xml:"version"`
41+ } `xml:"parent"`
42+
43+ GroupID string `xml:"groupId"`
44+ ArtifactID string `xml:"artifactId"`
45+ Version string `xml:"version"`
46+ Name string `xml:"name"`
47+ Description string `xml:"description"`
48+ URL string `xml:"url"`
49+
50+ Licenses []struct {
4251 Name string `xml:"name"`
4352 URL string `xml:"url"`
4453 Distribution string `xml:"distribution"`
4554 } `xml:"licenses>license"`
55+
4656 Dependencies []struct {
4757 GroupID string `xml:"groupId"`
4858 ArtifactID string `xml:"artifactId"`
@@ -81,8 +91,16 @@ func ParsePackageMetaData(r io.Reader) (*Metadata, error) {
8191 })
8292 }
8393
94+ pomGroupID := pom .GroupID
95+ if pomGroupID == "" {
96+ // the current module could inherit parent: https://maven.apache.org/pom.html#Inheritance
97+ pomGroupID = pom .Parent .GroupID
98+ }
99+ if pomGroupID == "" {
100+ return nil , util .ErrInvalidArgument
101+ }
84102 return & Metadata {
85- GroupID : pom . GroupID ,
103+ GroupID : pomGroupID ,
86104 ArtifactID : pom .ArtifactID ,
87105 Name : pom .Name ,
88106 Description : pom .Description ,
0 commit comments