@@ -50,6 +50,43 @@ func WithRemoteRepos(repos []string) option {
5050 }
5151}
5252
53+ type extendedParser struct {
54+ * parser
55+ }
56+
57+ // ExtendedParser extends the types.Parser and returns additional meta data
58+ type ExtendedParser interface {
59+ types.Parser
60+ // GetRemoteRepositories returns the remote repositories
61+ GetRemoteRepositories () []string
62+ // GetProperties returns properties for given gav string
63+ GetProperties (groupID , artifactID , version string ) map [string ]string
64+ // EvaluateProperty evaluates the string in the property
65+ EvaluateProperty (s string , props map [string ]string ) string
66+ }
67+
68+ func (e * extendedParser ) GetRemoteRepositories () []string {
69+ return e .remoteRepositories
70+ }
71+
72+ func (e * extendedParser ) GetProperties (groupID , artifactID , version string ) map [string ]string {
73+ art := newArtifact (groupID , artifactID , version , "" , nil )
74+ result := e .cache .get (art )
75+ if result == nil {
76+ return nil
77+ }
78+ return result .properties
79+ }
80+
81+ func (e * extendedParser ) EvaluateProperty (s string , props map [string ]string ) string {
82+ return evaluateVariable (s , props , nil )
83+ }
84+
85+ // evaluateVariable
86+ func NewExtendedParser (filePath string , opts ... option ) ExtendedParser {
87+ return & extendedParser {newPomParser (filePath , opts ... )}
88+ }
89+
5390type parser struct {
5491 rootPath string
5592 cache pomCache
@@ -60,6 +97,10 @@ type parser struct {
6097}
6198
6299func NewParser (filePath string , opts ... option ) types.Parser {
100+ return newPomParser (filePath , opts ... )
101+ }
102+
103+ func newPomParser (filePath string , opts ... option ) * parser {
63104 o := & options {
64105 offline : false ,
65106 remoteRepos : []string {centralURL },
@@ -337,7 +378,8 @@ func (p *parser) mergeDependencyManagements(depManagements ...[]pomDependency) [
337378}
338379
339380func (p * parser ) parseDependencies (deps []pomDependency , props map [string ]string , depManagement , rootDepManagement []pomDependency ,
340- exclusions map [string ]struct {}) []artifact {
381+ exclusions map [string ]struct {},
382+ ) []artifact {
341383 // Imported POMs often have no dependencies, so dependencyManagement resolution can be skipped.
342384 if len (deps ) == 0 {
343385 return nil
@@ -542,6 +584,7 @@ func (p *parser) openPom(filePath string) (*pom, error) {
542584 content : content ,
543585 }, nil
544586}
587+
545588func (p * parser ) tryRepository (groupID , artifactID , version string ) (* pom , error ) {
546589 // Generate a proper path to the pom.xml
547590 // e.g. com.fasterxml.jackson.core, jackson-annotations, 2.10.0
0 commit comments