title: How to include custom artifact in distribution in gradle
body: <p>I'd like to know how to include a custom build artifact in the distribution zip built with gradle in a <em>canonical</em> way. I've managed to do it by referring to the path of the artifact directly, but I'm guessing there's some better way to achieve this:</p>
  
  <pre><code>task sourcesJar(type: Jar, dependsOn: tasks.classes) {
      classifier 'sources'
      from sourceSets.main.allSource
  }
  
  tasks.distZip.shouldRunAfter tasks.sourcesJar
  tasks.distTar.shouldRunAfter tasks.sourcesJar
  
  artifacts {
      archives sourcesJar
  }
  
  distributions {
      main {
          contents {
              from { "${libsDir}/${project.name}-${version}-sources.jar" }
          }
      }
  }
  </code></pre>
  
  <p>How can I refer to the name of my sources artifact based on its definition, or alternatively is there an even better way to include built artifacts in the distributions?</p>