Skip to content

Commit 4aba62e

Browse files
AshishAshish
authored andcommitted
Updated code to remove existing repositories in POM
1 parent e55ded2 commit 4aba62e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Common/src/main/java/com/ing/parent/createParentPOM.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ public static void main(String[] args) {
4242
// Create a new document for the target pom.xml file
4343
Document targetDocument = createTargetDocument(targetPath);
4444

45-
// Remove content under dependencies tag from target document
45+
// Remove content under dependencies and Repositories tag from target document
4646
removeExistingDependencies(targetDocument);
47+
removeExistingRepositories(targetDocument);
48+
removeExistingPluginRepositories(targetDocument);
49+
4750

4851
// Copy dependencies from modules pom to target pom
4952
for (int i = 2; i < args.length; i++) {
@@ -53,8 +56,8 @@ public static void main(String[] args) {
5356

5457
// Copy repositories and pluginRepositories
5558
if (args[i].contains("Engine")) {
56-
copyRepositories(sourceDocument, targetDocument);
57-
removeDuplicateRepositories(targetDocument);
59+
//copyRepositories(sourceDocument, targetDocument);
60+
//removeDuplicateRepositories(targetDocument);
5861
copyPluginRepositories(sourceDocument,targetDocument);
5962
removeDuplicatePluginRepositories(targetDocument);
6063
}
@@ -233,4 +236,23 @@ private static void saveXML(Document doc, File file) throws TransformerException
233236
StreamResult streamResult = new StreamResult(file);
234237
transformer.transform(domSource, streamResult);
235238
}
239+
240+
private static void removeExistingRepositories(Document targetDocument) {
241+
NodeList dependencyList = targetDocument.getElementsByTagName("repositories");
242+
if (dependencyList.getLength() > 0) {
243+
Node dependenciesNode = dependencyList.item(0);
244+
while (dependenciesNode.hasChildNodes()) {
245+
dependenciesNode.removeChild(dependenciesNode.getFirstChild());
246+
}
247+
}
248+
}
249+
private static void removeExistingPluginRepositories(Document targetDocument) {
250+
NodeList dependencyList = targetDocument.getElementsByTagName("pluginRepositories");
251+
if (dependencyList.getLength() > 0) {
252+
Node dependenciesNode = dependencyList.item(0);
253+
while (dependenciesNode.hasChildNodes()) {
254+
dependenciesNode.removeChild(dependenciesNode.getFirstChild());
255+
}
256+
}
257+
}
236258
}

0 commit comments

Comments
 (0)