Following this post How do I configure my Gradle build to publish artifacts to Nexus? – Sonatype Support
I can successfully publish grade (uploadArchives
) to a private nexus repository. But it has to provide the username and password
I try to set it in ~/.gradle/gradle.properties
, but not sure how to do that.
So how to hide that nexus username and password?
Got the solution from official document for this problem
https://help.sonatype.com/repomanager2/maven-and-other-build-tools/gradle
with mine
$ more build.gradle
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'maven'
repositories {
maven {
url "${nexusUrl}/content/groups/public"
}
}
dependencies {
....
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "${nexusUrl}/content/repositories/snapshots") {
authentication(userName: nexusUsername, password: nexusPassword)
}
you can save the username and password in ~/.gradle/gradle.properties
$ cat ~/.gradle/gradle.properties
nexusUrl=http://localhost:8081/nexus
nexusUsername=admin
nexusPassword=admin123