setting credentials in gradle via maven-publish

Single quotes denote a String literal without variable expansion;

Please use

username project.nexusUsername password project.nexusPassword

Reference: http://docs.groovy-lang.org/latest/html/documentation/#_single_quoted_string


The issue was how the properties was specified in the external properties file. I was using double quotes for the String values in the properties file and that was resulting in authentication failures. Once I removed the double quotes from the external properties file, I was able to publish to nexus.

Incorrect external properties file setting

someUsername="someuser"

Correct external properties file setting

someUsername=someuser

build.gradle

publishing {
    publications {
        shadow(MavenPublication) {
            from components.shadow
            groupId project.group
            artifactId project.artifactId
        }
    }
    repositories {
        maven {
            credentials {
                username project.someUsername
                password project.somePassword
            }
            if (project.version.endsWith("-SNAPSHOT")) {
                url project.someSnapshot
            } else {
                url project.someRelease
            }
        }
    }
}

this works.