I'm trying to publish a Kotlin Multiplatform library including sources using the maven-publish plugin. This is generally working but when I want to have a look at the code of the dependency inside my Android Studio project I can't see the sources but instead will see decompiled Kotlin code.
I tried several approaches of adding a sources.jar to the generated aar file already. Right now I'm following this approach: https://stackoverflow.com/a/28704799. But I still can't see the sources(gradle clean cache and restart included).
Library build.gradle:
apply plugin: 'maven-publish'
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}
publishing {
publications {
bar(MavenPublication) {
groupId 'com.foo'
artifactId 'bar'
version '0.1'
artifact(sourceJar)
artifact("$buildDir/outputs/aar/bar-release.aar")
}
}
repositories {
maven {
url "$buildDir/repo"
}
}
}
I also tried using different sourceSets like specifying one by name since the content of android.sourceSets.main.java.srcDirs is leading to a path where no sources are inside.
The library is included in the app project like this:
dependencies {
implementation 'com.foo:bar:0.1'
}
Looking at the local maven repository I can even see the bar-release-sources.jar but it seems like it's not part of the aar?