title: Unable to publish artifacts to Nexus maven repository using Gradle
body: <p>I am new to Gradle, nexus and Maven and trying to use Gradle 'publish' task to publish maven artifacts from Jenkins to a new nexus repository. The Jenkins job is failing with below error while publishing. I have provided the user name and password for Nexus in the job.</p>
  
  <pre>
  
  :common-test:publishMavenJavaPublicationToMavenRepositoryCould not find metadata 
  com.xx.audit:common-test:1.0.3-SNAPSHOT/maven-metadata.xml in
   remote (https://nexus.xx.com:8443/content/repositories/snapshots)
  
  Upload https://nexus.xx.com:8443/content/repositories/snapshots/yy/audit/common-test/1.0.3-SNAPSHOT/common-test-1.0.3-20151102.120123-1.jar
  Could not transfer artifact com.xx.audit:common-test:jar:1.0.3-20151102.120123-1 
  from/to remote (https://nexus.xx.com:8443/content/repositories/snapshots):
   Could not write to resource 'yy/audit/common-test/1.0.3-SNAPSHOT/common-test-1.0.3-20151102.120123-1.jar'
  
  </pre>
  
  <p>Do we need to create folder structure in nexus maven repository before publishing first time? And add the maven-metadata.xml? How are the *.pom.sha, *.pom.md5 are generated.
  Please help me on this.</p>
  
  <p>build.gradle configuration:</p>
  
  <pre>
    apply plugin: "maven-publish"
  
      //* New Gradle task to jar source
      task sourcesJar(type: Jar, dependsOn: classes) {
          classifier = 'sources'
          from sourceSets.main.allSource
      }
  
      //* New Gradle task to jar javadoc
      task javadocJar(type: Jar, dependsOn: javadoc) {
          classifier = 'javadoc'
          from javadoc.destinationDir
      }
  
      publishing {
          publications {
              mavenJava(MavenPublication) {
                  from components.java
  
                  artifact sourcesJar {
                      classifier "sources"
                  }
              }
          }
      }
  
      publishing {
          repositories {
              maven {
                  credentials {
                      username nexusUsername
                      password nexusPassword
                  }   
                  if (project.version.endsWith('-SNAPSHOT')) {
                      url nexusSnapshotRepoURL
                  } else {
                      url nexusReleaseRepoURL
                  }   
              }   
          }
      }
  
  </pre>