title: Uploading to Maven Central with Gradle, Avoiding Unknown Property Error
body: <p>I'm trying to get my first Gradle project uploaded to Maven Central. I've followed <a href="http://central.sonatype.org/pages/gradle.html#metadata-definition-and-upload" rel="nofollow noreferrer">Sonatype's documentation</a> for this and have created an <code>uploadArchives</code> task for generating the metadata.</p>
  
  <pre><code>uploadArchives {
    repositories {
      mavenDeployer {
        beforeDeployment { MavenDeployment deployment -&gt; signing.signPom(deployment) }
  
        repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
          authentication(userName: ossrhUsername, password: ossrhPassword)
        }
  
        snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
          authentication(userName: ossrhUsername, password: ossrhPassword)
        }
  ...etc. etc.
  </code></pre>
  
  <p>The task references two properties, "ossrhUsername" and "ossrhPassword", which I'm supposed to define in <code>gradle.properties</code>; however, if I do not have a <code>gradle.properties</code> with these properties, the build fails with an error, even for non-<code>uploadArchives</code> tasks.</p>
  
  <pre><code>$ gradlew test
  </code></pre>
  
  <blockquote>
    <p>Could not get unknown property 'ossrhUsername' for object of type
    org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.</p>
  </blockquote>
  
  <p>I would like for the build to succeed (apart from the <code>uploadArchives</code> task, of course) without having to define these properties in a <code>gradle.properties</code> file. </p>
  
  <p>How do I go about doing this?</p>
  
  <p>Would it be simpler to just manage a separate <code>pom.xml</code> exclusively for Maven Central uploading?</p>
  
  <p><strong>EDIT</strong> The identified <a href="https://stackoverflow.com/questions/12749225/where-to-put-gradle-configuration-i-e-credentials-that-should-not-be-committe">potential duplicate</a> is about where to externalize credentials. My question is how to ensure the Gradle build still executes successfully despite the credentials not being externalized in <code>gradle.properties</code>. I would like for others to be able to clone the repo and execute Gradle without having to define OSSRH credential properties.</p>