throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
}
SAXBuilder saxBuilder = createSaxBuilder();
Document document;
EolDetectingInputStream eolDetectingStream = null;
try {
eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
InputStreamReader inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
document = saxBuilder.build(inputStreamReader);
} catch (JDOMException e) {
throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
} finally {
if (eolDetectingStream != null) {
eolDetectingStream.close();
}
}
Element rootElement = document.getRootElement();
Namespace ns = rootElement.getNamespace();
changeParentVersion(rootElement, ns);
changeCurrentModuleVersion(rootElement, ns);
//changePropertiesVersion(rootElement, ns);
changeDependencyManagementVersions(rootElement, ns);
changeDependencyVersions(rootElement, ns);
if (scmUrl != null) {
changeScm(rootElement, ns);
}
if (modified) {
FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
try {
XMLOutputter outputter = new XMLOutputter();
String eol = eolDetectingStream.getEol();
if (!"".equals(eol)) {
Format format = outputter.getFormat();
format.setLineSeparator(eol);
format.setTextMode(Format.TextMode.PRESERVE);
outputter.setFormat(format);