class ParentPomHandler @@dependencyHandler = DependencyHandler.new @@pluginManagementHandler = PluginManagementHandler.new def makeCordinateFromUrl(externalPomUrl) cordinatesArr = Array.new pomDoc = Nokogiri::XML(open("#{externalPomUrl}")) cordinatesArr.push(pomDoc.at("project/groupId").text) cordinatesArr.push(pomDoc.at("project/artifactId").text) cordinatesArr.push(pomDoc.at("project/version").text) return cordinatesArr end def fetch_mbp_cordinates_found_in_ancestor(pom_document) parentNode = pom_document.at("project/parent") cordinateArr = Array.new grpId = parentNode.at("groupId").text artifactId = parentNode.at("artifactId").text version = parentNode.at("version").text if (grpId == "com.cerner.maven" and artifactId == "maven-base-pom") cordinateArr.push(grpId) cordinateArr.push(artifactId) cordinateArr.push(version) end return cordinateArr end def putParentInReactorPom(cordinatesArr,project_directory_path) fullPomPath = "#{project_directory_path}/pom.xml" pom_document = Nokogiri::XML(open(fullPomPath)) grpId = cordinatesArr[0] artifactId = cordinatesArr[1] version = cordinatesArr[2] if (pom_document.at_css("project/parent").nil?) nokObj = Nokogiri::XML::Node projectNode = pom_document.at("project") parentNode = nokObj.new("parent" , projectNode) grpNode = nokObj.new("groupId" , projectNode) grpNode.content = grpId artifactNode = nokObj.new("artifactId" , projectNode) artifactNode.content = artifactId versionNode = nokObj.new("version" , projectNode) versionNode.content = version parentNode.add_child(grpNode) parentNode.add_child(artifactNode) parentNode.add_child(versionNode) pom_nokogiri = @@dependencyHandler.add_node_element('project', parentNode, pom_document) File.write(fullPomPath, pom_nokogiri) end return true end def makeOriginalPomUrl(pom_document) orginalCordinateArr = Array.new grpId = pom_document.at("project/parent/groupId").text artifactId = pom_document.at("project/parent/artifactId").text version = pom_document.at("project/parent/version").text orginalCordinateArr.push(grpId) orginalCordinateArr.push(artifactId) orginalCordinateArr.push(version) return orginalCordinateArr end def compareTwoCordinatesArr(urlCordinate,originalPomCordinate) isIdentical = false if (urlCordinate.sort == originalPomCordinate.sort) isIdentical=true end return isIdentical end end