mavenReactorService 0.4.0 → 0.5.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7fae17333cd252b6f09da7094ce445921ff615c4
4
- data.tar.gz: f25618f42767f75876fa0ec0463835424aea3b67
2
+ SHA256:
3
+ metadata.gz: af361c31a82706f443d9db2fedf4d6ee6b70c27e7add22d347d8eb52c7d73e76
4
+ data.tar.gz: ea6afab2f78ca51c208dbfcfa80e6277e5e599335cbec98ae883b6a96d65099d
5
5
  SHA512:
6
- metadata.gz: a59784c6f195597eb80acb45a38689c109e89a4ea5c5f75da6054990900cb3df4cf7c5768172b71294aca3dbe954aff63726a31f33d4e3db30900c0424a1117f
7
- data.tar.gz: f40bd246e989a8c78d3178f65c08d6e394ca809a96dc0d3f2fa2147f6bbe46901333812e3980419c8737d4a071eecc03302cb1e397f23a020d60c868374c99d4
6
+ metadata.gz: e00c05cf8045a878fa78f9d913df3b245932f1e5c70ea879919c971d224c39a4b3cca4bea40673195e34e51987009ba6461f3b532124e5f745b52dfb1805518a
7
+ data.tar.gz: d3dace8a55c53638eba784fe49ca91886df1f4d028f8bb243e5f3bc2a427162bf0cae6058e5dbcc16c50ca4aaf211a9e766b2265898a742b372f99e4258ffba4
@@ -4,6 +4,7 @@ require 'mavenReactorService/BasicInfoHandler'
4
4
  class DependencyHandler
5
5
  @@reactorHandler = ReactorHandler.new
6
6
  @@basicInfoHandler = BasicInfoHandler.new
7
+ @@projectURLArr= Array.new
7
8
  def projectPomDependencyHandler()
8
9
  efftive_pom_document = @@basicInfoHandler.copyTagsFromEffectivePom(Dir.getwd)
9
10
  alldependencies = efftive_pom_document.at("project/dependencies")
@@ -20,7 +21,6 @@ class DependencyHandler
20
21
  end
21
22
  end
22
23
 
23
-
24
24
  # return the dependency list of effetive-pom
25
25
  def getTempDependencyList()
26
26
  temp_pom_document = Nokogiri::XML(open("temp.xml"))
@@ -173,27 +173,39 @@ class DependencyHandler
173
173
  end
174
174
  filteredUrl = "#{filteredUrl}/#{latestPom}"
175
175
  parent_pom_document = Nokogiri::XML(open(filteredUrl))
176
+ puts "External configuration POM URL found at :: #{filteredUrl}"
176
177
  rescue
177
- puts "Wrong Url :::: #{filteredUrl}"
178
178
  end
179
179
  if !parent_pom_document.nil?
180
180
  return parent_pom_document
181
181
  end
182
182
  end
183
183
  end
184
-
185
- # indentify the actual url of parent
184
+ # indentify the actual url of parent
186
185
  def getRepositories(pom_document)
187
- urlArr = Array.new
186
+ reactorProjectArr = @@reactorHandler.getReactPOMRepos()
187
+ origProjectPOMDoc = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd)
188
+ origProjectPOMDoc.css("repositories/repository").each do |eachRepo|
189
+ eachUrl = eachRepo.at_css("url").text
190
+ eachUrl = eachUrl.end_with?("/") ? eachUrl.chop : eachUrl
191
+ if !(@@projectURLArr.include?eachUrl)
192
+ @@projectURLArr.push(eachUrl)
193
+ end
194
+ end
188
195
  pom_document.css("repositories/repository").each do |eachRepo|
189
196
  eachUrl = eachRepo.at_css("url").text
190
- lastChar = eachUrl[-1,1]
191
- if lastChar=="/"
192
- eachUrl= eachUrl[0,eachUrl.length-1]
197
+ eachUrl = eachUrl.end_with?("/") ? eachUrl.chop : eachUrl
198
+ if !(@@projectURLArr.include?eachUrl)
199
+ @@projectURLArr.push(eachUrl)
200
+ end
201
+ end
202
+
203
+ reactorProjectArr.each do |eachReactURL|
204
+ if !(@@projectURLArr.include?eachReactURL)
205
+ @@projectURLArr.push(eachReactURL)
193
206
  end
194
- urlArr.push(eachUrl)
195
207
  end
196
- return urlArr
208
+ return @@projectURLArr
197
209
  end
198
210
 
199
211
  # This api takes decision to indentify the dependency where the place holder found. #
@@ -1,6 +1,8 @@
1
1
  class MoveCommonPropertiesToRootPom
2
+
2
3
  @@reactorHandler = ReactorHandler.new
3
4
  @@modulePomPaths = nil
5
+
4
6
  def findCommonProperties (project_directory_path)
5
7
  @@modulePomPaths = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
6
8
  allModuleProperties = Array.new
@@ -9,16 +11,18 @@ class MoveCommonPropertiesToRootPom
9
11
  modulePomDoc = Nokogiri::XML(open(modulePomPath))
10
12
  modulePomDoc.css("project/properties").children.each do |property|
11
13
  if property.name != 'text' && property.name != 'comment'
12
- propertyNameValue = "#{property.name}:#{property.text}"
14
+ propertyNameValue = "#{property.name}:_#{property.text}"
13
15
  allModuleProperties.push(propertyNameValue)
14
16
  end
15
17
  end
16
18
  end
19
+
17
20
  allModuleProperties.uniq.each do |property|
18
21
  if allModuleProperties.count(property) == @@modulePomPaths.length
19
22
  commonProperties.push(property)
20
23
  end
21
24
  end
25
+
22
26
  return commonProperties
23
27
  end
24
28
 
@@ -29,7 +33,7 @@ class MoveCommonPropertiesToRootPom
29
33
  projectNode = pom_document.at('project')
30
34
  propertiesNode = nokObj.new('properties',projectNode)
31
35
  commonProperties.each do |property|
32
- propNameValue = property.split(':')
36
+ propNameValue = property.split(':_')
33
37
  propName = propNameValue[0]
34
38
  propValue = propNameValue[1]
35
39
  propNode = nokObj.new(propName,projectNode)
@@ -47,7 +51,7 @@ class MoveCommonPropertiesToRootPom
47
51
  @@modulePomPaths.each do |eachModulePath|
48
52
  pom_document = @@reactorHandler.parse_xml_from_file(eachModulePath)
49
53
  commonProperties.each do |property|
50
- propNameValue = property.split(':')
54
+ propNameValue = property.split(':_')
51
55
  propName = propNameValue[0]
52
56
  pom_document.css('project/properties').children.each do |eachProperty|
53
57
  if eachProperty.name == propName
@@ -42,25 +42,13 @@ class MvnReactorization
42
42
 
43
43
  def findHighestVersionOfPom(pomFileArr)
44
44
  tempHash=Hash.new
45
+ highestVerionArr = Array.new
45
46
  pomFileArr.each do |eachPath|
46
47
  pomDetArr = getDetails(eachPath)
47
48
  version = pomDetArr[2]
48
- numericVersion = version.split(/[^\d]/).join
49
- eachValArr = numericVersion.split('')
50
- sum=0
51
- eachValArr.each do |char|
52
- sum=sum+char.to_i
53
- end
54
- tempHash[version]=sum
55
- end
56
- tempVal=0
57
- finalSnapShot =""
58
- tempHash.each do |key,val|
59
- if (val>tempVal)
60
- tempVal = val
61
- finalSnapShot = key
62
- end
49
+ highestVerionArr.push(version)
63
50
  end
51
+ finalSnapShot = highestVerionArr.max
64
52
  return finalSnapShot
65
53
  end
66
54
 
@@ -11,7 +11,7 @@ class ParentPomHandler
11
11
  return cordinatesArr
12
12
  end
13
13
 
14
- def makeMbpCordinateFromOriginalPom(pom_document)
14
+ def fetch_mbp_cordinates_found_in_ancestor(pom_document)
15
15
  parentNode = pom_document.at("project/parent")
16
16
  cordinateArr = Array.new
17
17
  grpId = parentNode.at("groupId").text
@@ -31,6 +31,7 @@ class PluginHandler
31
31
  directoryNode = buildNode.css("directory")
32
32
  finalNameNode = buildNode.css("finalName")
33
33
  additionalClasspathElementsNode = buildNode.css("additionalClasspathElements")
34
+ sortOrderFile = buildNode.css("sortOrderFile")
34
35
  if !srcDirectoryNode.nil?
35
36
  srcDirectoryNode.each do |eachSrcDirectory|
36
37
  eachSrcDirectory.remove
@@ -81,6 +82,12 @@ class PluginHandler
81
82
  eachAdditionalClasspathElements.remove
82
83
  end
83
84
  end
85
+
86
+ if !sortOrderFile.nil?
87
+ sortOrderFile.each do |eachSortOrderFile|
88
+ eachSortOrderFile.remove
89
+ end
90
+ end
84
91
 
85
92
  formated_pom_doc = @@dependencyHandler.add_node_element("project",buildNode,temp_pom_document)
86
93
  File.write("temp.xml", formated_pom_doc)
@@ -151,7 +158,13 @@ class PluginHandler
151
158
  toAddPath = "project/build"
152
159
  end
153
160
  pomFilePluginNode.each do |eachPlugin|
154
- grpId = eachPlugin.at("groupId").text
161
+ #grpId = eachPlugin.at("groupId").text
162
+ grpId=nil
163
+ if (!eachPlugin.at("groupId").nil? and eachPlugin.at("groupId").parent.name == "plugin")
164
+ grpId = eachPlugin.at("groupId").text
165
+ else
166
+ grpId = "org.apache.maven.plugins"
167
+ end
155
168
  artifactId = eachPlugin.at("artifactId").text
156
169
  fullPlugin = "#{grpId}:#{artifactId}"
157
170
  if pluginList.include?fullPlugin
@@ -183,7 +196,13 @@ class PluginHandler
183
196
  toAddPath = "project/build"
184
197
  end
185
198
  pomFilePluginNode.each do |eachPlugin|
186
- grpId = eachPlugin.at("groupId").text
199
+ #grpId = eachPlugin.at("groupId").text
200
+ grpId=nil
201
+ if (!eachPlugin.at("groupId").nil? and eachPlugin.at("groupId").parent.name == "plugin")
202
+ grpId = eachPlugin.at("groupId").text
203
+ else
204
+ grpId = "org.apache.maven.plugins"
205
+ end
187
206
  artifactId = eachPlugin.at("artifactId").text
188
207
  fullPlugin = "#{grpId}:#{artifactId}"
189
208
  if pluginList.include?fullPlugin
@@ -218,7 +237,13 @@ class PluginHandler
218
237
  toAddPath = "project/build"
219
238
  end
220
239
  pomFilePluginNode.each do |eachPlugin|
221
- grpId = eachPlugin.at("groupId").text
240
+ # issue-117
241
+ #grpId = eachPlugin.at("groupId").text
242
+ if (!eachPlugin.at("groupId").nil? and eachPlugin.at("groupId").parent.name == "plugin")
243
+ grpId = eachPlugin.at("groupId").text
244
+ else
245
+ grpId = "org.apache.maven.plugins"
246
+ end
222
247
  artifactId = eachPlugin.at("artifactId").text
223
248
  fullPlugin = "#{grpId}:#{artifactId}"
224
249
  if pluginList.include?fullPlugin
@@ -0,0 +1,145 @@
1
+ class PropertyManager
2
+
3
+ @@ppp_counter = 1
4
+
5
+ @@reactorHandler = ReactorHandler.new
6
+ @@modulePomPaths = nil
7
+ def restructure(project_directory_path, parent_pom_path)
8
+ @@modulePomPaths = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
9
+ allModuleProperties = Array.new
10
+ commonProperties = Array.new
11
+ reactorProperties = Array.new
12
+ @@modulePomPaths.each do |modulePomPath|
13
+ modulePomDoc = Nokogiri::XML(open(modulePomPath))
14
+ amp_counter = 1
15
+ modulePomDoc.css("project/properties").children.each do |property|
16
+ if property.name != 'text' && property.name != 'comment'
17
+ propertyNameValue = "#{property.name}:_#{property.text}"
18
+ allModuleProperties.push(propertyNameValue)
19
+ # puts("(#{amp_counter}) allModuleProperty : #{propertyNameValue}")
20
+ amp_counter += 1
21
+ end
22
+ end
23
+ puts("\n\n")
24
+ end
25
+
26
+ #Parsing Parent POM, pushing all the Properties tag into "parent_pom_properties".
27
+ parent_pom_properties = Array.new
28
+ parent_pom_doc = Nokogiri::XML(open(parent_pom_path))
29
+ pppnv_counter = 1
30
+ parent_pom_doc.css("project/properties").children.each do |parent_pom_property|
31
+ if parent_pom_property.name != 'text' && parent_pom_property.name != 'comment'
32
+ parent_pom_property_name_value = "#{parent_pom_property.name}:_#{parent_pom_property.text}"
33
+ parent_pom_properties.push(parent_pom_property_name_value)
34
+ # puts("(#{pppnv_counter}) parent_pom_property_name_value : #{parent_pom_property_name_value}")
35
+ pppnv_counter += 1
36
+ end
37
+ end
38
+ puts("\n\n")
39
+
40
+ # Assumption is : the Reactor POM will only contain properties, which are common to the Module POMs.
41
+ # We will find Common properties between "Parent POM" and "Common Module POM"
42
+ # They(Common Properties) can be excluded before we add them into the Reactor POM by the function isAvailableInParentPomProperties(parent_pom_properties, property).
43
+
44
+ p_counter = 1
45
+ u_counter = 1
46
+
47
+ allModuleProperties.uniq.each do |property|
48
+
49
+ # puts("(#{u_counter}) Unique Module Property : #{property}")
50
+ u_counter += 1
51
+
52
+ if allModuleProperties.count(property) == @@modulePomPaths.length
53
+
54
+ # puts("(#{p_counter}) Common Module Property : #{property}")
55
+ p_counter += 1
56
+ commonProperties.push(property)
57
+ if !isAvailableInParentPomProperties(parent_pom_properties, property)
58
+ reactorProperties.push(property)
59
+ end
60
+ end
61
+ end
62
+ puts("\n\n")
63
+ writeToReactor(project_directory_path,commonProperties,reactorProperties,parent_pom_properties)
64
+
65
+ end
66
+
67
+ def writeToReactor(project_directory_path,commonProperties,reactorProperties,parent_pom_properties)
68
+ reactorPomPath = "#{project_directory_path}/pom.xml"
69
+ pom_document = @@reactorHandler.parse_xml_from_file(reactorPomPath)
70
+ nokObj = Nokogiri::XML::Node
71
+ projectNode = pom_document.at('project')
72
+ propertiesNode = nokObj.new('properties',projectNode)
73
+ reactorProperties.each do |property|
74
+ propNameValue = property.split(':_')
75
+ propName = propNameValue[0]
76
+ propValue = propNameValue[1]
77
+ propNode = nokObj.new(propName,projectNode)
78
+ propNode.content = propValue
79
+ propertiesNode.add_child(propNode)
80
+ end
81
+ dependencyHandler = DependencyHandler.new
82
+ pomObj = dependencyHandler.add_node_element('project',propertiesNode,pom_document)
83
+ File.write(reactorPomPath,pomObj)
84
+ puts "Moved common properties to reactor pom!!!"
85
+ removeCommonPropertiesfromModulePOMs(project_directory_path,commonProperties,parent_pom_properties)
86
+
87
+ end
88
+
89
+ def removeCommonPropertiesfromModulePOMs (project_directory_path,commonProperties,parent_pom_properties)
90
+
91
+ @@modulePomPaths.each do |eachModulePath|
92
+ pom_document = @@reactorHandler.parse_xml_from_file(eachModulePath)
93
+ if !commonProperties.nil?
94
+ commonProperties.each do |property|
95
+ propNameValue = property.split(':_')
96
+ propName = propNameValue[0]
97
+ pom_document.css('project/properties').children.each do |eachProperty|
98
+ if eachProperty.name == propName
99
+ eachProperty.remove
100
+ end
101
+ end
102
+ end
103
+ File.write(eachModulePath,pom_document)
104
+ end
105
+ end
106
+ removeParentPropertiesfromModulePOMs(project_directory_path,parent_pom_properties)
107
+ end
108
+
109
+ def removeParentPropertiesfromModulePOMs(project_directory_path,parent_pom_properties)
110
+ @@modulePomPaths.each do |eachModulePath|
111
+ pom_document = @@reactorHandler.parse_xml_from_file(eachModulePath)
112
+ if !parent_pom_properties.nil?
113
+ parent_pom_properties.each do |property|
114
+ propNameValue = property.split(':_')
115
+ propName = propNameValue[0]
116
+ pom_document.css('project/properties').children.each do |eachProperty|
117
+ if eachProperty.name == propName
118
+ eachProperty.remove
119
+ end
120
+ end
121
+ end
122
+ File.write(eachModulePath,pom_document)
123
+ end
124
+ end
125
+ puts "Common properties removed from child modules!!!"
126
+ end
127
+
128
+ def isAvailableInParentPomProperties (parent_pom_properties, common_module_pom_property)
129
+ #Looping over parent POM properties and checking if that is present in one of the 'common module POM properties'
130
+ # puts("Checking availability of common_module_pom_property in parent POM : #{common_module_pom_property}")
131
+
132
+ parent_pom_properties.each do |parent_pom_property|
133
+ if parent_pom_property == common_module_pom_property
134
+ # puts("(#{@@ppp_counter}) !!! Matched !!! common_module_pom_property = #{common_module_pom_property}")
135
+ # puts("parent_pom_property = #{parent_pom_property}")
136
+ # puts("\n\n")
137
+ @@ppp_counter += 1
138
+ return true
139
+ end
140
+ end
141
+ return false
142
+ end
143
+
144
+ end
145
+
@@ -4,6 +4,7 @@ require 'mavenReactorService/ReactorHandler'
4
4
  require 'mavenReactorService/DependencyHandler'
5
5
  require 'mavenReactorService/BasicInfoHandler'
6
6
  require 'mavenReactorService/PropertyHandler'
7
+ require 'mavenReactorService/PropertyManager'
7
8
  require 'mavenReactorService/PluginHandler'
8
9
  require 'mavenReactorService/MvnReactorization'
9
10
  require 'mavenReactorService/MergeRepository'
@@ -22,27 +23,32 @@ require 'open-uri'
22
23
 
23
24
  # This is controller class for reactor service #
24
25
  class ReactorCommands < Thor
25
- desc 'all [PROJECT_DIRECTORY_PATH]', 'Run Method For parent pom'
26
- def reactorHandler(externalPomUrl=nil,project_directory_path = Dir.getwd)
26
+ desc "all [PROJECT_DIRECTORY_PATH]", "Run Method For parent pom"
27
+
28
+ def reactorHandler(externalPomUrl = nil, project_directory_path = Dir.getwd)
27
29
  reactorHandler = ReactorHandler.new
30
+ cordinateArr = reactorHandler.checkIdenticalParent(project_directory_path)
28
31
  reactorHandler.createEffectivePom(project_directory_path,externalPomUrl)
29
32
  reactorHandler.makeReator(project_directory_path)
33
+ reactorHandler.addParentInReactorPom(project_directory_path,cordinateArr)
30
34
  reactorHandler.managePlugins(project_directory_path)
31
- reactorHandler.plugiConfigHandler(project_directory_path)
32
- reactorHandler.moveCommonProperties(project_directory_path)
35
+ reactorHandler.plugiConfigHandler(project_directory_path)
36
+ reactorHandler.moveCommonProperties(project_directory_path,externalPomUrl)
33
37
  reactorHandler.createDistributionManagmentInReactorPom(project_directory_path,externalPomUrl)
34
38
  reactorHandler.handleDeveloperAndContributors(project_directory_path)
35
39
  reactorHandler.mergeRepository(project_directory_path)
36
- reactorHandler.manageDepedency(project_directory_path)
40
+ reactorHandler.manageDepedency(project_directory_path)
37
41
  reactorHandler.handleInterDependency(project_directory_path)
38
42
  reactorHandler.handleTeamSpecificParent(project_directory_path,externalPomUrl)
39
- reactorHandler.dmpmForexternalConfiguration(project_directory_path,externalPomUrl)
40
- reactorHandler.removeEmptyTags(project_directory_path)
41
- reactorHandler.sortPomExecutor()
42
- end
43
+ reactorHandler.dmpmForexternalConfiguration(project_directory_path,externalPomUrl)
44
+ reactorHandler.removeTagsWithHardCodedPath(project_directory_path)
45
+ reactorHandler.removeEmptyTags(project_directory_path)
46
+ reactorHandler.sortPomExecutor()
47
+ end
43
48
 
44
- desc 'all [PROJECT_DIRECTORY_PATH]', 'Run Method For parent pom'
45
- def projectValidator(project_directory_path = Dir.getwd )
49
+ desc "projectValidator [ROJECT_DIRECTORY_PATH]", "Run Method to check project eligibility for reacorization"
50
+
51
+ def projectValidator(project_directory_path = Dir.getwd)
46
52
  reactorHandler = ReactorHandler.new
47
53
  reactorHandler.validateProjectsEligiblity(project_directory_path)
48
54
  end
@@ -2,101 +2,126 @@
2
2
  class ReactorHandler
3
3
  @@xml_file
4
4
  @@cordinateArr
5
- @@flag=false
5
+ @@flag = false
6
6
  @@projectsWithExternalConfiguration = Array.new
7
+ @@allProjectRepos = Array.new
8
+
7
9
  # This api will generate effective-pom and implements flatten out process #
8
10
  # If parent tag is not prersent then effective-pom will not be generated #
9
- def createEffectivePom(project_directory_path,externalPomUrl)
10
- eachModuleArr = fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
11
+ def createEffectivePom(project_directory_path, externalPomUrl, isMBP = false)
12
+ reactorProjectPOM = Dir.getwd + "/pom.xml"
13
+ if (File.exists?(reactorProjectPOM))
14
+ reactorProjectDoc = parse_xml_from_file(reactorProjectPOM)
15
+ reactorProjectDoc.css("repositories/repository").each do |eachRepo|
16
+ eachUrl = eachRepo.at_css("url").text
17
+ eachUrl = eachUrl.end_with?("/") ? eachUrl.chop : eachUrl
18
+ if !(@@allProjectRepos.include? eachUrl)
19
+ @@allProjectRepos.push(eachUrl)
20
+ end
21
+ end
22
+ end
23
+ eachModuleArr = Array.new
24
+ if isMBP
25
+ eachModuleArr.push("#{project_directory_path}/pom.xml")
26
+ else
27
+ eachModuleArr = fetchGidArtifactIdAndVersionFromChildModule(project_directory_path, false)
28
+ end
29
+ parentPomHandler = ParentPomHandler.new
30
+ cordinatesArr = nil
31
+ if (!externalPomUrl.nil?) and (externalPomUrl.include? "https://" or externalPomUrl.include? "http://")
32
+ cordinatesArr = parentPomHandler.makeCordinateFromUrl(externalPomUrl)
33
+ end
11
34
  eachModuleArr.each do |eachPom|
12
- isIdentical=false
35
+ isIdentical = false
13
36
  pom_document = parse_xml_from_file(eachPom)
14
- if tag_exists?('parent', pom_document)
15
- parentPomHandler = ParentPomHandler.new
16
- @@cordinateArr = parentPomHandler.makeMbpCordinateFromOriginalPom(pom_document)
17
- if ((@@cordinateArr.length == 0) and ((!externalPomUrl.nil?) and (externalPomUrl.include? "https://" or externalPomUrl.include? "http://")))
18
- cordinatesArr = parentPomHandler.makeCordinateFromUrl(externalPomUrl)
37
+ if tag_exists?("parent", pom_document)
38
+ @@cordinateArr = parentPomHandler.fetch_mbp_cordinates_found_in_ancestor(pom_document)
39
+ if ((@@cordinateArr.length == 0) and ((!externalPomUrl.nil?) and (externalPomUrl.include? "https://" or externalPomUrl.include? "http://")))
19
40
  orginalCordinateArr = parentPomHandler.makeOriginalPomUrl(pom_document)
20
- isIdentical = parentPomHandler.compareTwoCordinatesArr(cordinatesArr,orginalCordinateArr)
21
- elsif (@@cordinateArr.length > 0)
22
- isIdentical=true
41
+ isIdentical = parentPomHandler.compareTwoCordinatesArr(cordinatesArr, orginalCordinateArr)
42
+ elsif (@@cordinateArr.length > 0)
43
+ isIdentical = true
23
44
  end
24
- if !isIdentical
25
- eachPomPath = eachPom.sub("/pom.xml","")
26
- Dir.chdir(eachPomPath) {
27
- result = `mvn help:effective-pom -Doutput=effective_pom.xml`
28
- puts result # Maven out-put
29
- generate_temp_xml()
30
- @@projectsWithExternalConfiguration.push(eachPomPath)
31
- basicInfoHandler = BasicInfoHandler.new
32
- basicInfoHandler.handleGrpAndArtifact(eachPomPath)
33
- basicInfoHandler.handleModelVersion(eachPomPath)
34
- basicInfoHandler.handleInceptionYearDescAndOrganization(eachPomPath)
35
- basicInfoHandler.handleProjectUrl(eachPomPath)
36
- basicInfoHandler.handleDevelopersContributorsMailingLists(eachPomPath)
37
- basicInfoHandler.handleScmIssueManagementCiManagement(eachPomPath)
38
- basicInfoHandler.handleDistributionManagement(eachPomPath)
39
- basicInfoHandler.handleRepositories(eachPomPath)
40
- basicInfoHandler.handlePluginRepositories(eachPomPath)
41
- pluginHandler = PluginHandler.new
42
- pluginHandler.addBuildTag()
43
- pluginHandler.addReportingTag()
44
- propertyHandler = PropertyHandler.new
45
- propertyHandler.handleProperties(eachPomPath)
46
- dependencyHandler = DependencyHandler.new
47
- dependencyHandler.projectPomDependencyHandler()
48
- tempDependencyList = dependencyHandler.getTempDependencyList()
49
- childDependencyMap = dependencyHandler.getOriginalDependencyMap()
50
- parentDependencyMap = dependencyHandler.getImmediateParentDependencyMap()
51
- grandParentDependencyMap = dependencyHandler.getgrandParentDependencyMap()
52
- dependencyHandler.findPlaceHolderWithinPoms(tempDependencyList,childDependencyMap,parentDependencyMap,grandParentDependencyMap)
53
- project_end()
54
- tempPropertyMap = propertyHandler.getTempPropertyMap()
55
- childPropertyMap = propertyHandler.getOriginalPropertyMap()
56
- parentPropertyMap = propertyHandler.getImidiateParentPropertyMap()
57
- grandparentPropertyMap = propertyHandler.getgrandParentPropertyMap()
58
- propertyHandler.findPlaceHolderWithinProperties(tempPropertyMap,childPropertyMap,parentPropertyMap,grandparentPropertyMap)
59
- pluginHandler.removePluginManagementTag()
60
- pluginList = pluginHandler.getGrpAndArtifactIdOfPlugins()
61
- pluginHandler.compareWithOriginalPomPlugin(pluginList)
62
- pluginHandler.compareWithParentPomPlugin(pluginList)
63
- pluginHandler.compareWithGrandParentPomPlugin(pluginList)
64
- pluginHandler.removeExtraTag("build")
65
- #Reporting plugin
66
- reportSwitch = "reporting"
67
- pluginList = pluginHandler.getGrpAndArtifactIdOfPlugins(reportSwitch)
68
- pluginHandler.compareWithOriginalPomPlugin(pluginList,reportSwitch)
69
- pluginHandler.compareWithParentPomPlugin(pluginList,reportSwitch)
70
- pluginHandler.compareWithGrandParentPomPlugin(pluginList,reportSwitch)
71
- pluginHandler.removeExtraTag("reporting")
72
- #Site and eclipse plugin
73
- handleSiteAndEclipsePlugin(eachPomPath)
74
- closeFileObj()
75
- basicInfoHandler.renamePom(eachPomPath)
76
- basicInfoHandler.renameTemp(eachPomPath)
77
- puts "Original pom is reanamed to pom_back.xml"
78
- }
79
- else
45
+ if !isIdentical
46
+ eachPomPath = eachPom.sub("/pom.xml", "")
47
+ Dir.chdir(eachPomPath) {
48
+ result = `mvn help:effective-pom -Doutput=effective_pom.xml`
49
+ puts result # Maven out-put
50
+ generate_temp_xml()
51
+ @@projectsWithExternalConfiguration.push(eachPomPath)
52
+ basicInfoHandler = BasicInfoHandler.new
53
+ basicInfoHandler.handleGrpAndArtifact(eachPomPath)
54
+ basicInfoHandler.handleModelVersion(eachPomPath)
55
+ basicInfoHandler.handleInceptionYearDescAndOrganization(eachPomPath)
56
+ basicInfoHandler.handleProjectUrl(eachPomPath)
57
+ basicInfoHandler.handleDevelopersContributorsMailingLists(eachPomPath)
58
+ basicInfoHandler.handleScmIssueManagementCiManagement(eachPomPath)
59
+ basicInfoHandler.handleDistributionManagement(eachPomPath)
60
+ basicInfoHandler.handleRepositories(eachPomPath)
61
+ basicInfoHandler.handlePluginRepositories(eachPomPath)
62
+ pluginHandler = PluginHandler.new
63
+ pluginHandler.addBuildTag()
64
+ pluginHandler.addReportingTag()
65
+ propertyHandler = PropertyHandler.new
66
+ propertyHandler.handleProperties(eachPomPath)
67
+ dependencyHandler = DependencyHandler.new
68
+ dependencyHandler.projectPomDependencyHandler()
69
+ tempDependencyList = dependencyHandler.getTempDependencyList()
70
+ childDependencyMap = dependencyHandler.getOriginalDependencyMap()
71
+ parentDependencyMap = dependencyHandler.getImmediateParentDependencyMap()
72
+ grandParentDependencyMap = dependencyHandler.getgrandParentDependencyMap()
73
+ dependencyHandler.findPlaceHolderWithinPoms(tempDependencyList, childDependencyMap, parentDependencyMap, grandParentDependencyMap)
74
+ project_end()
75
+ tempPropertyMap = propertyHandler.getTempPropertyMap()
76
+ childPropertyMap = propertyHandler.getOriginalPropertyMap()
77
+ parentPropertyMap = propertyHandler.getImidiateParentPropertyMap()
78
+ grandparentPropertyMap = propertyHandler.getgrandParentPropertyMap()
79
+ propertyHandler.findPlaceHolderWithinProperties(tempPropertyMap, childPropertyMap, parentPropertyMap, grandparentPropertyMap)
80
+ pluginHandler.removePluginManagementTag()
81
+ pluginList = pluginHandler.getGrpAndArtifactIdOfPlugins()
82
+ pluginHandler.compareWithOriginalPomPlugin(pluginList)
83
+ pluginHandler.compareWithParentPomPlugin(pluginList)
84
+ pluginHandler.compareWithGrandParentPomPlugin(pluginList)
85
+ pluginHandler.removeExtraTag("build")
86
+ #Reporting plugin
87
+ reportSwitch = "reporting"
88
+ pluginList = pluginHandler.getGrpAndArtifactIdOfPlugins(reportSwitch)
89
+ pluginHandler.compareWithOriginalPomPlugin(pluginList, reportSwitch)
90
+ pluginHandler.compareWithParentPomPlugin(pluginList, reportSwitch)
91
+ pluginHandler.compareWithGrandParentPomPlugin(pluginList, reportSwitch)
92
+ pluginHandler.removeExtraTag("reporting")
93
+ #Site and eclipse plugin
94
+ handleSiteAndEclipsePlugin(eachPomPath)
95
+ closeFileObj()
96
+ basicInfoHandler.renamePom(eachPomPath)
97
+ basicInfoHandler.renameTemp(eachPomPath)
98
+ puts "Original pom is reanamed to pom_back.xml"
99
+ }
100
+ else
80
101
  puts "Provided parent URL and external configuration are same"
81
- end
102
+ end
82
103
  else
83
- eachPomPath = eachPom.sub("/pom.xml","")
104
+ eachPomPath = eachPom.sub("/pom.xml", "")
84
105
  index = eachPomPath.rindex("/")
85
- projectName = eachPomPath[index+1,eachPomPath.length-1]
106
+ projectName = eachPomPath[index + 1, eachPomPath.length - 1]
86
107
  puts "No parent found for #{projectName} project"
87
108
  end
88
109
  end
89
110
  puts "Effective pom generation is completed"
90
111
  end
91
112
 
113
+ def getReactPOMRepos()
114
+ return @@allProjectRepos
115
+ end
116
+
92
117
  def handleSiteAndEclipsePlugin(project_directory_path)
93
118
  siteAndEclipsePluginHandler = SiteAndEclipsePluginHandler.new
94
- siteAndEclipsePluginHandler.managePlugins(project_directory_path,"org.apache.maven.plugins:maven-site-plugin")
95
- siteAndEclipsePluginHandler.managePlugins(project_directory_path,"org.apache.maven.plugins:maven-eclipse-plugin")
119
+ siteAndEclipsePluginHandler.managePlugins(project_directory_path, "org.apache.maven.plugins:maven-site-plugin")
120
+ siteAndEclipsePluginHandler.managePlugins(project_directory_path, "org.apache.maven.plugins:maven-eclipse-plugin")
96
121
  end
97
122
 
98
123
  def makeReator(project_directory_path)
99
- mvnReactorization = MvnReactorization.new
124
+ mvnReactorization = MvnReactorization.new
100
125
  mvnReactorization.makeReactor(project_directory_path)
101
126
  end
102
127
 
@@ -113,25 +138,25 @@ class ReactorHandler
113
138
  end
114
139
 
115
140
  def plugiConfigHandler(project_directory_path)
116
- pluginConfigurationHandler= PluginConfigurationHandler.new
117
- pluginConfigurationHandler.mergePluginConfiguration(project_directory_path,@@projectsWithExternalConfiguration)
141
+ pluginConfigurationHandler = PluginConfigurationHandler.new
142
+ pluginConfigurationHandler.mergePluginConfiguration(project_directory_path, @@projectsWithExternalConfiguration)
118
143
  end
119
-
144
+
120
145
  def mergeRepository(project_directory_path)
121
- mergeRepository =MergeRepository.new
146
+ mergeRepository = MergeRepository.new
122
147
  #Repositories
123
- commonUrlList = mergeRepository.findCommonRepos(project_directory_path,"repositories/repository")
124
- rootRepo = mergeRepository.makeFullRepoFromCommonRepo(project_directory_path,"repositories/repository",commonUrlList)
125
- mergeRepository.addRepoIntoReactorPom(project_directory_path,rootRepo,"repositories")
126
- mergeRepository.deleteRepoFromChildModule(project_directory_path,"repositories")
127
- mergeRepository.renameDuplicateRepoId(project_directory_path,"repositories/repository")
148
+ commonUrlList = mergeRepository.findCommonRepos(project_directory_path, "repositories/repository")
149
+ rootRepo = mergeRepository.makeFullRepoFromCommonRepo(project_directory_path, "repositories/repository", commonUrlList)
150
+ mergeRepository.addRepoIntoReactorPom(project_directory_path, rootRepo, "repositories")
151
+ mergeRepository.deleteRepoFromChildModule(project_directory_path, "repositories")
152
+ mergeRepository.renameDuplicateRepoId(project_directory_path, "repositories/repository")
128
153
  #PluginRepositories
129
- commonUrlList = mergeRepository.findCommonRepos(project_directory_path,"pluginRepositories/pluginRepository")
130
- rootRepo = mergeRepository.makeFullRepoFromCommonRepo(project_directory_path,"pluginRepositories/pluginRepository",commonUrlList)
131
- mergeRepository.addRepoIntoReactorPom(project_directory_path,rootRepo,"pluginRepositories")
132
- mergeRepository.deleteRepoFromChildModule(project_directory_path,"pluginRepositories")
133
- mergeRepository.renameDuplicateRepoId(project_directory_path,"pluginRepositories/pluginRepository")
134
- puts "Renamed repo is done"
154
+ commonUrlList = mergeRepository.findCommonRepos(project_directory_path, "pluginRepositories/pluginRepository")
155
+ rootRepo = mergeRepository.makeFullRepoFromCommonRepo(project_directory_path, "pluginRepositories/pluginRepository", commonUrlList)
156
+ mergeRepository.addRepoIntoReactorPom(project_directory_path, rootRepo, "pluginRepositories")
157
+ mergeRepository.deleteRepoFromChildModule(project_directory_path, "pluginRepositories")
158
+ mergeRepository.renameDuplicateRepoId(project_directory_path, "pluginRepositories/pluginRepository")
159
+ puts "Renamed repo is done"
135
160
  end
136
161
 
137
162
  def handleInterDependency(project_directory_path)
@@ -141,16 +166,16 @@ class ReactorHandler
141
166
 
142
167
  def handleDeveloperAndContributors(project_directory_path)
143
168
  developerAndContributors = DeveloperAndContributors.new
144
- commonDevelopers = developerAndContributors.findCommonDevelopers(project_directory_path,"developers/developer")
145
- developersAndContributorsList = developerAndContributors.mergeDeveloperAndContributors(project_directory_path,commonDevelopers,"developers/developer")
146
- developerAndContributors.addDeveloperAndContributersInReator(project_directory_path,developersAndContributorsList,"developers")
147
- developerAndContributors.removeCommonDevelopersAndContributorsFromChild(project_directory_path,commonDevelopers,"developers/developer")
169
+ commonDevelopers = developerAndContributors.findCommonDevelopers(project_directory_path, "developers/developer")
170
+ developersAndContributorsList = developerAndContributors.mergeDeveloperAndContributors(project_directory_path, commonDevelopers, "developers/developer")
171
+ developerAndContributors.addDeveloperAndContributersInReator(project_directory_path, developersAndContributorsList, "developers")
172
+ developerAndContributors.removeCommonDevelopersAndContributorsFromChild(project_directory_path, commonDevelopers, "developers/developer")
148
173
  #developerAndContributors.removeEmptyTags(project_directory_path,"developers")
149
174
  #Contributors
150
- commonDevelopers = developerAndContributors.findCommonDevelopers(project_directory_path,"contributors/contributor")
151
- developersAndContributorsList = developerAndContributors.mergeDeveloperAndContributors(project_directory_path,commonDevelopers,"contributors/contributor")
152
- developerAndContributors.addDeveloperAndContributersInReator(project_directory_path,developersAndContributorsList,"contributors")
153
- developerAndContributors.removeCommonDevelopersAndContributorsFromChild(project_directory_path,commonDevelopers,"contributors/contributor")
175
+ commonDevelopers = developerAndContributors.findCommonDevelopers(project_directory_path, "contributors/contributor")
176
+ developersAndContributorsList = developerAndContributors.mergeDeveloperAndContributors(project_directory_path, commonDevelopers, "contributors/contributor")
177
+ developerAndContributors.addDeveloperAndContributersInReator(project_directory_path, developersAndContributorsList, "contributors")
178
+ developerAndContributors.removeCommonDevelopersAndContributorsFromChild(project_directory_path, commonDevelopers, "contributors/contributor")
154
179
  #developerAndContributors.removeEmptyTags(project_directory_path,"contributors")
155
180
  end
156
181
 
@@ -158,21 +183,22 @@ class ReactorHandler
158
183
  pluginManagementHandler = PluginManagementHandler.new
159
184
  pluginManagementHandler.executeShortPom()
160
185
  end
161
-
162
- def handleTeamSpecificParent(project_directory_path,externalPomUrl)
163
- if ((!externalPomUrl.nil?) and (externalPomUrl.include? "https://" or externalPomUrl.include? "http://"))
164
- parentPomHandler = ParentPomHandler.new
165
- parentPomHandler.setParentInreactor(project_directory_path,externalPomUrl)
166
- end
167
- end
168
- # This api will return the list of projects path of individual projects #
169
- def fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,retDecision)
186
+
187
+ def handleTeamSpecificParent(project_directory_path, externalPomUrl)
188
+ if ((!externalPomUrl.nil?) and (externalPomUrl.include? "https://" or externalPomUrl.include? "http://"))
189
+ parentPomHandler = ParentPomHandler.new
190
+ parentPomHandler.setParentInreactor(project_directory_path, externalPomUrl)
191
+ end
192
+ end
193
+
194
+ # This api will return the list of projects path of individual projects #
195
+ def fetchGidArtifactIdAndVersionFromChildModule(project_directory_path, retDecision)
170
196
  alldir = Dir.entries(project_directory_path)
171
- pomFilePath=Array.new
197
+ pomFilePath = Array.new
172
198
  alldir.each do |fileLtst|
173
199
  if File.directory? fileLtst
174
200
  if !(File.basename(fileLtst) == "." || File.basename(fileLtst) == "..")
175
- innerFileLtst = Dir.entries(fileLtst)
201
+ innerFileLtst = Dir.entries(fileLtst)
176
202
  innerFileLtst.each do |eachInner|
177
203
  fileName = File.basename(eachInner)
178
204
  if fileName == "pom.xml"
@@ -183,57 +209,65 @@ class ReactorHandler
183
209
  end
184
210
  end
185
211
  if (retDecision)
186
- mvnReactorization = MvnReactorization.new
187
- finalSnapShot = mvnReactorization.findHighestVersionOfPom(pomFilePath)
188
- fullDetails = mvnReactorization.getDetails(pomFilePath[0])
189
- fullDetails[2]=finalSnapShot
212
+ mvnReactorization = MvnReactorization.new
213
+ finalSnapShot = mvnReactorization.findHighestVersionOfPom(pomFilePath)
214
+ fullDetails = mvnReactorization.getDetails(pomFilePath[0])
215
+ fullDetails[2] = finalSnapShot
190
216
  return fullDetails
191
217
  else
192
218
  return pomFilePath
193
219
  end
194
220
  end
195
-
196
- def moveCommonProperties (project_directory_path)
197
- moveCommonPropertiesToRootPom = MoveCommonPropertiesToRootPom.new
198
- commonProperties = moveCommonPropertiesToRootPom.findCommonProperties(project_directory_path)
199
- moveCommonPropertiesToRootPom.writeCommonPropertiesToReactorPom(project_directory_path,commonProperties)
200
- moveCommonPropertiesToRootPom.removeCommonPropertiesfromModules(project_directory_path,commonProperties)
221
+
222
+ # Adding parent POM path
223
+ def moveCommonProperties (project_directory_path, parent_pom_path)
224
+
225
+ if parent_pom_path.to_s.strip.empty?
226
+ moveCommonPropertiesToRootPom = MoveCommonPropertiesToRootPom.new
227
+ commonProperties = moveCommonPropertiesToRootPom.findCommonProperties(project_directory_path)
228
+ moveCommonPropertiesToRootPom.writeCommonPropertiesToReactorPom(project_directory_path,commonProperties)
229
+ moveCommonPropertiesToRootPom.removeCommonPropertiesfromModules(project_directory_path,commonProperties)
230
+ else
231
+ propertyManager = PropertyManager.new
232
+ propertyManager.restructure(project_directory_path, parent_pom_path)
233
+ end
201
234
  end
202
235
 
203
- def createDistributionManagmentInReactorPom (project_directory_path,externalPomUrl)
236
+ def createDistributionManagmentInReactorPom(project_directory_path, externalPomUrl)
204
237
  moveDistributionManagement = MoveDistributionManagement.new
205
- moveDistributionManagement.moveDistributionManagementFromFirstModule(project_directory_path,externalPomUrl)
238
+ moveDistributionManagement.moveDistributionManagementFromFirstModule(project_directory_path, externalPomUrl)
206
239
  end
207
-
240
+
208
241
  def removeEmptyTags(project_directory_path)
209
- pomPathArr = fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
210
- mvnReactorization = MvnReactorization.new
211
- pomPathArr.each do |eachPomPath|
212
- pom_document = parse_xml_from_file(eachPomPath)
213
- clean(pom_document.at("project"))
214
- mvnReactorization.write_nokogiri_to_xml(eachPomPath, pom_document)
242
+ pomPathArr = fetchGidArtifactIdAndVersionFromChildModule(project_directory_path, false)
243
+ mvnReactorization = MvnReactorization.new
244
+ pomPathArr.each do |eachPomPath|
245
+ pom_document = parse_xml_from_file(eachPomPath)
246
+ clean(pom_document.at("project"))
247
+ mvnReactorization.write_nokogiri_to_xml(eachPomPath, pom_document)
248
+ end
215
249
  end
216
- end
217
- def clean(node)
218
- node.children.each do |child|
219
- clean(child)
220
- child.remove if child.content.gsub(/\s+/, '').empty?
250
+
251
+ def clean(node)
252
+ node.children.each do |child|
253
+ clean(child)
254
+ child.remove if child.content.gsub(/\s+/, "").empty?
255
+ end
221
256
  end
222
- end
223
257
 
224
- def dmpmForexternalConfiguration(project_directory_path,externalPomUrl)
258
+ def dmpmForexternalConfiguration(project_directory_path, externalPomUrl)
225
259
  if @@flag
226
- dmAndPMManagementForExternalConfiguration = DMAndPMManagementForExternalConfiguration.new
227
- cordinateArr = dmAndPMManagementForExternalConfiguration.getParentCordinates(externalPomUrl,"dependency")
228
- dmAndPMManagementForExternalConfiguration.comparetheVersionWithParent(project_directory_path,cordinateArr,"dependencies/dependency")
229
- dmAndPMManagementForExternalConfiguration.comparetheVersionWithParent(project_directory_path,cordinateArr,"dependencyManagement/dependencies/dependency")
230
- cordinateArr = dmAndPMManagementForExternalConfiguration.getParentCordinates(externalPomUrl,"plugins")
231
- dmAndPMManagementForExternalConfiguration.comparethePluginVersionWithParent(project_directory_path,cordinateArr,"project/build/plugins/plugin")
232
- dmAndPMManagementForExternalConfiguration.comaprePluginVersionWihReactorPom(project_directory_path,cordinateArr,"project/build/pluginManagement/plugins/plugin")
260
+ dmAndPMManagementForExternalConfiguration = DMAndPMManagementForExternalConfiguration.new
261
+ cordinateArr = dmAndPMManagementForExternalConfiguration.getParentCordinates(externalPomUrl, "dependency")
262
+ dmAndPMManagementForExternalConfiguration.comparetheVersionWithParent(project_directory_path, cordinateArr, "dependencies/dependency")
263
+ dmAndPMManagementForExternalConfiguration.comparetheVersionWithParent(project_directory_path, cordinateArr, "dependencyManagement/dependencies/dependency")
264
+ cordinateArr = dmAndPMManagementForExternalConfiguration.getParentCordinates(externalPomUrl, "plugins")
265
+ dmAndPMManagementForExternalConfiguration.comparethePluginVersionWithParent(project_directory_path, cordinateArr, "project/build/plugins/plugin")
266
+ dmAndPMManagementForExternalConfiguration.comaprePluginVersionWihReactorPom(project_directory_path, cordinateArr, "project/build/pluginManagement/plugins/plugin")
233
267
  end
234
268
  end
235
-
236
- def handleTeamSpecificParent(project_directory_path,externalConfigUrl)
269
+
270
+ def handleTeamSpecificParent(project_directory_path, externalConfigUrl)
237
271
  parentPomHandler = ParentPomHandler.new
238
272
  if (!externalConfigUrl.nil?)
239
273
  begin
@@ -242,11 +276,11 @@ class ReactorHandler
242
276
  raise "Parent POM URL is not valid !!!"
243
277
  end
244
278
  cordinatesArr = parentPomHandler.makeCordinateFromUrl(externalConfigUrl)
245
- @@flag = parentPomHandler.putParentInReactorPom(cordinatesArr,project_directory_path)
279
+ @@flag = parentPomHandler.putParentInReactorPom(cordinatesArr, project_directory_path)
246
280
  end
247
281
  end
248
282
 
249
- def validateProjectsEligiblity (project_directory_path)
283
+ def validateProjectsEligiblity(project_directory_path)
250
284
  validateProjects = ValidateProjects.new
251
285
  validateProjects.checkEligiblityForReactorization(project_directory_path)
252
286
  end
@@ -270,13 +304,13 @@ class ReactorHandler
270
304
  # Rescue is hit only when
271
305
  # Supplied tag is either empty or nil or
272
306
  # Supplied pom_nokogiri is nil
273
- raise 'Either tag or pom object supplied is empty or nil'
307
+ raise "Either tag or pom object supplied is empty or nil"
274
308
  end
275
309
 
276
310
  # This api generate blank temp.xml inside the individual projects #
277
311
  def generate_temp_xml()
278
312
  dest = "temp.xml"
279
- File.write("temp.xml","<?xml version=\"1.0\" encoding=\"UTF-8\"?><project>")
313
+ File.write("temp.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><project>")
280
314
  end
281
315
 
282
316
  def project_end()
@@ -284,7 +318,7 @@ class ReactorHandler
284
318
  file = File.open(tempXml)
285
319
  contents = file.read
286
320
  if !contents.include? "</project>"
287
- File.write(tempXml, "</project>", File.size(tempXml), mode: 'a')
321
+ File.write(tempXml, "</project>", File.size(tempXml), mode: "a")
288
322
  end
289
323
  end
290
324
 
@@ -294,16 +328,84 @@ class ReactorHandler
294
328
  Nokogiri::XML(@@xml_file, &:strict)
295
329
  rescue Errno::ENOENT
296
330
  raise Errno::ENOENT,
297
- "Couldn't locate a file at that path, please check the path!"
331
+ "Couldn't locate a file at that path, please check the path!"
298
332
  rescue Nokogiri::XML::SyntaxError => e
299
333
  raise Nokogiri::XML::SyntaxError,
300
- "The following errors occurred while parsing your XML file: \n" +
301
- e.message
334
+ "The following errors occurred while parsing your XML file: \n" +
335
+ e.message
302
336
  end
303
337
 
304
338
  def closeFileObj()
305
339
  @@xml_file.close
306
340
  @@xml_file.closed?
307
341
  end
308
- end
309
342
 
343
+ def removeTagsWithHardCodedPath(project_directory_path)
344
+ pomList = fetchGidArtifactIdAndVersionFromChildModule(project_directory_path, false)
345
+ projectDirPath = project_directory_path.gsub('\\', "/")
346
+ pomList.each do |eachPomPath|
347
+ pomDocument = parse_xml_from_file(eachPomPath)
348
+ pomDocument.css("project").each do |plugin|
349
+ plugin.xpath("//*[not(child::*)]").each do |eachLeafNode|
350
+ leafNodeText = eachLeafNode.text().gsub('\\', "/")
351
+ if leafNodeText.include?(projectDirPath)
352
+ eachLeafNode.remove
353
+ end
354
+ end
355
+ end
356
+ mvnReactorization = MvnReactorization.new
357
+ mvnReactorization.write_nokogiri_to_xml(eachPomPath, pomDocument)
358
+ end
359
+ end
360
+ def checkIdenticalParent(project_directory_path)
361
+ eachModuleArr = fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
362
+ validateProjects = ValidateProjects.new
363
+ cordinateArr = Array.new
364
+ cordinates = validateProjects.checkEligiblityForReactorization(project_directory_path)
365
+ if !cordinates.nil?
366
+ cordinates.each do |key,indx|
367
+ cordinatesArr = key.split(":")
368
+ cordinateArr.push(cordinatesArr[0])
369
+ cordinateArr.push(cordinatesArr[1])
370
+ cordinateArr.push(cordinatesArr[2])
371
+ end
372
+ if cordinateArr.length == 3
373
+ eachModuleArr.each do |eachPom|
374
+ pom_document = parse_xml_from_file(eachPom)
375
+ if !pom_document.at("project/parent").nil?
376
+ pom_document.at("project/parent").remove
377
+ File.write(eachPom,pom_document)
378
+ end
379
+ end
380
+ end
381
+ end
382
+ if cordinateArr.length==3
383
+ puts "#{cordinateArr[0]}:#{cordinateArr[1]}:#{cordinateArr[2]} parent is removed from child modules"
384
+ end
385
+ return cordinateArr
386
+ end
387
+
388
+ def addParentInReactorPom(project_directory_path,cordinateArr)
389
+ if cordinateArr.length == 3
390
+ reactorPom = "#{project_directory_path}/pom.xml"
391
+ pom_document = parse_xml_from_file(reactorPom)
392
+ nokObj = Nokogiri::XML::Node
393
+ projectNode = pom_document.at("project")
394
+ grpIdNode = nokObj.new("groupId",projectNode)
395
+ grpIdNode.content=cordinateArr[0]
396
+ artifactIdNode = nokObj.new("artifactId",projectNode)
397
+ artifactIdNode.content = cordinateArr[1]
398
+ versionNode = nokObj.new("version",projectNode)
399
+ versionNode.content = cordinateArr[2]
400
+ parentNode = nokObj.new("parent",projectNode)
401
+ parentNode.add_child(grpIdNode)
402
+ parentNode.add_child(artifactIdNode)
403
+ parentNode.add_child(versionNode)
404
+ modelVersionNode = pom_document.at_css('modelVersion')
405
+ modelVersionNode.add_previous_sibling("\n")
406
+ modelVersionNode.add_previous_sibling(parentNode.to_xml)
407
+ File.write(reactorPom, pom_document.to_xml)
408
+ puts "Parent tag is added in reactor pom"
409
+ end
410
+ end
411
+ end
@@ -53,9 +53,11 @@ class ValidateProjects
53
53
  end
54
54
  if mbpHash.length == 1
55
55
  puts "All projects have MBP as their immediate ancestors with identical version. Good to go !!!"
56
+ return mbpHash
56
57
  else
57
58
  if nonMbpHash.length == 1 and grandMbpHash.length == 1
58
59
  puts "All projects have identical non MBP as their immediate ancestors as well as identical MBP as their grand ancestor . Good to go !!!"
60
+ return nonMbpHash
59
61
  else
60
62
  raise "All projects do not have identical immediate ancestors and MBP as their one of the ancestor. Aborting the reactorization !!!"
61
63
  end
@@ -1,3 +1,3 @@
1
1
  module MavenReactorService
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "mavenReactorService"
8
8
  spec.version = MavenReactorService::VERSION
9
9
  spec.authors = ["Indrashis"]
10
- spec.email = ["ibanerjee307@gmail.com"]
10
+ spec.email = ["indrashis.banerjee@cerner.com"]
11
11
 
12
12
  spec.summary = 'Maven Reactor Service'
13
13
  spec.description = 'Reactor Service for individual projects'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mavenReactorService
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indrashis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-17 00:00:00.000000000 Z
11
+ date: 2020-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: 3.1.2
83
83
  description: Reactor Service for individual projects
84
84
  email:
85
- - ibanerjee307@gmail.com
85
+ - indrashis.banerjee@cerner.com
86
86
  executables:
87
87
  - console
88
88
  - mavenReactorization
@@ -113,6 +113,7 @@ files:
113
113
  - lib/mavenReactorService/PluginHandler.rb
114
114
  - lib/mavenReactorService/PluginManagementHandler.rb
115
115
  - lib/mavenReactorService/PropertyHandler.rb
116
+ - lib/mavenReactorService/PropertyManager.rb
116
117
  - lib/mavenReactorService/ReactorCommands.rb
117
118
  - lib/mavenReactorService/ReactorHandler.rb
118
119
  - lib/mavenReactorService/SiteAndEclipsePluginHandler.rb
@@ -138,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.6.14.1
142
+ rubygems_version: 3.0.3
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Maven Reactor Service