Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions util/maven/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Project struct {

Licenses []License `xml:"licenses>license,omitempty"`
Developers []Developer `xml:"developers>developer,omitempty"`
Modules []String `xml:"modules>module,omitempty"`
SCM SCM `xml:"scm,omitempty"`
IssueManagement IssueManagement `xml:"issueManagement,omitempty"`
DistributionManagement DistributionManagement `xml:"distributionManagement,omitempty"`
Expand Down Expand Up @@ -304,6 +305,14 @@ func (p *Project) Interpolate() error {
}
p.Repositories = repos

var modules []String
for _, m := range p.Modules {
if ok := m.interpolate(properties); ok {
modules = append(modules, m)
}
}
p.Modules = modules

return nil
}

Expand Down
21 changes: 21 additions & 0 deletions util/maven/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ func TestProject(t *testing.T) {
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("unmarshal input:\n(- got, + want):\n%s", diff)
}

inputAggregator, err := os.ReadFile("testdata/aggregator-1.0.0.xml")
if err != nil {
t.Fatalf("failed to read file: %v", err)
}
wantAggregator := Project{
ProjectKey: ProjectKey{
GroupID: "com.example",
ArtifactID: "aggregator",
Version: "1.0.0",
},
Packaging: "pom",
Modules: []String{"module-1", "module-2"},
}
var gotAggregator Project
if err := xml.Unmarshal(inputAggregator, &gotAggregator); err != nil {
t.Fatalf("failed to unmarshal input: %v", err)
}
if diff := cmp.Diff(gotAggregator, wantAggregator); diff != "" {
t.Errorf("unmarshal aggregator input:\n(- got, + want):\n%s", diff)
}
}

func TestMergeParent(t *testing.T) {
Expand Down
10 changes: 10 additions & 0 deletions util/maven/testdata/aggregator-1.0.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<project>
<groupId>com.example</groupId>
<artifactId>aggregator</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>module-1</module>
<module>module-2</module>
</modules>
</project>
Loading