Hello, I’m developing a kotlin library and using i...
# getting-started
a
Hello, I’m developing a kotlin library and using it on a java project but it is not including sources in my jar when I try to access it from intellij it says
compiled code
on the method implementations, any ideias?
t
If you turned it into a .jar and included it in a java projects, did you also make a jar that contains the source? (with for example
Copy code
mvn source:jar
) ?
a
yes I have a task for the sources Jar like following
Copy code
task sourcesJar(type: Jar) {
    from sourceSets.main.allJava
    classifier 'sources'
}
t
And did you also inlcude something like:
Copy code
idea {
    module {
            //if you love browsing Javadoc
            downloadJavadoc = true

            //if you love reading sources :)
            downloadSources = true
    }
}
(getting this from stack overflow https://stackoverflow.com/questions/37281153/gradle-downloading-source-dependencies, im not that good with gradle yet :P)
r
I suspect because you're using
from sourceSets.main.allJava
it includes Java sources (which aren't there) and ignores Kotlin sources. I use the following to publish a sources jar:
Copy code
java {
    withSourcesJar()
}
that way, there's no need to register a separate task (it will be done automatically by including the above), and it includes all sources
👍 2
K 1
a
v
I am not sure I understood your problem exactly. I am also developing a Kotlin library. You can see how it solves this problem there: https://github.com/vsirotin/si-units