7
7
"encoding/xml"
8
8
"io"
9
9
10
+ "code.gitea.io/gitea/modules/util"
10
11
"code.gitea.io/gitea/modules/validation"
11
12
12
13
"golang.org/x/net/html/charset"
@@ -31,18 +32,27 @@ type Dependency struct {
31
32
}
32
33
33
34
type 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 {
42
51
Name string `xml:"name"`
43
52
URL string `xml:"url"`
44
53
Distribution string `xml:"distribution"`
45
54
} `xml:"licenses>license"`
55
+
46
56
Dependencies []struct {
47
57
GroupID string `xml:"groupId"`
48
58
ArtifactID string `xml:"artifactId"`
@@ -81,8 +91,16 @@ func ParsePackageMetaData(r io.Reader) (*Metadata, error) {
81
91
})
82
92
}
83
93
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
+ }
84
102
return & Metadata {
85
- GroupID : pom . GroupID ,
103
+ GroupID : pomGroupID ,
86
104
ArtifactID : pom .ArtifactID ,
87
105
Name : pom .Name ,
88
106
Description : pom .Description ,
0 commit comments