You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Sankaran, Nambi" <ns...@ebay.com> on 2009/04/13 20:52:21 UTC
updating dependencyManagement section in pom.xml using Maven Embedder
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