code-intelligence.com/cifuzz@v0.40.0/internal/build/maven/xml.go (about) 1 package maven 2 3 import ( 4 "encoding/xml" 5 "io" 6 ) 7 8 type Resource struct { 9 Directory string `xml:"directory"` 10 } 11 12 // this struct is a abbreviated representation of an actual pom.xml 13 type Project struct { 14 XMLName xml.Name `xml:"project"` 15 GroupId string `xml:"groupId"` 16 Version string `xml:"version"` 17 Name string `xml:"name"` 18 Description string `xml:"description"` 19 Properties struct { 20 Text string `xml:",chardata"` 21 MavenCompilerTarget string `xml:"maven.compiler.target"` 22 MavenCompilerSource string `xml:"maven.compiler.source"` 23 } `xml:"properties"` 24 Dependencies struct { 25 Dependency []struct { 26 GroupId string `xml:"groupId"` 27 ArtifactId string `xml:"artifactId"` 28 Version string `xml:"version"` 29 Scope string `xml:"scope"` 30 } `xml:"dependency"` 31 } `xml:"dependencies"` 32 Build struct { 33 SourceDirectory string `xml:"sourceDirectory"` 34 ScriptSourceDirectory string `xml:"scriptSourceDirectory"` 35 TestSourceDirectory string `xml:"testSourceDirectory"` 36 OutputDirectory string `xml:"outputDirectory"` 37 TestOutputDirectory string `xml:"testOutputDirectory"` 38 Resources struct { 39 Resource []Resource `xml:"resource"` 40 } `xml:"resources"` 41 TestResources struct { 42 TestResource []Resource `xml:"testResource"` 43 } `xml:"testResources"` 44 Directory string `xml:"directory"` 45 } `xml:"build"` 46 Reporting struct { 47 OutputDirectory string `xml:"outputDirectory"` 48 } `xml:"reporting"` 49 } 50 51 func parseXML(in io.Reader) (*Project, error) { 52 bytes, err := io.ReadAll(in) 53 if err != nil { 54 return nil, err 55 } 56 57 var project Project 58 err = xml.Unmarshal(bytes, &project) 59 if err != nil { 60 return nil, err 61 } 62 63 return &project, nil 64 }