I know I can retrieve some settings.xml parameters using properties, like, for example ${settings.localRepository}
to get the location of the local repository.
Now imagine my settings.xml contains the following servers definition:
<servers>
<server>
<id>server-dev</id>
<username>devuser</username>
<password>devpass</password>
</server>
<server>
<id>server-hom</id>
<username>homuser</username>
<password>hompass</password>
</server>
</servers>
Is there a way, given an id
of a server to get the value of any parameter? For example, something like ${settings.servers.server.server-dev.username}
would return devuser
.
I've already tried the following:
${settings.servers.server.server-dev.username}
${settings.servers.server-dev.username}
${settings.servers.server[server-dev].username}
${settings.servers[server-dev].username}
but none of them worked...
Regarding this page, this is not possible. However, as it is a feature not correctly documented, I still have some hope to do that in this way...
A Maven settings. xml file defines values that configure Maven execution in various ways. Most commonly, it is used to define a local repository location, alternate remote repository servers, and authentication information for private repositories.
This build profile is defined in Maven global settings xml file i.e. at %M2_HOME%/conf/settings. xml location where Maven plugin is installed. The following are the number of ways to activate a Maven build profile. Use of command on the input console explicitly.
In case you are on Maven 3+, this can be achieved with servers-maven-extension. Once registered, settings.xml/servers content can be referenced using ${settings.servers.server.<server id>.<property>} (e.g. ${settings.servers.server.server-dev.username}).
disclosure: I am the maintainer of the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With