How do I upload to a remote Maven repository on my LAN without hard-coding a password into “build.gradle”?
“build.gradle” has the following (among other things):
apply plugin: 'maven'
configurations {
deployerJars
}
dependencies {
...
deployerJars "org.apache.maven.wagon:wagon-http:2.2+"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "https://some.lan.host/repositories/snapshots") {
authentication(userName: "myname", password: "password")
}
}
}
This works but would be a security problem because the project is hosted on a public code forge and the username and password would be publicly visible.
How can I upload without revealing secret information? I tried this:
dependencies {
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2+"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "scp://some.lan.host/much/longer/path/due/to/use/of/nexus") {
authentication(userName: "myname", privateKey: "/myhome/.ssh/id_rsa")
}
}
}
but it didn’t work.
Due to the Nexus server, I would prefer a solution that used the HTTP protocol.
Incidentally, the link org.apache.maven.artifact.ant.Authentication on this Gradle documentation webpage is broken. There are others.