if ( projects == null || parentGav == null || repo == null ) {
return null;
}
try {
POM parentPom;
Path path = initProjectStructure( parentGav, repo );
parentPom = pomService.load( path );
if ( parentPom == null ) {
//uncommon case, the pom was just created.
return null;
}
ioService.startBatch( new FileSystem[] { Paths.convert( path ).getFileSystem() }, optionsFactory.makeCommentedOption( comment != null ? comment : "" ) );
POM pom;
boolean saveParentPom = false;
for ( Project project : projects ) {
pom = pomService.load( project.getPomXMLPath() );
pom.setParent( parentGav );
if ( updateChildrenGav ) {
pom.getGav().setGroupId( parentGav.getGroupId() );
pom.getGav().setVersion( parentGav.getVersion() );
}
pomService.save( project.getPomXMLPath(), pom, null, comment );
parentPom.setMultiModule( true );
parentPom.getModules().add( pom.getName() != null ? pom.getName() : pom.getGav().getArtifactId() );
saveParentPom = true;
}
if ( saveParentPom ) {
pomService.save( path, parentPom, null, comment );