mavenReactorService 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/mavenReactorization +7 -0
- data/bin/setup +8 -0
- data/lib/mavenReactorService.rb +5 -0
- data/lib/mavenReactorService/BasicInfoHandler.rb +173 -0
- data/lib/mavenReactorService/DMAndPMManagementForExternalConfiguration.rb +205 -0
- data/lib/mavenReactorService/DependencyHandler.rb +264 -0
- data/lib/mavenReactorService/DependencyManagementHandler.rb +183 -0
- data/lib/mavenReactorService/DeveloperAndContributors.rb +130 -0
- data/lib/mavenReactorService/InterDependencyHandler.rb +87 -0
- data/lib/mavenReactorService/MergeRepository.rb +98 -0
- data/lib/mavenReactorService/MoveCommonPropertiesToRootPom.rb +83 -0
- data/lib/mavenReactorService/MoveDistributionManagement.rb +68 -0
- data/lib/mavenReactorService/MvnReactorization.rb +209 -0
- data/lib/mavenReactorService/ParentPomHandler.rb +71 -0
- data/lib/mavenReactorService/PluginConfigurationHandler.rb +106 -0
- data/lib/mavenReactorService/PluginHandler.rb +292 -0
- data/lib/mavenReactorService/PluginManagementHandler.rb +391 -0
- data/lib/mavenReactorService/PropertyHandler.rb +129 -0
- data/lib/mavenReactorService/ReactorCommands.rb +49 -0
- data/lib/mavenReactorService/ReactorHandler.rb +309 -0
- data/lib/mavenReactorService/SiteAndEclipsePluginHandler.rb +105 -0
- data/lib/mavenReactorService/ValidateProjects.rb +70 -0
- data/lib/mavenReactorService/version.rb +3 -0
- data/mavenReactorService.gemspec +39 -0
- metadata +146 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
class ParentPomHandler
|
2
|
+
@@dependencyHandler = DependencyHandler.new
|
3
|
+
@@pluginManagementHandler = PluginManagementHandler.new
|
4
|
+
|
5
|
+
def makeCordinateFromUrl(externalPomUrl)
|
6
|
+
cordinatesArr = Array.new
|
7
|
+
pomDoc = Nokogiri::XML(open("#{externalPomUrl}"))
|
8
|
+
cordinatesArr.push(pomDoc.at("project/groupId").text)
|
9
|
+
cordinatesArr.push(pomDoc.at("project/artifactId").text)
|
10
|
+
cordinatesArr.push(pomDoc.at("project/version").text)
|
11
|
+
return cordinatesArr
|
12
|
+
end
|
13
|
+
|
14
|
+
def makeMbpCordinateFromOriginalPom(pom_document)
|
15
|
+
parentNode = pom_document.at("project/parent")
|
16
|
+
cordinateArr = Array.new
|
17
|
+
grpId = parentNode.at("groupId").text
|
18
|
+
artifactId = parentNode.at("artifactId").text
|
19
|
+
version = parentNode.at("version").text
|
20
|
+
if (grpId == "com.cerner.maven" and artifactId == "maven-base-pom")
|
21
|
+
cordinateArr.push(grpId)
|
22
|
+
cordinateArr.push(artifactId)
|
23
|
+
cordinateArr.push(version)
|
24
|
+
end
|
25
|
+
return cordinateArr
|
26
|
+
end
|
27
|
+
|
28
|
+
def putParentInReactorPom(cordinatesArr,project_directory_path)
|
29
|
+
fullPomPath = "#{project_directory_path}/pom.xml"
|
30
|
+
pom_document = Nokogiri::XML(open(fullPomPath))
|
31
|
+
grpId = cordinatesArr[0]
|
32
|
+
artifactId = cordinatesArr[1]
|
33
|
+
version = cordinatesArr[2]
|
34
|
+
if (pom_document.at_css("project/parent").nil?)
|
35
|
+
nokObj = Nokogiri::XML::Node
|
36
|
+
projectNode = pom_document.at("project")
|
37
|
+
parentNode = nokObj.new("parent" , projectNode)
|
38
|
+
grpNode = nokObj.new("groupId" , projectNode)
|
39
|
+
grpNode.content = grpId
|
40
|
+
artifactNode = nokObj.new("artifactId" , projectNode)
|
41
|
+
artifactNode.content = artifactId
|
42
|
+
versionNode = nokObj.new("version" , projectNode)
|
43
|
+
versionNode.content = version
|
44
|
+
parentNode.add_child(grpNode)
|
45
|
+
parentNode.add_child(artifactNode)
|
46
|
+
parentNode.add_child(versionNode)
|
47
|
+
pom_nokogiri = @@dependencyHandler.add_node_element('project', parentNode, pom_document)
|
48
|
+
File.write(fullPomPath, pom_nokogiri)
|
49
|
+
end
|
50
|
+
return true
|
51
|
+
end
|
52
|
+
|
53
|
+
def makeOriginalPomUrl(pom_document)
|
54
|
+
orginalCordinateArr = Array.new
|
55
|
+
grpId = pom_document.at("project/parent/groupId").text
|
56
|
+
artifactId = pom_document.at("project/parent/artifactId").text
|
57
|
+
version = pom_document.at("project/parent/version").text
|
58
|
+
orginalCordinateArr.push(grpId)
|
59
|
+
orginalCordinateArr.push(artifactId)
|
60
|
+
orginalCordinateArr.push(version)
|
61
|
+
return orginalCordinateArr
|
62
|
+
end
|
63
|
+
|
64
|
+
def compareTwoCordinatesArr(urlCordinate,originalPomCordinate)
|
65
|
+
isIdentical = false
|
66
|
+
if (urlCordinate.sort == originalPomCordinate.sort)
|
67
|
+
isIdentical=true
|
68
|
+
end
|
69
|
+
return isIdentical
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
class PluginConfigurationHandler
|
2
|
+
@@reactorHandler = ReactorHandler.new
|
3
|
+
@@xPathOfLeafNode = nil
|
4
|
+
@@leafNodesXpathMasterList = nil
|
5
|
+
@@mvnReactorization = MvnReactorization.new
|
6
|
+
pluginConfigMap = Hash.new
|
7
|
+
def mergePluginConfiguration (project_directory_path,projectsWithExternalConfiguration)
|
8
|
+
projectsWithExternalConfiguration.each do |projectPath|
|
9
|
+
fullPomPath = "#{projectPath}/pom.xml"
|
10
|
+
modulePomDoc = Nokogiri::XML(open(fullPomPath))
|
11
|
+
if(!modulePomDoc.nil?)
|
12
|
+
modulePomDoc.css('project/build/plugins/plugin').each do|plugin|
|
13
|
+
@@leafNodesXpathMasterList = Array.new
|
14
|
+
configNode = plugin.at('configuration')
|
15
|
+
executionsNode = plugin.at('executions')
|
16
|
+
if (!configNode.nil? and configNode.parent.name == "plugin")
|
17
|
+
findConfigurationLeafNode(configNode)
|
18
|
+
xpathConfigList = @@leafNodesXpathMasterList
|
19
|
+
@@leafNodesXpathMasterList = Array.new
|
20
|
+
if (!executionsNode.nil? and executionsNode.parent.name == "plugin")
|
21
|
+
executionsNode.css("execution").each do |eachExecution|
|
22
|
+
exeConfig = eachExecution.at("configuration")
|
23
|
+
if (!exeConfig.nil?)
|
24
|
+
findConfigurationLeafNode(exeConfig)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
commonList = xpathConfigList & @@leafNodesXpathMasterList.uniq
|
29
|
+
removeTagFromExecutions(commonList,plugin)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
@@mvnReactorization.write_nokogiri_to_xml(fullPomPath, modulePomDoc)
|
33
|
+
puts "Plugin Configuration is done"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def removeTagFromExecutions(commonList,plugin)
|
39
|
+
if (!commonList.nil? and !commonList.empty?)
|
40
|
+
commonList.each do |eachEntry|
|
41
|
+
lastValArr = eachEntry.split(">")
|
42
|
+
lastVal = lastValArr.last
|
43
|
+
finalEntry = "executions>execution>#{eachEntry}"
|
44
|
+
finalEntry = finalEntry.chomp(">#{lastVal}")
|
45
|
+
plugin.css(finalEntry).each do |eachEntry|
|
46
|
+
textVal = eachEntry.text
|
47
|
+
if (!textVal.nil? and !textVal.empty? and textVal == lastVal)
|
48
|
+
eachEntry.remove
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def findConfigurationLeafNode (configuration)
|
57
|
+
configuration.children.each do |leafNode|
|
58
|
+
if leafNode.children.length>1
|
59
|
+
findConfigurationLeafNode(leafNode)
|
60
|
+
else
|
61
|
+
if leafNode.name != 'text'
|
62
|
+
findXpathOfLeafNode (leafNode)
|
63
|
+
@@xPathOfLeafNode = "#{@@xPathOfLeafNode}#{leafNode.name}>#{leafNode.text}"
|
64
|
+
end
|
65
|
+
if !@@xPathOfLeafNode.nil?
|
66
|
+
@@leafNodesXpathMasterList.push(@@xPathOfLeafNode)
|
67
|
+
end
|
68
|
+
@@xPathOfLeafNode = nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def findXpathOfLeafNode (leafNode)
|
74
|
+
if (leafNode.parent.name != 'plugin' && leafNode.parent.name != 'text' && leafNode.parent.name != 'execution')
|
75
|
+
@@xPathOfLeafNode = "#{leafNode.parent.name}>#{@@xPathOfLeafNode}"
|
76
|
+
findXpathOfLeafNode(leafNode.parent)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def AppendLeafNodesToOuterConfig (plugin,xPathsLeafNode)
|
81
|
+
plugin.css('configuration').each do |configuration|
|
82
|
+
if configuration.parent.name == "plugin"
|
83
|
+
|
84
|
+
puts configuration
|
85
|
+
puts "*********************************************************************"
|
86
|
+
puts xPathsLeafNode
|
87
|
+
|
88
|
+
leafNodeXpathArray = xPathsLeafNode.split('>')
|
89
|
+
#nodeToCheckAndCreate = leafNodeXpathArray [leafNodeXpathArray.length - ]
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# puts plugin
|
95
|
+
# puts "*********************************************"
|
96
|
+
# puts xPathsLeafNode
|
97
|
+
|
98
|
+
# pluginConfigMap.each do |plugin,nodes|
|
99
|
+
# if !nodes.empty?
|
100
|
+
# puts "#{plugin} => #{nodes}"
|
101
|
+
#
|
102
|
+
# end
|
103
|
+
# end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,292 @@
|
|
1
|
+
class PluginHandler
|
2
|
+
@@basicInfoHandler = BasicInfoHandler.new
|
3
|
+
@@dependencyHandler = DependencyHandler.new
|
4
|
+
@@reactorHandler = ReactorHandler.new
|
5
|
+
@@xpathOfPlugin=nil
|
6
|
+
# remove pluginmanagement section
|
7
|
+
def removePluginManagementTag()
|
8
|
+
efftive_pom_document = @@basicInfoHandler.copyTagsFromEffectivePom(Dir.getwd)
|
9
|
+
temp_pom_document = Nokogiri::XML(open("temp.xml"))
|
10
|
+
buildNode = temp_pom_document.at("project/build")
|
11
|
+
if !buildNode.nil?
|
12
|
+
#If condition will come
|
13
|
+
buildNode.at("pluginManagement").remove
|
14
|
+
formated_pom_doc = @@dependencyHandler.add_node_element("project",buildNode,temp_pom_document)
|
15
|
+
File.write("temp.xml", formated_pom_doc)
|
16
|
+
puts "Plugins management is removed"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def removeExtraTag(tagName)
|
21
|
+
temp_pom_document = Nokogiri::XML(open("temp.xml"))
|
22
|
+
buildNode = temp_pom_document.at("project/#{tagName}")
|
23
|
+
if !buildNode.nil?
|
24
|
+
srcDirectoryNode = buildNode.css("sourceDirectory")
|
25
|
+
scriptSourceDirectoryNode = buildNode.css("scriptSourceDirectory")
|
26
|
+
testSourceDirectoryNode = buildNode.css("testSourceDirectory")
|
27
|
+
outputDirectoryNode = buildNode.css("outputDirectory")
|
28
|
+
testOutputDirectoryNode = buildNode.css("testOutputDirectory")
|
29
|
+
resourcesNode = buildNode.css("resources")
|
30
|
+
testResourcesNode = buildNode.css("testResources")
|
31
|
+
directoryNode = buildNode.css("directory")
|
32
|
+
finalNameNode = buildNode.css("finalName")
|
33
|
+
additionalClasspathElementsNode = buildNode.css("additionalClasspathElements")
|
34
|
+
if !srcDirectoryNode.nil?
|
35
|
+
srcDirectoryNode.each do |eachSrcDirectory|
|
36
|
+
eachSrcDirectory.remove
|
37
|
+
end
|
38
|
+
end
|
39
|
+
if !scriptSourceDirectoryNode.nil?
|
40
|
+
scriptSourceDirectoryNode.each do |eachScriptSourceDirectory|
|
41
|
+
eachScriptSourceDirectory.remove
|
42
|
+
end
|
43
|
+
end
|
44
|
+
if !testSourceDirectoryNode.nil?
|
45
|
+
testSourceDirectoryNode.each do |eachTestSourceDirectory|
|
46
|
+
eachTestSourceDirectory.remove
|
47
|
+
end
|
48
|
+
end
|
49
|
+
if !outputDirectoryNode.nil?
|
50
|
+
outputDirectoryNode.each do |eachOutputDirectory|
|
51
|
+
eachOutputDirectory.remove
|
52
|
+
end
|
53
|
+
end
|
54
|
+
if !testOutputDirectoryNode.nil?
|
55
|
+
testOutputDirectoryNode.each do |eachTestOutputDirectory|
|
56
|
+
eachTestOutputDirectory.remove
|
57
|
+
end
|
58
|
+
end
|
59
|
+
if !resourcesNode.nil?
|
60
|
+
resourcesNode.each do |eachResources|
|
61
|
+
eachResources.remove
|
62
|
+
end
|
63
|
+
end
|
64
|
+
if !testResourcesNode.nil?
|
65
|
+
testResourcesNode.each do |eachTestResources|
|
66
|
+
eachTestResources.remove
|
67
|
+
end
|
68
|
+
end
|
69
|
+
if !directoryNode.nil?
|
70
|
+
directoryNode.each do |eachDirectory|
|
71
|
+
eachDirectory.remove
|
72
|
+
end
|
73
|
+
end
|
74
|
+
if !finalNameNode.nil?
|
75
|
+
finalNameNode.each do |eachFinalName|
|
76
|
+
eachFinalName.remove
|
77
|
+
end
|
78
|
+
end
|
79
|
+
if !additionalClasspathElementsNode.nil?
|
80
|
+
additionalClasspathElementsNode.each do |eachAdditionalClasspathElements|
|
81
|
+
eachAdditionalClasspathElements.remove
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
formated_pom_doc = @@dependencyHandler.add_node_element("project",buildNode,temp_pom_document)
|
86
|
+
File.write("temp.xml", formated_pom_doc)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def addBuildTag()
|
91
|
+
efftive_pom_document = @@basicInfoHandler.copyTagsFromEffectivePom(Dir.getwd)
|
92
|
+
allplugins = efftive_pom_document.at("project/build")
|
93
|
+
if !allplugins.nil?
|
94
|
+
tempXml = "temp.xml"
|
95
|
+
File.write(tempXml, allplugins, File.size(tempXml), mode: 'a')
|
96
|
+
puts "Plugins are added"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
def addReportingTag()
|
102
|
+
efftive_pom_document = @@basicInfoHandler.copyTagsFromEffectivePom(Dir.getwd)
|
103
|
+
allplugins = efftive_pom_document.at("project/reporting")
|
104
|
+
if !allplugins.nil?
|
105
|
+
tempXml = "temp.xml"
|
106
|
+
File.write(tempXml, allplugins, File.size(tempXml), mode: 'a')
|
107
|
+
puts "Reporting Plugins are added"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# make a list of plugins from effective pom
|
112
|
+
def getGrpAndArtifactIdOfPlugins(tagName=nil)
|
113
|
+
temp_pom_document = Nokogiri::XML(open("temp.xml"))
|
114
|
+
pluginList = Array.new
|
115
|
+
buildPluginPath = "project/build/plugins/plugin"
|
116
|
+
reportingPluginPath = "project/reporting/plugins/plugin"
|
117
|
+
pluginNode = nil
|
118
|
+
if (tagName == "reporting")
|
119
|
+
pluginNode = temp_pom_document.css(reportingPluginPath)
|
120
|
+
else
|
121
|
+
pluginNode = temp_pom_document.css(buildPluginPath)
|
122
|
+
end
|
123
|
+
pluginNode.each do |eachPlugin|
|
124
|
+
grpId=nil
|
125
|
+
if (!eachPlugin.at("groupId").nil? and eachPlugin.at("groupId").parent.name == "plugin")
|
126
|
+
grpId = eachPlugin.at("groupId").text
|
127
|
+
else
|
128
|
+
grpId = "org.apache.maven.plugins"
|
129
|
+
end
|
130
|
+
artifactId = eachPlugin.at("artifactId").text
|
131
|
+
fullPlugin = "#{grpId}:#{artifactId}"
|
132
|
+
pluginList.push(fullPlugin)
|
133
|
+
end
|
134
|
+
return pluginList
|
135
|
+
end
|
136
|
+
|
137
|
+
# findout the common plugin in original pom
|
138
|
+
def compareWithOriginalPomPlugin(pluginList,tagName=nil)
|
139
|
+
pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
|
140
|
+
temp_pom_document = @@reactorHandler.parse_xml_from_file("temp.xml")
|
141
|
+
pluginNode = nil
|
142
|
+
pomFilePluginNode = nil
|
143
|
+
toAddPath=nil
|
144
|
+
if tagName == "reporting"
|
145
|
+
pluginNode = temp_pom_document.at("project/reporting/plugins")
|
146
|
+
pomFilePluginNode = pom_document.css("project/reporting/plugins/plugin")
|
147
|
+
toAddPath = "project/reporting"
|
148
|
+
else
|
149
|
+
pluginNode = temp_pom_document.at("project/build/plugins")
|
150
|
+
pomFilePluginNode = pom_document.css("project/build/plugins/plugin")
|
151
|
+
toAddPath = "project/build"
|
152
|
+
end
|
153
|
+
pomFilePluginNode.each do |eachPlugin|
|
154
|
+
grpId = eachPlugin.at("groupId").text
|
155
|
+
artifactId = eachPlugin.at("artifactId").text
|
156
|
+
fullPlugin = "#{grpId}:#{artifactId}"
|
157
|
+
if pluginList.include?fullPlugin
|
158
|
+
handlePlaceholder(eachPlugin,fullPlugin,pluginNode)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
formated_pom_doc = @@dependencyHandler.add_node_element(toAddPath,pluginNode,temp_pom_document)
|
162
|
+
File.write("temp.xml", formated_pom_doc.to_xml)
|
163
|
+
end
|
164
|
+
|
165
|
+
# findout the common plugin in parent
|
166
|
+
def compareWithParentPomPlugin(pluginList,tagName=nil)
|
167
|
+
puts "Parent plugin placeholder replacement is started"
|
168
|
+
pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
|
169
|
+
parent = pom_document.at("project/parent")
|
170
|
+
if !parent.nil?
|
171
|
+
parent_pom_document = @@dependencyHandler.getParentPomDomObjFromUrl(pom_document)
|
172
|
+
temp_pom_document = @@reactorHandler.parse_xml_from_file("temp.xml")
|
173
|
+
pluginNode = nil
|
174
|
+
pomFilePluginNode = nil
|
175
|
+
toAddPath=nil
|
176
|
+
if tagName == "reporting"
|
177
|
+
pluginNode = temp_pom_document.at("project/reporting/plugins")
|
178
|
+
pomFilePluginNode = parent_pom_document.css("project/reporting/plugins/plugin")
|
179
|
+
toAddPath = "project/reporting"
|
180
|
+
else
|
181
|
+
pluginNode = temp_pom_document.at("project/build/plugins")
|
182
|
+
pomFilePluginNode = parent_pom_document.css("project/build/plugins/plugin")
|
183
|
+
toAddPath = "project/build"
|
184
|
+
end
|
185
|
+
pomFilePluginNode.each do |eachPlugin|
|
186
|
+
grpId = eachPlugin.at("groupId").text
|
187
|
+
artifactId = eachPlugin.at("artifactId").text
|
188
|
+
fullPlugin = "#{grpId}:#{artifactId}"
|
189
|
+
if pluginList.include?fullPlugin
|
190
|
+
handlePlaceholder(eachPlugin,fullPlugin,pluginNode)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
formated_pom_doc = @@dependencyHandler.add_node_element(toAddPath,pluginNode,temp_pom_document)
|
194
|
+
File.write("temp.xml", formated_pom_doc.to_xml)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# findout the common plugin in grand parent
|
199
|
+
def compareWithGrandParentPomPlugin(pluginList,tagName=nil)
|
200
|
+
pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
|
201
|
+
parent = pom_document.at("project/parent")
|
202
|
+
if !parent.nil?
|
203
|
+
parent_pom_document = @@dependencyHandler.getParentPomDomObjFromUrl(pom_document)
|
204
|
+
grandParent = parent_pom_document.at("project/parent")
|
205
|
+
if !grandParent.nil?
|
206
|
+
grand_parent_pom_document = @@dependencyHandler.getParentPomDomObjFromUrl(parent_pom_document)
|
207
|
+
temp_pom_document = @@reactorHandler.parse_xml_from_file("temp.xml")
|
208
|
+
pluginNode = nil
|
209
|
+
pomFilePluginNode = nil
|
210
|
+
toAddPath=nil
|
211
|
+
if tagName == "reporting"
|
212
|
+
pluginNode = temp_pom_document.at("project/reporting/plugins")
|
213
|
+
pomFilePluginNode = grand_parent_pom_document.css("project/reporting/plugins/plugin")
|
214
|
+
toAddPath = "project/reporting"
|
215
|
+
else
|
216
|
+
pluginNode = temp_pom_document.at("project/build/plugins")
|
217
|
+
pomFilePluginNode = grand_parent_pom_document.css("project/build/plugins/plugin")
|
218
|
+
toAddPath = "project/build"
|
219
|
+
end
|
220
|
+
pomFilePluginNode.each do |eachPlugin|
|
221
|
+
grpId = eachPlugin.at("groupId").text
|
222
|
+
artifactId = eachPlugin.at("artifactId").text
|
223
|
+
fullPlugin = "#{grpId}:#{artifactId}"
|
224
|
+
if pluginList.include?fullPlugin
|
225
|
+
handlePlaceholder(eachPlugin,fullPlugin,pluginNode)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
formated_pom_doc = @@dependencyHandler.add_node_element(toAddPath,pluginNode,temp_pom_document)
|
229
|
+
File.write("temp.xml", formated_pom_doc.to_xml)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# handle placeholder operation
|
235
|
+
def handlePlaceholder(eachPlugin,fullPlugin,pluginNode)
|
236
|
+
eachPlugin.children.each do |eachTag|
|
237
|
+
if (eachTag.children.length>1)
|
238
|
+
handlePlaceholder(eachTag,fullPlugin,pluginNode)
|
239
|
+
else
|
240
|
+
pluginVal = eachTag.text
|
241
|
+
plugintag = eachTag.name
|
242
|
+
if (pluginVal.include?"${" and plugintag!="#cdata-section")
|
243
|
+
@@xpathOfPlugin=nil
|
244
|
+
createXpathOfTag(eachTag)
|
245
|
+
replaceTagValInTemp(fullPlugin,plugintag,pluginVal,pluginNode)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# create xpath of placeholder tag
|
252
|
+
def createXpathOfTag(eachTag)
|
253
|
+
if (eachTag.parent.name != "plugin")
|
254
|
+
@@xpathOfPlugin = "#{eachTag.parent.name}/#{@@xpathOfPlugin}"
|
255
|
+
createXpathOfTag(eachTag.parent)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# introduce place holder if found in original, parent or grand parent
|
260
|
+
def replaceTagValInTemp(fullPlugin,tagName,tagVal,pluginNode)
|
261
|
+
temp_pom_document = @@reactorHandler.parse_xml_from_file("temp.xml")
|
262
|
+
pluginNode.css("plugin").each do |eachPlugin|
|
263
|
+
grpId=nil
|
264
|
+
if (!eachPlugin.at("groupId").nil? and eachPlugin.at("groupId").parent.name == "plugin")
|
265
|
+
grpId = eachPlugin.at("groupId").text
|
266
|
+
else
|
267
|
+
grpId = "org.apache.maven.plugins"
|
268
|
+
end
|
269
|
+
artifactId = eachPlugin.at("artifactId").text
|
270
|
+
tempFullPlugin = "#{grpId}:#{artifactId}"
|
271
|
+
if (fullPlugin == tempFullPlugin)
|
272
|
+
fullXpath = "#{@@xpathOfPlugin}#{tagName}"
|
273
|
+
deleteNode = eachPlugin.at(fullXpath)
|
274
|
+
deleteParent = deleteNode.parent
|
275
|
+
deleteNode.remove
|
276
|
+
nokObj = Nokogiri::XML::Node
|
277
|
+
projectNode = temp_pom_document.at("project")
|
278
|
+
tagNode = nokObj.new(tagName,projectNode)
|
279
|
+
tagNode.content=tagVal
|
280
|
+
deleteParent.add_child(tagNode)
|
281
|
+
# eachPlugin.css("configuration").each do |eachConfig|
|
282
|
+
# parentName = eachConfig.parent.name
|
283
|
+
# if (parentName == "plugin")
|
284
|
+
# eachConfig.remove
|
285
|
+
# end
|
286
|
+
# end
|
287
|
+
pluginNode.add_child(eachPlugin)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|