title: Publishing Library using Kotlin DSL
body: <p>I want to publish an Android library using Kotlin DSL. I got some errors</p>
  
  <pre><code>val sourcesJar by tasks.registering(Jar::class) {
      archiveClassifier.set("sources")
      from(sourceSets.getByName("main").allSource) 
  }
  
  </code></pre>
  
  <p>SourceSet with name 'main' not found.</p>
  
  <pre><code>publishing {
      publications {
          create&lt;MavenPublication&gt;("maven") {
              groupId = artifactGroup
              artifactId = artifactID
              version = artifactVersion
  
              from(components["java"])
              artifact(sourcesJar.get())
  
              pom {
                  ...
              }
          }
      }
  }
  </code></pre>
  
  <p>SoftwareComponentInternal with name 'java' not found.</p>
  
  <p>These blocks are in the library module <code>build.gradle.kts</code>.<br>
  Gradle Version: 5.6.2</p>
  
  <p>How can I solve these problems ?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Need to use android source sets.</p>
  
  <pre><code>val androidSourcesJar by tasks.registering(Jar::class) {
      archiveClassifier.set("sources")
      from(android.sourceSets.getByName("main").java.srcDirs)
  }
  </code></pre>