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.
Files changed (31) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/Gemfile +6 -0
  4. data/README.md +35 -0
  5. data/Rakefile +2 -0
  6. data/bin/console +14 -0
  7. data/bin/mavenReactorization +7 -0
  8. data/bin/setup +8 -0
  9. data/lib/mavenReactorService.rb +5 -0
  10. data/lib/mavenReactorService/BasicInfoHandler.rb +173 -0
  11. data/lib/mavenReactorService/DMAndPMManagementForExternalConfiguration.rb +205 -0
  12. data/lib/mavenReactorService/DependencyHandler.rb +264 -0
  13. data/lib/mavenReactorService/DependencyManagementHandler.rb +183 -0
  14. data/lib/mavenReactorService/DeveloperAndContributors.rb +130 -0
  15. data/lib/mavenReactorService/InterDependencyHandler.rb +87 -0
  16. data/lib/mavenReactorService/MergeRepository.rb +98 -0
  17. data/lib/mavenReactorService/MoveCommonPropertiesToRootPom.rb +83 -0
  18. data/lib/mavenReactorService/MoveDistributionManagement.rb +68 -0
  19. data/lib/mavenReactorService/MvnReactorization.rb +209 -0
  20. data/lib/mavenReactorService/ParentPomHandler.rb +71 -0
  21. data/lib/mavenReactorService/PluginConfigurationHandler.rb +106 -0
  22. data/lib/mavenReactorService/PluginHandler.rb +292 -0
  23. data/lib/mavenReactorService/PluginManagementHandler.rb +391 -0
  24. data/lib/mavenReactorService/PropertyHandler.rb +129 -0
  25. data/lib/mavenReactorService/ReactorCommands.rb +49 -0
  26. data/lib/mavenReactorService/ReactorHandler.rb +309 -0
  27. data/lib/mavenReactorService/SiteAndEclipsePluginHandler.rb +105 -0
  28. data/lib/mavenReactorService/ValidateProjects.rb +70 -0
  29. data/lib/mavenReactorService/version.rb +3 -0
  30. data/mavenReactorService.gemspec +39 -0
  31. metadata +146 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fae17333cd252b6f09da7094ce445921ff615c4
4
+ data.tar.gz: f25618f42767f75876fa0ec0463835424aea3b67
5
+ SHA512:
6
+ metadata.gz: a59784c6f195597eb80acb45a38689c109e89a4ea5c5f75da6054990900cb3df4cf7c5768172b71294aca3dbe954aff63726a31f33d4e3db30900c0424a1117f
7
+ data.tar.gz: f40bd246e989a8c78d3178f65c08d6e394ca809a96dc0d3f2fa2147f6bbe46901333812e3980419c8737d4a071eecc03302cb1e397f23a020d60c868374c99d4
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in mavenReactorService.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # MavenReactorService
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mavenReactorService`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'mavenReactorService'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mavenReactorService
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mavenReactorService.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mavenReactorService"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ # coding: UTF-8
4
+
5
+ require 'mavenReactorService/ReactorCommands'
6
+
7
+ ReactorCommands.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require "mavenReactorService/version"
2
+
3
+ module MavenReactorService
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,173 @@
1
+ require 'fileutils'
2
+
3
+ # This class will handle groupid, Artifactid and version of a project#
4
+ class BasicInfoHandler
5
+ @@reactorHandler = ReactorHandler.new
6
+ @@pomPath = nil
7
+ @@tempPath = nil
8
+ @@effective_pom_path=nil
9
+ # This api will handle grpId, artifactid,version, packaging and name #
10
+ def handleGrpAndArtifact (project_directory_path)
11
+ @@tempPath = "#{project_directory_path}/temp.xml"
12
+ pom_doc = copyTagsFromOriginalPom(project_directory_path)
13
+ grpId = pom_doc.at("project/groupId")
14
+ artifactId = pom_doc.at("project/artifactId")
15
+ version = pom_doc.at("project/version")
16
+ packaging = pom_doc.at("project/packaging")
17
+ projectName = pom_doc.at("project/name")
18
+ File.write(@@tempPath, grpId, File.size(@@tempPath), mode: 'a')
19
+ File.write(@@tempPath, artifactId, File.size(@@tempPath), mode: 'a')
20
+ File.write(@@tempPath, version, File.size(@@tempPath), mode: 'a')
21
+ File.write(@@tempPath, packaging, File.size(@@tempPath), mode: 'a')
22
+ File.write(@@tempPath, projectName, File.size(@@tempPath), mode: 'a')
23
+ puts "::Basic info is added successfully::"
24
+ end
25
+
26
+ # Return original pom object #
27
+ def copyTagsFromOriginalPom(project_directory_path)
28
+ @@pomPath = "#{project_directory_path}/pom.xml"
29
+ pom_doc = @@reactorHandler.parse_xml_from_file(@@pomPath)
30
+ return pom_doc
31
+ end
32
+
33
+ # Return effective pom object #
34
+ def copyTagsFromEffectivePom(project_directory_path)
35
+ @@effective_pom_path = "#{project_directory_path}/effective_pom.xml"
36
+ pom_doc = @@reactorHandler.parse_xml_from_file(@@effective_pom_path)
37
+ return pom_doc
38
+ end
39
+ def handleModelVersion(project_directory_path)
40
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
41
+ modelVersion = effective_pom_doc.at("project/modelVersion")
42
+ if (!modelVersion.nil?)
43
+ File.write(@@tempPath, modelVersion, File.size(@@tempPath), mode: 'a')
44
+ end
45
+ end
46
+
47
+ # This api will handle inception year, org and desc #
48
+ def handleInceptionYearDescAndOrganization(project_directory_path)
49
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
50
+ desc = effective_pom_doc.at("project/description")
51
+ inceptionYear = effective_pom_doc.at("project/inceptionYear")
52
+ org = effective_pom_doc.at("project/organization")
53
+ if (!desc.nil?)
54
+ File.write(@@tempPath, desc, File.size(@@tempPath), mode: 'a')
55
+ end
56
+ if (!inceptionYear.nil?)
57
+ File.write(@@tempPath, inceptionYear, File.size(@@tempPath), mode: 'a')
58
+ end
59
+ if (!org.nil?)
60
+ File.write(@@tempPath, org, File.size(@@tempPath), mode: 'a')
61
+ end
62
+ puts "::Description, inception year and org is added successfully::"
63
+ end
64
+
65
+ # This api will handle url #
66
+ def handleProjectUrl(project_directory_path)
67
+ pom_doc = copyTagsFromOriginalPom(project_directory_path)
68
+ url = pom_doc.at("project/url")
69
+ if (!url.nil?)
70
+ File.write(@@tempPath, url, File.size(@@tempPath), mode: 'a')
71
+ puts "::Url is added successfully::"
72
+ end
73
+ end
74
+
75
+ # This api will handle developers, contributors and mailing lists #
76
+ def handleDevelopersContributorsMailingLists(project_directory_path)
77
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
78
+ developers = effective_pom_doc.at("project/developers")
79
+ contributors = effective_pom_doc.at("project/contributors")
80
+ mailingList = effective_pom_doc.at("project/mailingLists")
81
+ if (!developers.nil?)
82
+ File.write(@@tempPath, developers, File.size(@@tempPath), mode: 'a')
83
+ puts "::Developers is added successfully::"
84
+ end
85
+ if (!contributors.nil?)
86
+ File.write(@@tempPath, contributors, File.size(@@tempPath), mode: 'a')
87
+ puts "::Contributors is added successfully::"
88
+ end
89
+ if (!mailingList.nil?)
90
+ File.write(@@tempPath, mailingList, File.size(@@tempPath), mode: 'a')
91
+ puts "::Mailing list is added successfully::"
92
+ end
93
+ end
94
+
95
+ # This api will handle scm, issueManagement and ciManagement lists #
96
+ def handleScmIssueManagementCiManagement(project_directory_path)
97
+ tempPath = "#{project_directory_path}/temp.xml"
98
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
99
+ pom_doc = Nokogiri::XML(open(@@pomPath))
100
+ scm = pom_doc.at("project/scm")
101
+ issueManagement = effective_pom_doc.at("project/issueManagement")
102
+ ciManagement = effective_pom_doc.at("project/ciManagement")
103
+ if (!scm.nil?)
104
+ File.write(@@tempPath, scm, File.size(@@tempPath), mode: 'a')
105
+ puts "::Scm is added successfully::"
106
+ end
107
+ if (!issueManagement.nil?)
108
+ File.write(@@tempPath, issueManagement, File.size(@@tempPath), mode: 'a')
109
+ puts "::IssueManagement is added successfully::"
110
+ end
111
+ if (!ciManagement.nil?)
112
+ File.write(@@tempPath, ciManagement, File.size(@@tempPath), mode: 'a')
113
+ puts "::CiManagement is added successfully::"
114
+ end
115
+ end
116
+
117
+ # This api will handle distribution management #
118
+ def handleDistributionManagement(project_directory_path)
119
+ pom_doc = copyTagsFromOriginalPom(project_directory_path)
120
+ distributionManagement = pom_doc.at("project/distributionManagement")
121
+ if (!distributionManagement.nil?)
122
+ File.write(@@tempPath, distributionManagement, File.size(@@tempPath), mode: 'a')
123
+ puts "::DistributionManagement is added successfully::"
124
+ end
125
+ end
126
+
127
+ # This api will handle properties #
128
+ def handleProperties(project_directory_path)
129
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
130
+ properties = effective_pom_doc.at("project/properties")
131
+ if (!properties.nil?)
132
+ File.write(@@tempPath, properties, File.size(@@tempPath), mode: 'a')
133
+ puts "::Prfoperties is added successfully::"
134
+ end
135
+ end
136
+
137
+ # This api will handle Repositories #
138
+ def handleRepositories(project_directory_path)
139
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
140
+ repositories = effective_pom_doc.at("project/repositories")
141
+ if (!repositories.nil?)
142
+ File.write(@@tempPath, repositories, File.size(@@tempPath), mode: 'a')
143
+ puts "::Repositories is added successfully::"
144
+ end
145
+ end
146
+
147
+ # This api will handle Plugin-Repositories #
148
+ def handlePluginRepositories(project_directory_path)
149
+ effective_pom_doc = copyTagsFromEffectivePom(project_directory_path)
150
+ repositories = effective_pom_doc.at("project/pluginRepositories")
151
+ if (!repositories.nil?)
152
+ File.write(@@tempPath, repositories, File.size(@@tempPath), mode: 'a')
153
+ puts "::pluginRepositories is added successfully::"
154
+ end
155
+ end
156
+
157
+ def renamePom(project_directory_path)
158
+ begin
159
+ File.rename("#{project_directory_path}/pom.xml", "#{project_directory_path}/pom_back.xml")
160
+ rescue
161
+ renamePom(project_directory_path)
162
+ end
163
+ end
164
+
165
+ def renameTemp(project_directory_path)
166
+ begin
167
+ File.rename("#{project_directory_path}/temp.xml", "#{project_directory_path}/pom.xml")
168
+ rescue
169
+ renameTemp(project_directory_path)
170
+ end
171
+ puts "Temp is renamed to pom.xml"
172
+ end
173
+ end
@@ -0,0 +1,205 @@
1
+ class DMAndPMManagementForExternalConfiguration
2
+ @@reactorHandler = ReactorHandler.new
3
+ @@mvnReactorization = MvnReactorization.new
4
+ @@cordinateArr = Array.new
5
+
6
+ def getParentCordinates(externalPomUrl,tag)
7
+ pom_document = Nokogiri::XML(open(externalPomUrl))
8
+ if tag == "dependency"
9
+ getCordinatesListFromEffectivepom(pom_document)
10
+ else
11
+ @@cordinateArr=Array.new
12
+ getCordinatesFromParentPlugin(pom_document,"project/build/pluginManagement/plugins/plugin")
13
+ getCordinatesFromParentPlugin(pom_document,"project/build/plugins/plugin")
14
+ end
15
+ return @@cordinateArr.uniq
16
+ end
17
+
18
+ def getCordinatesListFromEffectivepom(pom_document)
19
+ pom_document.css("project/dependencyManagement/dependencies/dependency").each do |eachDependency|
20
+ grpId = eachDependency.at("groupId").text
21
+ artId = eachDependency.at("artifactId").text
22
+ version = eachDependency.at("version").text
23
+ fullDependency = "#{grpId}:#{artId}:#{version}"
24
+ @@cordinateArr.push(fullDependency)
25
+ end
26
+ findParent(pom_document,"dependency")
27
+ end
28
+
29
+ def findParent(pom_document,tag)
30
+ if @@reactorHandler.tag_exists?('project/parent', pom_document)
31
+ dependencyHandler = DependencyHandler.new
32
+ parentPom = dependencyHandler.getParentPomDomObjFromUrl(pom_document)
33
+ if tag == "dependency"
34
+ getCordinatesListFromEffectivepom(parentPom)
35
+ else
36
+ getCordinatesFromParentPlugin(parentPom,"project/build/pluginManagement/plugins/plugin")
37
+ getCordinatesFromParentPlugin(parentPom,"project/build/plugins/plugin")
38
+ end
39
+ else
40
+ puts ":::::::::::End of Searching::::::"
41
+ end
42
+ end
43
+
44
+ def getCordinatesFromParentPlugin(pom_document,tag)
45
+ pom_document.css(tag).each do |eachPlugin|
46
+ grpId=nil
47
+ if (eachPlugin.at("groupId").nil?)
48
+ grpId="org.apache.maven.plugins"
49
+ else
50
+ grpId = eachPlugin.at("groupId").text
51
+ end
52
+ artifactId = eachPlugin.at("artifactId").text
53
+ version=nil
54
+ if (!eachPlugin.at("version").nil? and eachPlugin.at("version").parent.name=="plugin")
55
+ version = eachPlugin.at("version").text
56
+ end
57
+ if !version.nil?
58
+ if version.include?"${"
59
+ version = version.gsub("${","")
60
+ version = version.gsub("}","")
61
+ version = findPropVal(pom_document,version)
62
+ end
63
+ fullCordinate = "#{grpId}:#{artifactId}:#{version}"
64
+ @@cordinateArr.push(fullCordinate)
65
+ end
66
+ end
67
+ findParent(pom_document,"plugins")
68
+ end
69
+
70
+ def findPropVal(pom_document,proTag)
71
+ propVal=nil
72
+ pom_document.at("project/properties").children.each do |eachProp|
73
+ if eachProp.name == proTag
74
+ propVal = eachProp.text
75
+ end
76
+ end
77
+ return propVal
78
+ end
79
+
80
+ def comparetheVersionWithParent(project_directory_path,cordinateArr,tag)
81
+ pomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
82
+ reactorPomPath = "#{project_directory_path}/pom.xml"
83
+ pomPathArr.push(reactorPomPath)
84
+ pomPathArr.each do |eachPomPath|
85
+ pom_document = @@reactorHandler.parse_xml_from_file(eachPomPath)
86
+ pom_document.css(tag).each do |eachDependency|
87
+ grpId=nil
88
+ if (eachDependency.at("groupId").nil?)
89
+ grpId="org.apache.maven.plugins"
90
+ else
91
+ grpId = eachDependency.at("groupId").text
92
+ end
93
+ artifactId = eachDependency.at("artifactId").text
94
+ version=nil
95
+ fullArtifactId=nil
96
+ if ((!eachDependency.at("version").nil?) and (eachDependency.at("version").parent.name=="dependency"))
97
+ version = eachDependency.at("version").text
98
+ fullArtifactId = "#{grpId}:#{artifactId}:#{version}"
99
+ end
100
+ if (!fullArtifactId.nil? and cordinateArr.include?fullArtifactId and !tag.include?"dependencyManagement/" and eachDependency.parent.parent.name=="project")
101
+ eachDependency.at("version").remove
102
+ elsif (cordinateArr.include?fullArtifactId and eachDependency.at("exclusions").nil? and tag.include?"dependencyManagement/")
103
+ eachDependency.remove
104
+ end
105
+ end
106
+ @@mvnReactorization.write_nokogiri_to_xml(eachPomPath, pom_document)
107
+ puts "Dm is done"
108
+ end
109
+ end
110
+
111
+ def comparethePluginVersionWithParent(project_directory_path,cordinateArr,tag)
112
+ pomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false)
113
+ pomPathArr.each do |eachPomPath|
114
+ pom_document = @@reactorHandler.parse_xml_from_file(eachPomPath)
115
+ pom_document.css(tag).each do |eachPlugin|
116
+ grpId=nil
117
+ if (eachPlugin.at("groupId").nil?)
118
+ grpId="org.apache.maven.plugins"
119
+ else
120
+ grpId = eachPlugin.at("groupId").text
121
+ end
122
+ artifactId = eachPlugin.at("artifactId").text
123
+ version=nil
124
+ fullArtifactId=nil
125
+ isParentGreater=false
126
+ if ((!eachPlugin.at("version").nil?) and (eachPlugin.at("version").parent.name=="plugin"))
127
+ version = eachPlugin.at("version").text
128
+ if version.include?"${"
129
+ version = version.gsub("${","")
130
+ version = version.gsub("}","")
131
+ version = findPropVal(pom_document,version)
132
+ end
133
+ fullArtifactId = "#{grpId}:#{artifactId}:#{version}"
134
+ isParentGreater = findHigherVersionOfPlugin(fullArtifactId,cordinateArr)
135
+ end
136
+ if (!fullArtifactId.nil? and isParentGreater)
137
+ eachPlugin.at("version").remove
138
+ end
139
+ end
140
+ @@mvnReactorization.write_nokogiri_to_xml(eachPomPath, pom_document)
141
+ puts "remove version of plugin is successfull"
142
+ end
143
+ end
144
+
145
+ def comaprePluginVersionWihReactorPom(project_directory_path,cordinateArr,tag)
146
+ pomPath = "#{project_directory_path}/pom.xml"
147
+ pom_document = @@reactorHandler.parse_xml_from_file(pomPath)
148
+ pom_document.css(tag).each do |eachPlugin|
149
+ grpId=nil
150
+ if (eachPlugin.at("groupId").nil?)
151
+ grpId="org.apache.maven.plugins"
152
+ else
153
+ grpId = eachPlugin.at("groupId").text
154
+ end
155
+ artifactId = eachPlugin.at("artifactId").text
156
+ version=nil
157
+ fullArtifactId=nil
158
+ isParentGreater=false
159
+ if ((!eachPlugin.at("version").nil?) and (eachPlugin.at("version").parent.name=="plugin"))
160
+ version = eachPlugin.at("version").text
161
+ fullArtifactId = "#{grpId}:#{artifactId}:#{version}"
162
+ isParentGreater = findHigherVersionOfPlugin(fullArtifactId,cordinateArr)
163
+ end
164
+ if (!fullArtifactId.nil? and isParentGreater)
165
+ eachPlugin.remove
166
+ end
167
+ end
168
+ pluginNode = pom_document.at("project/build/pluginManagement/plugins/plugin")
169
+ buildNode = pom_document.at("project/build")
170
+ if (pluginNode.nil? and !buildNode.nil?)
171
+ buildNode.remove
172
+ end
173
+ @@mvnReactorization.write_nokogiri_to_xml(pomPath, pom_document)
174
+ puts "remove version of plugin is successfull"
175
+ end
176
+
177
+ def findHigherVersionOfPlugin(fullArtifactId,cordinateArr)
178
+ isParentGreater = false
179
+ cordinateArrWithoutVersion = Hash.new
180
+ cordinateArr.each do |eachCordinate|
181
+ eachValArr = eachCordinate.split(":")
182
+ grpId = eachValArr[0]
183
+ artifactId = eachValArr[1]
184
+ fullArtfactId = "#{grpId}:#{artifactId}"
185
+ cordinateArrWithoutVersion[fullArtfactId] = eachValArr[2]
186
+ end
187
+ childCordinateArr = fullArtifactId.split(":")
188
+ childCordinate = "#{childCordinateArr[0]}:#{childCordinateArr[1]}"
189
+ childPluginVersion = childCordinateArr[2]
190
+ if(!cordinateArrWithoutVersion[childCordinate].nil?)
191
+ parentVersion = cordinateArrWithoutVersion[childCordinate]
192
+ isParentGreater = compareVersion(childPluginVersion,parentVersion)
193
+ end
194
+ return isParentGreater
195
+ end
196
+
197
+ def compareVersion(childPluginVersion,parentVersion)
198
+ if (!childPluginVersion.nil? and !parentVersion.nil? and parentVersion>=childPluginVersion)
199
+ return true
200
+ else
201
+ return false
202
+ end
203
+ end
204
+ end
205
+