From 80e0509f260aef0250398bb3e424c1095477a5c9 Mon Sep 17 00:00:00 2001 From: akadir Date: Sat, 22 Jul 2023 15:12:25 +0300 Subject: [PATCH] fix: add missing configuration tags resolves https://github.com/vifraa/gopom/issues/3 --- example_pom.go | 72 +++++++++++++++++++++++++++++++++++++++++--------- gopom.go | 42 ++++++++++++++++------------- gopom_test.go | 55 +++++++++++++++++++++++++++++++++++--- 3 files changed, 135 insertions(+), 34 deletions(-) diff --git a/example_pom.go b/example_pom.go index de3ed3e..dbd8b71 100644 --- a/example_pom.go +++ b/example_pom.go @@ -325,7 +325,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -350,7 +354,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -368,7 +376,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -393,7 +405,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -414,11 +430,19 @@ var examplePom = ` report inherited - configuration + + value + value2 + value3 + inherited - configuration + + value + value2 + value3 + @@ -492,7 +516,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -517,7 +545,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -535,7 +567,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -560,7 +596,11 @@ var examplePom = ` goal inherited - configuration + + value + value2 + value3 + @@ -719,11 +759,19 @@ var examplePom = ` report inherited - configuration + + value + value2 + value3 + inherited - configuration + + value + value2 + value3 + diff --git a/gopom.go b/gopom.go index b8db882..e6e53dd 100644 --- a/gopom.go +++ b/gopom.go @@ -304,20 +304,22 @@ type PluginManagement struct { } type Plugin struct { - GroupID string `xml:"groupId"` - ArtifactID string `xml:"artifactId"` - Version string `xml:"version"` - Extensions string `xml:"extensions"` - Executions []PluginExecution `xml:"executions>execution"` - Dependencies []Dependency `xml:"dependencies>dependency"` - Inherited string `xml:"inherited"` + GroupID string `xml:"groupId"` + ArtifactID string `xml:"artifactId"` + Version string `xml:"version"` + Extensions string `xml:"extensions"` + Executions []PluginExecution `xml:"executions>execution"` + Dependencies []Dependency `xml:"dependencies>dependency"` + Inherited string `xml:"inherited"` + Configuration Properties `xml:"configuration"` } type PluginExecution struct { - ID string `xml:"id"` - Phase string `xml:"phase"` - Goals []string `xml:"goals>goal"` - Inherited string `xml:"inherited"` + ID string `xml:"id"` + Phase string `xml:"phase"` + Goals []string `xml:"goals>goal"` + Inherited string `xml:"inherited"` + Configuration Properties `xml:"configuration"` } type Reporting struct { @@ -327,17 +329,19 @@ type Reporting struct { } type ReportingPlugin struct { - GroupID string `xml:"groupId"` - ArtifactID string `xml:"artifactId"` - Version string `xml:"version"` - Inherited string `xml:"inherited"` - ReportSets []ReportSet `xml:"reportSets>reportSet"` + GroupID string `xml:"groupId"` + ArtifactID string `xml:"artifactId"` + Version string `xml:"version"` + Inherited string `xml:"inherited"` + ReportSets []ReportSet `xml:"reportSets>reportSet"` + Configuration Properties `xml:"configuration"` } type ReportSet struct { - ID string `xml:"id"` - Reports []string `xml:"reports>report"` - Inherited string `xml:"inherited"` + ID string `xml:"id"` + Reports []string `xml:"reports>report"` + Inherited string `xml:"inherited"` + Configuration Properties `xml:"configuration"` } type Profile struct { diff --git a/gopom_test.go b/gopom_test.go index c3417d6..ddf972e 100644 --- a/gopom_test.go +++ b/gopom_test.go @@ -427,6 +427,14 @@ func TestParsing_Build(t *testing.T) { assert.Equal(t, 1, len(pl[0].Executions[0].Goals)) assert.Equal(t, "goal", pl[0].Executions[0].Goals[0]) assert.Equal(t, "inherited", pl[0].Executions[0].Inherited) + assert.Equal(t, 3, len(pl[0].Executions[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Executions[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Executions[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Executions[0].Configuration.Entries["key3"]) + assert.Equal(t, 3, len(pl[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Configuration.Entries["key3"]) assert.Equal(t, 1, len(pl[0].Dependencies)) d := pl[0].Dependencies[0] @@ -454,6 +462,14 @@ func TestParsing_Build(t *testing.T) { assert.Equal(t, 1, len(pl[0].Executions[0].Goals)) assert.Equal(t, "goal", pl[0].Executions[0].Goals[0]) assert.Equal(t, "inherited", pl[0].Executions[0].Inherited) + assert.Equal(t, 3, len(pl[0].Executions[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Executions[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Executions[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Executions[0].Configuration.Entries["key3"]) + assert.Equal(t, 3, len(pl[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Configuration.Entries["key3"]) assert.Equal(t, 1, len(pl[0].Dependencies)) d = pl[0].Dependencies[0] @@ -485,6 +501,14 @@ func TestParsing_Reporting(t *testing.T) { assert.Equal(t, 1, len(pl[0].ReportSets[0].Reports)) assert.Equal(t, "report", pl[0].ReportSets[0].Reports[0]) assert.Equal(t, "inherited", pl[0].ReportSets[0].Inherited) + assert.Equal(t, 3, len(pl[0].ReportSets[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].ReportSets[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].ReportSets[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].ReportSets[0].Configuration.Entries["key3"]) + assert.Equal(t, 3, len(pl[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Configuration.Entries["key3"]) } func TestParsing_Profiles(t *testing.T) { @@ -538,6 +562,14 @@ func TestParsing_Profiles(t *testing.T) { assert.Equal(t, 1, len(pl[0].Executions[0].Goals)) assert.Equal(t, "goal", pl[0].Executions[0].Goals[0]) assert.Equal(t, "inherited", pl[0].Executions[0].Inherited) + assert.Equal(t, 3, len(pl[0].Executions[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Executions[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Executions[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Executions[0].Configuration.Entries["key3"]) + assert.Equal(t, 3, len(pl[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Configuration.Entries["key3"]) assert.Equal(t, 1, len(pl[0].Dependencies)) d := pl[0].Dependencies[0] @@ -565,6 +597,14 @@ func TestParsing_Profiles(t *testing.T) { assert.Equal(t, 1, len(pl[0].Executions[0].Goals)) assert.Equal(t, "goal", pl[0].Executions[0].Goals[0]) assert.Equal(t, "inherited", pl[0].Executions[0].Inherited) + assert.Equal(t, 3, len(pl[0].Executions[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Executions[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Executions[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Executions[0].Configuration.Entries["key3"]) + assert.Equal(t, 3, len(pl[0].Configuration.Entries)) + assert.Equal(t, "value", pl[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", pl[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", pl[0].Configuration.Entries["key3"]) assert.Equal(t, 1, len(pl[0].Dependencies)) d = pl[0].Dependencies[0] @@ -693,6 +733,14 @@ func TestParsing_Profiles(t *testing.T) { assert.Equal(t, 1, len(repPl[0].ReportSets[0].Reports)) assert.Equal(t, "report", repPl[0].ReportSets[0].Reports[0]) assert.Equal(t, "inherited", repPl[0].ReportSets[0].Inherited) + assert.Equal(t, 3, len(repPl[0].ReportSets[0].Configuration.Entries)) + assert.Equal(t, "value", repPl[0].ReportSets[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", repPl[0].ReportSets[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", repPl[0].ReportSets[0].Configuration.Entries["key3"]) + assert.Equal(t, 3, len(repPl[0].Configuration.Entries)) + assert.Equal(t, "value", repPl[0].Configuration.Entries["key"]) + assert.Equal(t, "value2", repPl[0].Configuration.Entries["key2"]) + assert.Equal(t, "value3", repPl[0].Configuration.Entries["key3"]) } func Test_ParsingParentProperties(t *testing.T) { @@ -732,9 +780,10 @@ func Test_ParsingNotifierConfigurations(t *testing.T) { func Test_MarshalingProjectToXML(t *testing.T) { ignitePlugin := Plugin{ - GroupID: "org.apache.ignite", - ArtifactID: "ignite-core", - Version: "2.14.0", + GroupID: "org.apache.ignite", + ArtifactID: "ignite-core", + Version: "2.14.0", + Configuration: Properties{Entries: map[string]string{}}, } // Add plugin to build plugins of original project p and marshal it to XML.