Hi
 
I need to change the versions of dependencies in dependencyManagement in
my super pom for each new release.
So, I am doing that using MavenEmbedder.
when the pom.xml is saved back to the disk, the maven expressions are
replaced by actual values based on the project.
 
 
MavenEmbedder embedder = new MavenEmbedder(configuration);

MavenEmbedderLogger logger = new MavenEmbedderConsoleLogger();

embedder.setLogger(logger);

                                                

MavenProject project = embedder.readProject( new File(pomFilePath) );

                                                

// set the version

project.setVersion(version);

                                                

// get the distributionManagement Section

DistributionManagement distributionMgmt=
project.getDistributionManagement();

                                                

// update the URL for distributionMgmt

DeploymentRepository repository = new DeploymentRepository();

repository.setUrl(repositoryUrl );

distributionMgmt.setRepository(repository);

                                                

 

// write the pom file

BufferedWriter writer = new BufferedWriter(new FileWriter( pomFilePath
));

project.writeModel(writer);

 
 
What is the best way to update dependencyManagement section using maven
embedder?
 
Thanks
Nambi
 

Reply via email to