I have a maven settings.xml located in:
/home/u123/.m2/settings.xml
where I specify a remote maven repository:
See: https://github.com/ci-and-cd/maven-settings-decoder
I use it in gradle build script to avoid expose nexus password in build.gradle or environment variable.
buildscript {
repositories {
...
mavenCentral()
}
dependencies {
...
classpath 'cn.home1.tools:maven-settings-decoder:1.0.5.OSS'
}
}
...
ext.mavenSettings = new cn.home1.tools.maven.SettingsDecoder();
ext.nexusSnapshotsUser = mavenSettings.getText("//server[id='${nexus}-snapshots']/username/text()")
ext.nexusSnapshotsPass = mavenSettings.getText("//server[id='${nexus}-snapshots']/password/text()")
println "${nexus}-snapshots username: " + mavenSettings.getText("//server[id='${nexus}-snapshots']/username/text()")
println "${nexus}-snapshots password: " + mavenSettings.getText("//server[id='${nexus}-snapshots']/password/text()")
...