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,264 @@
|
|
1
|
+
require 'mavenReactorService/BasicInfoHandler'
|
2
|
+
|
3
|
+
# handle the dependencies and it's place holder
|
4
|
+
class DependencyHandler
|
5
|
+
@@reactorHandler = ReactorHandler.new
|
6
|
+
@@basicInfoHandler = BasicInfoHandler.new
|
7
|
+
def projectPomDependencyHandler()
|
8
|
+
efftive_pom_document = @@basicInfoHandler.copyTagsFromEffectivePom(Dir.getwd)
|
9
|
+
alldependencies = efftive_pom_document.at("project/dependencies")
|
10
|
+
alldependencyManagement = efftive_pom_document.at("project/dependencyManagement")
|
11
|
+
if !alldependencies.nil?
|
12
|
+
tempXml = "temp.xml"
|
13
|
+
File.write(tempXml, alldependencies, File.size(tempXml), mode: 'a')
|
14
|
+
puts "Dependencies are added"
|
15
|
+
end
|
16
|
+
if !alldependencyManagement.nil?
|
17
|
+
tempXml = "temp.xml"
|
18
|
+
File.write(tempXml, alldependencyManagement, File.size(tempXml), mode: 'a')
|
19
|
+
puts "Dependency management is added"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# return the dependency list of effetive-pom
|
25
|
+
def getTempDependencyList()
|
26
|
+
temp_pom_document = Nokogiri::XML(open("temp.xml"))
|
27
|
+
dependencyList = Array.new
|
28
|
+
temp_pom_document.css("project/dependencies/dependency").each do |eachDependecy|
|
29
|
+
grpId = eachDependecy.at("groupId").text
|
30
|
+
artifactId = eachDependecy.at("artifactId").text
|
31
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
32
|
+
dependencyList.push(fullDependency)
|
33
|
+
end
|
34
|
+
return dependencyList
|
35
|
+
end
|
36
|
+
|
37
|
+
# return the union of dependencies in original-pom
|
38
|
+
def getOriginalDependencyMap()
|
39
|
+
pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
|
40
|
+
dependencyMap = Hash.new
|
41
|
+
|
42
|
+
if (!pom_document.at_css("project/dependencyManagement/dependencies/dependency").nil?)
|
43
|
+
pom_document.css("project/dependencyManagement/dependencies/dependency").each do |eachDependecy|
|
44
|
+
grpId = eachDependecy.at("groupId").text
|
45
|
+
artifactId = eachDependecy.at("artifactId").text
|
46
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
47
|
+
version = nil
|
48
|
+
if (!eachDependecy.at("version").nil?)
|
49
|
+
version = eachDependecy.at("version").text
|
50
|
+
end
|
51
|
+
dependencyMap[fullDependency] = version
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if (!pom_document.at_css("project/dependencies/dependency").nil?)
|
56
|
+
pom_document.css("project/dependencies/dependency").each do |eachDependecy|
|
57
|
+
grpId = eachDependecy.at("groupId").text
|
58
|
+
artifactId = eachDependecy.at("artifactId").text
|
59
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
60
|
+
version = nil
|
61
|
+
if (!eachDependecy.at("version").nil?)
|
62
|
+
version = eachDependecy.at("version").text
|
63
|
+
end
|
64
|
+
exsistingDependency = dependencyMap[fullDependency]
|
65
|
+
if (!exsistingDependency.nil? and !version.nil?)
|
66
|
+
dependencyMap[fullDependency] = version
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return dependencyMap
|
71
|
+
end
|
72
|
+
|
73
|
+
# return the union of dependencies in parent
|
74
|
+
def getImmediateParentDependencyMap()
|
75
|
+
pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
|
76
|
+
parent = pom_document.at("project/parent")
|
77
|
+
dependencyMap = Hash.new
|
78
|
+
if !parent.nil?
|
79
|
+
parent_pom_document = getParentPomDomObjFromUrl(pom_document)
|
80
|
+
if (!parent_pom_document.at_css("project/dependencyManagement/dependencies/dependency").nil?)
|
81
|
+
parent_pom_document.css("project/dependencyManagement/dependencies/dependency").each do |eachDependecy|
|
82
|
+
grpId = eachDependecy.at("groupId").text
|
83
|
+
artifactId = eachDependecy.at("artifactId").text
|
84
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
85
|
+
version = nil
|
86
|
+
if (!eachDependecy.at("version").nil?)
|
87
|
+
version = eachDependecy.at("version").text
|
88
|
+
end
|
89
|
+
dependencyMap[fullDependency] = version
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
if (!parent_pom_document.at_css("project/dependencies/dependency").nil?)
|
94
|
+
parent_pom_document.css("project/dependencies/dependency").each do |eachDependecy|
|
95
|
+
grpId = eachDependecy.at("groupId").text
|
96
|
+
artifactId = eachDependecy.at("artifactId").text
|
97
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
98
|
+
version = nil
|
99
|
+
if (!eachDependecy.at("version").nil?)
|
100
|
+
version = eachDependecy.at("version").text
|
101
|
+
end
|
102
|
+
exsistingDependency = dependencyMap[fullDependency]
|
103
|
+
if (!exsistingDependency.nil? and !version.nil?)
|
104
|
+
dependencyMap[fullDependency] = version
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
return dependencyMap
|
111
|
+
end
|
112
|
+
|
113
|
+
# return the union of dependencies in grand-parent
|
114
|
+
def getgrandParentDependencyMap()
|
115
|
+
pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
|
116
|
+
parent = pom_document.at("project/parent")
|
117
|
+
dependencyMap = Hash.new
|
118
|
+
if !parent.nil?
|
119
|
+
parent_pom_document = getParentPomDomObjFromUrl(pom_document)
|
120
|
+
grandParent = parent_pom_document.at("project/parent")
|
121
|
+
if !grandParent.nil?
|
122
|
+
grand_parent_pom_document = getParentPomDomObjFromUrl(parent_pom_document)
|
123
|
+
|
124
|
+
if (!grand_parent_pom_document.at_css("project/dependencyManagement/dependencies/dependency").nil?)
|
125
|
+
grand_parent_pom_document.css("project/dependencyManagement/dependencies/dependency").each do |eachDependecy|
|
126
|
+
grpId = eachDependecy.at("groupId").text
|
127
|
+
artifactId = eachDependecy.at("artifactId").text
|
128
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
129
|
+
version = nil
|
130
|
+
if (!eachDependecy.at("version").nil?)
|
131
|
+
version = eachDependecy.at("version").text
|
132
|
+
end
|
133
|
+
dependencyMap[fullDependency] = version
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
if (!grand_parent_pom_document.at_css("project/dependencies/dependency").nil?)
|
138
|
+
grand_parent_pom_document.css("project/dependencies/dependency").each do |eachDependecy|
|
139
|
+
grpId = eachDependecy.at("groupId").text
|
140
|
+
artifactId = eachDependecy.at("artifactId").text
|
141
|
+
fullDependency = "#{grpId}:#{artifactId}"
|
142
|
+
version = nil
|
143
|
+
if (!eachDependecy.at("version").nil?)
|
144
|
+
version = eachDependecy.at("version").text
|
145
|
+
end
|
146
|
+
exsistingDependency = dependencyMap[fullDependency]
|
147
|
+
if (!exsistingDependency.nil? and !version.nil?)
|
148
|
+
dependencyMap[fullDependency] = version
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
return dependencyMap
|
155
|
+
end
|
156
|
+
|
157
|
+
# create domobj of parent and grand parent
|
158
|
+
def getParentPomDomObjFromUrl(pom_document)
|
159
|
+
groupId = pom_document.css("parent/groupId").text
|
160
|
+
artifactId = pom_document.css("parent/artifactId").text
|
161
|
+
version = pom_document.css("parent/version").text
|
162
|
+
groupId = "#{groupId.gsub(".","/")}"
|
163
|
+
urlArr = getRepositories(pom_document)
|
164
|
+
urlArr.each do |eachUrl|
|
165
|
+
filteredUrl = "#{eachUrl}/#{groupId}/#{artifactId}/#{version}"
|
166
|
+
begin
|
167
|
+
pom_html_doc = Nokogiri::HTML(open(filteredUrl))
|
168
|
+
latestPom = nil
|
169
|
+
pom_html_doc.css('a').each do |eachref|
|
170
|
+
if (eachref.text.end_with?".pom")
|
171
|
+
latestPom = eachref.text
|
172
|
+
end
|
173
|
+
end
|
174
|
+
filteredUrl = "#{filteredUrl}/#{latestPom}"
|
175
|
+
parent_pom_document = Nokogiri::XML(open(filteredUrl))
|
176
|
+
rescue
|
177
|
+
puts "Wrong Url :::: #{filteredUrl}"
|
178
|
+
end
|
179
|
+
if !parent_pom_document.nil?
|
180
|
+
return parent_pom_document
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# indentify the actual url of parent
|
186
|
+
def getRepositories(pom_document)
|
187
|
+
urlArr = Array.new
|
188
|
+
pom_document.css("repositories/repository").each do |eachRepo|
|
189
|
+
eachUrl = eachRepo.at_css("url").text
|
190
|
+
lastChar = eachUrl[-1,1]
|
191
|
+
if lastChar=="/"
|
192
|
+
eachUrl= eachUrl[0,eachUrl.length-1]
|
193
|
+
end
|
194
|
+
urlArr.push(eachUrl)
|
195
|
+
end
|
196
|
+
return urlArr
|
197
|
+
end
|
198
|
+
|
199
|
+
# This api takes decision to indentify the dependency where the place holder found. #
|
200
|
+
def findPlaceHolderWithinPoms(tempDependencyList,originalDependencyMap,parentDependencyMap,grandParentDependencyMap)
|
201
|
+
if (!tempDependencyList.nil?)
|
202
|
+
originalVersion = nil
|
203
|
+
parentVersion = nil
|
204
|
+
grandParentVersion = nil
|
205
|
+
tempDependencyList.each do |eachDependency|
|
206
|
+
if (!originalDependencyMap.empty?)
|
207
|
+
originalVersion = originalDependencyMap[eachDependency]
|
208
|
+
end
|
209
|
+
if (!parentDependencyMap.empty?)
|
210
|
+
parentVersion = parentDependencyMap[eachDependency]
|
211
|
+
end
|
212
|
+
if (!grandParentDependencyMap.empty?)
|
213
|
+
grandParentVersion = grandParentDependencyMap[eachDependency]
|
214
|
+
end
|
215
|
+
if (!originalVersion.nil? and originalVersion.include? "${")
|
216
|
+
replaceVersionInTempFile(eachDependency,originalVersion)
|
217
|
+
elsif (!parentVersion.nil? and parentVersion.include? "${")
|
218
|
+
replaceVersionInTempFile(eachDependency,parentVersion)
|
219
|
+
elsif (!grandParentVersion.nil? and grandParentVersion.include? "${")
|
220
|
+
replaceVersionInTempFile(eachDependency,grandParentVersion)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# This api replace version by place-holder #
|
227
|
+
def replaceVersionInTempFile (eachDependency,version)
|
228
|
+
dependencyArr = eachDependency.split(":")
|
229
|
+
gid = dependencyArr[0]
|
230
|
+
artifactId = dependencyArr[1]
|
231
|
+
temp_pom_document = Nokogiri::XML(open("temp.xml"))
|
232
|
+
nokObj = Nokogiri::XML::Node
|
233
|
+
dependeciesNode = temp_pom_document.at("project/dependencies")
|
234
|
+
versionNode = nokObj.new("version",dependeciesNode)
|
235
|
+
versionNode.content=version
|
236
|
+
dependeciesNode.css("dependency").each do |tempDependency|
|
237
|
+
replaceDependency=nil
|
238
|
+
tempGid = tempDependency.at("groupId").text
|
239
|
+
tempArtifactId = tempDependency.at("artifactId").text
|
240
|
+
fullDependency = "#{tempGid}:#{tempArtifactId}"
|
241
|
+
if (eachDependency == fullDependency)
|
242
|
+
tempDependency.remove
|
243
|
+
tempDependency.at("version").remove
|
244
|
+
tempDependency.add_child(versionNode)
|
245
|
+
dependeciesNode.add_child(tempDependency)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
formated_pom_doc = add_node_element("project",dependeciesNode,temp_pom_document)
|
249
|
+
File.write("temp.xml", formated_pom_doc.to_xml)
|
250
|
+
end
|
251
|
+
|
252
|
+
# This api add child node in any tag #
|
253
|
+
def add_node_element(childs_parent_name, child_element, pom_nokogiri)
|
254
|
+
raise 'Parent tag is empty or nil' if childs_parent_name.nil? ||
|
255
|
+
childs_parent_name.empty?
|
256
|
+
raise 'Child element is nil' if child_element.nil?
|
257
|
+
raise 'POM Document is nil' if pom_nokogiri.nil?
|
258
|
+
childs_parent = pom_nokogiri.at_css(childs_parent_name)
|
259
|
+
childs_parent.add_child(child_element)
|
260
|
+
pom_nokogiri
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
|
@@ -0,0 +1,183 @@
|
|
1
|
+
class DependencyManagementHandler
|
2
|
+
@@reactorHandler = ReactorHandler.new
|
3
|
+
@@dependencyHandler = DependencyHandler.new
|
4
|
+
@@mvnReactorization = MvnReactorization.new
|
5
|
+
def handleDependencyManagement(project_dir)
|
6
|
+
commonDependencyList = findCommonDependency(project_dir)
|
7
|
+
putCommonDependencyInReactorPom(project_dir,commonDependencyList)
|
8
|
+
removePluginversionFromChildModule(project_dir,commonDependencyList,"project/dependencies/dependency")
|
9
|
+
removePluginversionFromChildModule(project_dir,commonDependencyList,"project/dependencyManagement/dependencies/dependency")
|
10
|
+
puts "Dependecy management is done"
|
11
|
+
end
|
12
|
+
|
13
|
+
def findCommonDependency(project_dir)
|
14
|
+
pomArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_dir,false)
|
15
|
+
if !(pomArr.nil? || pomArr.empty?)
|
16
|
+
allDepedencyList = Array.new
|
17
|
+
allDependencyManagementList = Array.new
|
18
|
+
masterList = Array.new
|
19
|
+
pomArr.each do |eachPomPath|
|
20
|
+
pom_document = @@reactorHandler.parse_xml_from_file(eachPomPath)
|
21
|
+
dependencyList = findAllDepedenciesOfAProject(pom_document,"project/dependencies/dependency")
|
22
|
+
allDepedencyList.push(dependencyList.uniq)
|
23
|
+
dependencyManagementList = findAllDepedenciesOfAProject(pom_document,"project/dependencyManagement/dependencies/dependency",dependencyList)
|
24
|
+
allDependencyManagementList.push(dependencyManagementList.uniq)
|
25
|
+
mergedList = mergeDependencies(dependencyList,dependencyManagementList)
|
26
|
+
filterList = addVersionOfMergedList(pom_document,mergedList)
|
27
|
+
masterList.push(filterList.uniq)
|
28
|
+
end
|
29
|
+
commonDependencyList = findCommonDepedencyFromMasterList(masterList)
|
30
|
+
return commonDependencyList
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def findCommonDepedencyFromMasterList(masterList)
|
35
|
+
commonDependencyList = Array.new
|
36
|
+
masterList.each_with_index do |eachPomDependencyList,index|
|
37
|
+
if index==0
|
38
|
+
commonDependencyList = eachPomDependencyList
|
39
|
+
else
|
40
|
+
commonDependencyList = commonDependencyList & eachPomDependencyList
|
41
|
+
end
|
42
|
+
end
|
43
|
+
return commonDependencyList
|
44
|
+
end
|
45
|
+
|
46
|
+
def findAllDepedenciesOfAProject(pom_document,tag,dependencyList=nil)
|
47
|
+
commonDependencyArr = Array.new
|
48
|
+
pom_document.css(tag).each do |eachDependency|
|
49
|
+
gid = eachDependency.at("groupId").text
|
50
|
+
artifactId = eachDependency.at("artifactId").text
|
51
|
+
version=nil
|
52
|
+
if !(eachDependency.at("version").nil?)
|
53
|
+
version = eachDependency.at("version").text
|
54
|
+
end
|
55
|
+
fullArtifactId = "#{gid}:#{artifactId}:#{version}"
|
56
|
+
deleteArtId = "#{gid}:#{artifactId}"
|
57
|
+
if !(commonDependencyArr.include?fullArtifactId)
|
58
|
+
if (!((!eachDependency.at("exclusions").nil?) and (eachDependency.at("exclusions").parent.name == "dependency") and (tag.include?"project/dependencyManagement")))
|
59
|
+
commonDependencyArr.push(fullArtifactId)
|
60
|
+
elsif (!dependencyList.nil?)
|
61
|
+
dependencyList.each do |eachEntry|
|
62
|
+
eachEntryArr = eachEntry.split(":")
|
63
|
+
ltstGrp = eachEntryArr[0]
|
64
|
+
ltstArtifact= eachEntryArr[1]
|
65
|
+
fullArtifact = "#{ltstGrp}:#{ltstArtifact}"
|
66
|
+
if (fullArtifact == deleteArtId)
|
67
|
+
dependencyList.delete(eachEntry)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
return commonDependencyArr
|
74
|
+
end
|
75
|
+
|
76
|
+
def mergeDependencies(allDepedencyList,allDependencyManagementList)
|
77
|
+
dependencyListWithoutVersion = Array.new
|
78
|
+
dependencyManagementListWithoutVersion = Array.new
|
79
|
+
allDepedencyList.each do |eachDependency|
|
80
|
+
eachDependencyArr = eachDependency.split(":")
|
81
|
+
cordinateDepedency = "#{eachDependencyArr[0]}:#{eachDependencyArr[1]}"
|
82
|
+
dependencyListWithoutVersion.push(cordinateDepedency)
|
83
|
+
end
|
84
|
+
allDependencyManagementList.each do |eachDependency|
|
85
|
+
eachDependencyArr = eachDependency.split(":")
|
86
|
+
cordinateDepedency = "#{eachDependencyArr[0]}:#{eachDependencyArr[1]}"
|
87
|
+
dependencyManagementListWithoutVersion.push(cordinateDepedency)
|
88
|
+
end
|
89
|
+
commonDependencyList = dependencyListWithoutVersion & dependencyManagementListWithoutVersion
|
90
|
+
uncommonDependencyList = (dependencyListWithoutVersion+dependencyManagementListWithoutVersion) - (dependencyListWithoutVersion&dependencyManagementListWithoutVersion)
|
91
|
+
mergedList = commonDependencyList + uncommonDependencyList
|
92
|
+
return mergedList
|
93
|
+
end
|
94
|
+
|
95
|
+
def addVersionOfMergedList(pom_document,mergedList)
|
96
|
+
filterMergedList = Array.new
|
97
|
+
mergedList.each do |eachEntry|
|
98
|
+
dependecyNode = pom_document.css ("project/dependencies/dependency")
|
99
|
+
dependecyManagementNode = pom_document.css ("project/dependencyManagement/dependencies/dependency")
|
100
|
+
dependecies = findVersionFromDependency(eachEntry,dependecyNode)
|
101
|
+
if dependecies.nil?
|
102
|
+
dependecies = findVersionFromDependency(eachEntry,dependecyManagementNode)
|
103
|
+
end
|
104
|
+
filterMergedList.push(dependecies)
|
105
|
+
end
|
106
|
+
return filterMergedList
|
107
|
+
end
|
108
|
+
|
109
|
+
def findVersionFromDependency(eachEntry,nodeObj)
|
110
|
+
cordinatedependency = nil
|
111
|
+
nodeObj.each do |eachNode|
|
112
|
+
gid = eachNode.at("groupId").text
|
113
|
+
artifactId = eachNode.at("artifactId").text
|
114
|
+
fullDependency = "#{gid}:#{artifactId}"
|
115
|
+
if fullDependency == eachEntry
|
116
|
+
if (eachNode.at("version") and eachNode.at("version").parent.name == "dependency")
|
117
|
+
version = eachNode.at("version").text
|
118
|
+
cordinatedependency = "#{fullDependency}:#{version}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
return cordinatedependency
|
123
|
+
end
|
124
|
+
|
125
|
+
def putCommonDependencyInReactorPom(project_directory,commonList)
|
126
|
+
pomPath = "#{project_directory}/pom.xml"
|
127
|
+
pom_document = @@reactorHandler.parse_xml_from_file(pomPath)
|
128
|
+
if commonList.length>0
|
129
|
+
nokObj = Nokogiri::XML::Node
|
130
|
+
projectNode = pom_document.at("project")
|
131
|
+
dependencyManagementNode = nokObj.new("dependencyManagement",projectNode)
|
132
|
+
dependenciesNode = nokObj.new("dependencies",projectNode)
|
133
|
+
commonList.each do |eachDependency|
|
134
|
+
dependencyArr = eachDependency.split(":")
|
135
|
+
gid = dependencyArr[0]
|
136
|
+
artifactId = dependencyArr[1]
|
137
|
+
version = dependencyArr[2]
|
138
|
+
dependencyNode = nokObj.new("dependency",projectNode)
|
139
|
+
grpNode = nokObj.new("groupId",projectNode)
|
140
|
+
grpNode.content=gid
|
141
|
+
artifactNode = nokObj.new("artifactId",projectNode)
|
142
|
+
artifactNode.content=artifactId
|
143
|
+
versionNode = nokObj.new("version",projectNode)
|
144
|
+
versionNode.content=version
|
145
|
+
dependencyNode.add_child(grpNode)
|
146
|
+
dependencyNode.add_child(artifactNode)
|
147
|
+
dependencyNode.add_child(versionNode)
|
148
|
+
dependenciesNode.add_child(dependencyNode)
|
149
|
+
end
|
150
|
+
dependencyManagementNode.add_child(dependenciesNode)
|
151
|
+
@@dependencyHandler.add_node_element('//project', dependencyManagementNode, pom_document)
|
152
|
+
@@mvnReactorization.write_nokogiri_to_xml(pomPath, pom_document)
|
153
|
+
puts "Dependency management is added in reactor pom"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def removePluginversionFromChildModule(project_directory,commonList,tag)
|
158
|
+
pomArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory,false)
|
159
|
+
if !(pomArr.nil? || pomArr.empty?)
|
160
|
+
pomArr.each do |eachPomPath|
|
161
|
+
pom_document = @@reactorHandler.parse_xml_from_file(eachPomPath)
|
162
|
+
pom_document.css(tag).each do |eachDependency|
|
163
|
+
fullDepedency=nil
|
164
|
+
grpId = eachDependency.at("groupId").text
|
165
|
+
artifactId = eachDependency.at("artifactId").text
|
166
|
+
partialDependency = "#{grpId}:#{artifactId}"
|
167
|
+
if (!eachDependency.at("version").nil?)
|
168
|
+
version = eachDependency.at("version").text
|
169
|
+
fullDepedency = "#{grpId}:#{artifactId}:#{version}"
|
170
|
+
if (commonList.include?fullDepedency)
|
171
|
+
if (tag.include?"dependencyManagement/")
|
172
|
+
eachDependency.remove
|
173
|
+
else
|
174
|
+
eachDependency.at("version").remove
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
@@mvnReactorization.write_nokogiri_to_xml(eachPomPath, pom_document)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
class DeveloperAndContributors
|
2
|
+
@@reactorHandler = ReactorHandler.new
|
3
|
+
@@mergeRepository = MergeRepository.new
|
4
|
+
@@dependencyHandler = DependencyHandler.new
|
5
|
+
def findCommonDevelopers(project_directory_path,tagName)
|
6
|
+
developerList = generateMasterDeveloperList(project_directory_path,tagName)
|
7
|
+
commonList = commonDeveloperorContributors(project_directory_path,tagName,developerList)
|
8
|
+
return commonList
|
9
|
+
end
|
10
|
+
|
11
|
+
def generateMasterDeveloperList(project_directory_path,tagName)
|
12
|
+
childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
|
13
|
+
developerList = Array.new
|
14
|
+
childPomPathArr.each do |eachChildModule|
|
15
|
+
child_pom_document = Nokogiri::XML(open(eachChildModule))
|
16
|
+
child_pom_document.css("project/#{tagName}").each do |eachChildRepo|
|
17
|
+
emailNode = eachChildRepo.at("email")
|
18
|
+
email=nil
|
19
|
+
if (!emailNode.nil? and !developerList.include?emailNode.text)
|
20
|
+
developerList.push(emailNode.text)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return developerList
|
25
|
+
end
|
26
|
+
|
27
|
+
def commonDeveloperorContributors(project_directory_path,tagName,developerList)
|
28
|
+
commonList = Array.new
|
29
|
+
pomArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
|
30
|
+
if !(pomArr.nil? || pomArr.empty?)
|
31
|
+
developerList.each do |eachDeveloper|
|
32
|
+
flag = true
|
33
|
+
pomArr.each do |eachPomPath|
|
34
|
+
if (flag)
|
35
|
+
flag=false
|
36
|
+
pom_document = @@reactorHandler.parse_xml_from_file(eachPomPath)
|
37
|
+
pom_document.css("project/#{tagName}").each do |eachChildRepo|
|
38
|
+
if (!eachChildRepo.at("email").nil?)
|
39
|
+
email= eachChildRepo.at("email").text
|
40
|
+
if (eachDeveloper==email)
|
41
|
+
flag = true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
if flag
|
46
|
+
if (!commonList.include?eachDeveloper)
|
47
|
+
commonList.push(eachDeveloper)
|
48
|
+
end
|
49
|
+
else
|
50
|
+
commonList.delete(eachDeveloper)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
return commonList
|
57
|
+
end
|
58
|
+
|
59
|
+
def mergeDeveloperAndContributors(project_directory_path,commontags,tagName)
|
60
|
+
childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
|
61
|
+
developersAndContributorsList = Array.new
|
62
|
+
emailList = Array.new
|
63
|
+
childPomPathArr.each do |eachChildModule|
|
64
|
+
child_pom_document = Nokogiri::XML(open(eachChildModule))
|
65
|
+
child_pom_document.css("project/#{tagName}").each do |eachChildRepo|
|
66
|
+
emailNode = eachChildRepo.at("email")
|
67
|
+
if !emailNode.nil?
|
68
|
+
email = emailNode.text
|
69
|
+
if (commontags.include?email and !emailList.include?email)
|
70
|
+
emailList.push(email)
|
71
|
+
developersAndContributorsList.push(eachChildRepo)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
return developersAndContributorsList
|
77
|
+
end
|
78
|
+
|
79
|
+
def addDeveloperAndContributersInReator(project_directory_path,commontags,tagName)
|
80
|
+
if (!commontags.nil? and !commontags.empty?)
|
81
|
+
@@mergeRepository.addRepoIntoReactorPom(project_directory_path,commontags,tagName)
|
82
|
+
puts "Added developers and contributors"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def removeCommonDevelopersAndContributorsFromChild(project_directory_path,commontags,tagName)
|
88
|
+
childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
|
89
|
+
childPomPathArr.each do |eachChildModule|
|
90
|
+
child_pom_document = Nokogiri::XML(open(eachChildModule))
|
91
|
+
tagArr = tagName.split("/")
|
92
|
+
baseName = tagArr[0]
|
93
|
+
lastTag = tagArr[1]
|
94
|
+
baseNode = child_pom_document.at("project/#{baseName}")
|
95
|
+
if (!baseNode.nil?)
|
96
|
+
baseNode.css(lastTag).each do |eachChildRepo|
|
97
|
+
emailNode = eachChildRepo.at("email")
|
98
|
+
if !emailNode.nil?
|
99
|
+
email = emailNode.text
|
100
|
+
if (commontags.include?email)
|
101
|
+
eachChildRepo.remove
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
pom_nokogiri = @@dependencyHandler.add_node_element('project', baseNode, child_pom_document)
|
106
|
+
File.write(eachChildModule, pom_nokogiri)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def removeEmptyTags(project_directory_path,tagName)
|
112
|
+
childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
|
113
|
+
childPomPathArr.each do |eachChildModule|
|
114
|
+
child_pom_document = Nokogiri::XML(open(eachChildModule))
|
115
|
+
tagArr = tagName.split("/")
|
116
|
+
baseName = tagArr[0]
|
117
|
+
lastTag = tagArr[1]
|
118
|
+
baseNode = child_pom_document.at("project/#{baseName}")
|
119
|
+
if (!baseNode.nil?)
|
120
|
+
lastNode = baseNode.at(lastTag)
|
121
|
+
if (lastNode.nil?)
|
122
|
+
baseNode.remove
|
123
|
+
File.write(eachChildModule, child_pom_document)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
puts "Removed Common #{tagName}"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|