title: maven-publish with Kotlin for android aars
body: <p>I have a Kotlin Android library that I'm trying to publish to an s3 maven repo I've set up. Everything works but I can't seem to see the sources. Here's what I have</p>
  
  <pre><code>task sourceJar(type: Jar) {
      from android.sourceSets.main.java.srcDirs
      classifier 'sources'
  }
  
  publishing {
      repositories {
          maven {
              url awsUrl
              credentials(AwsCredentials) {
                  accessKey awsAccessKey
                  secretKey awsSecretKey
              }
          }
      }
      publications {
          aar(MavenPublication) {
              groupId = "com.example"
              artifactId = "library-0"
              version = libraryVersionName
              artifact("$buildDir/outputs/aar/${project.name}-debug.aar")
              artifact(sourceJar)
              pom.withXml {
                  def dependenciesNode = asNode().appendNode('dependencies')
                  //Iterate over the compile dependencies (we don't want the test ones), adding a &lt;dependency&gt; node for each
                  configurations.implementation.allDependencies.each {
                      if(it.group != null &amp;&amp; (it.name != null || "unspecified".equals(it.name)) &amp;&amp; it.version != null) {
                          def dependencyNode = dependenciesNode.appendNode('dependency')
                          dependencyNode.appendNode('groupId', it.group)
                          dependencyNode.appendNode('artifactId', it.name)
                          dependencyNode.appendNode('version', it.version)
                      }
                  }
              }
          }
      }
  }
  
  project.tasks.whenTaskAdded { addedTask -&gt;
      if (addedTask.name == 'generatePomFileForMavenJavaPublication') {
          addedTask.dependsOn assembleDebug
      }
  }
  </code></pre>
  
  <p>On my app I've added the maven repo url and am including the library with:</p>
  
  <pre><code>implementation 'com.example:library-0:1.0.0-SNAPSHOT'
  </code></pre>
  
  <p>Everything works, the app builds and the library is running great. Only issue is when I go to view the sources of any of the classes/functions I only see the function stubs saying compiled code and no javadoc. Is there something I should be doing different with the source jar?</p>
  
  <p>UPDATE</p>
  
  <p>I've changed the publication to <code>aar</code> and looked at my <code>.gradle/caches/</code> directory which now contains my library:</p>
  
  <pre><code>AndroidManifest.xml
  R.txt
  jars/classes.jar
  res/layout/**
  res/values/**
  </code></pre>
  
  <p><code>jar/classes.jar</code> contains all the compiled <code>.class</code> files and the proguard file. During the upload I do see that I've uploaded:</p>
  
  <pre><code>library-0-1.0.0-20180306.153335-5.aar
  library-0-1.0.0-20180306.153335-5.aar.md5
  library-0-1.0.0-20180306.153335-5.aar.sha1
  library-0-1.0.0-20180306.153335-5.pom
  library-0-1.0.0-20180306.153335-5.pom.md5
  library-0-1.0.0-20180306.153335-5.pom.sha1
  library-0-1.0.0-20180306.153335-5-sources.jar
  library-0-1.0.0-20180306.153335-5-sources.jar.md5
  library-0-1.0.0-20180306.153335-5-sources.jar.sha1
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>As an added reference, I found a sample of a library with similar publishing: <a href="http://central.maven.org/maven2/com/mcxiaoke/volley/library-aar/1.0.1/" rel="nofollow noreferrer">http://central.maven.org/maven2/com/mcxiaoke/volley/library-aar/1.0.1/</a> Here, it looks like it's the same structure with the appended <code>-sources</code>. The <code>.pom</code> file doesn't look like it needs to specify anything special. As a reference, here's my <code>.pom</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.example&lt;/groupId&gt;
    &lt;artifactId&gt;library-0&lt;/artifactId&gt;
    &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;aar&lt;/packaging&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.jetbrains.kotlin&lt;/groupId&gt;
        &lt;artifactId&gt;kotlin-stdlib-jre7&lt;/artifactId&gt;
        &lt;version&gt;1.2.30&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.android.support&lt;/groupId&gt;
        &lt;artifactId&gt;appcompat-v7&lt;/artifactId&gt;
        &lt;version&gt;27.1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.android.support.constraint&lt;/groupId&gt;
        &lt;artifactId&gt;constraint-layout&lt;/artifactId&gt;
        &lt;version&gt;1.0.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;android.arch.lifecycle&lt;/groupId&gt;
        &lt;artifactId&gt;extensions&lt;/artifactId&gt;
        &lt;version&gt;1.1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.github.bumptech.glide&lt;/groupId&gt;
        &lt;artifactId&gt;glide&lt;/artifactId&gt;
        &lt;version&gt;4.6.1&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>