Riduidel
Riduidel

Reputation: 22292

Alter settings.xml from a maven plugin

Is it possible to access content of user settings.xml file from a maven plugin Mojo ?

And if so, how ?

I would like to alter this file in order to put in some user-specific configuration.

Upvotes: 1

Views: 393

Answers (2)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298838

for reading the Settings Object see khmarbaise's answer, and for writing the modified settings back, use a SettingsWriter:

/**
 * @component role="org.apache.maven.settings.io.SettingsWriter"
 */
private SettingsWriter settingsWriter;

Upvotes: 1

khmarbaise
khmarbaise

Reputation: 97379

This can simply be achieved by injecting the Settings into your Mojo:

/**
 * @parameter default-value="${settings}"
 */
private Settings settings;

Upvotes: 3

Related Questions