@@ -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