Hi everyone, I have issues creating a library fat ...
# build-tools
d
Hi everyone, I have issues creating a library fat jar for my kotlin project. I’m using the built-in jar plugin and adding the compiled dependencies. This is the task:
Copy code
task fatJar(type: Jar) {
    from {
        // Add runtime dependencies to jar.
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
}
Is there something wrong? When I include the jar into another project I can only see my classes from the Java code, not the Kotlin one.
a
I'd recommend just using Shadow plugin
<https://imperceptiblethoughts.com/shadow/>
d
I already used it but I had the same issue… My kotlin code bundled into the jar is not visibile from other kotlin sources under the
main/kotlin
dir, only from
main/java
a
are you sure you're compiling Kotlin?
might need to add that src folder to srcs
d
Just edited it like
Copy code
task fatJar(type: Jar) {
    // Add runtime dependencies to jar.
    from configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    from sourceSets.main.allSource
    with jar
}
, so now also my sources are bundled… But this doesn’t fix
are you sure you’re compiling Kotlin?
I’m building with
./gradlew build fatJar
where
fatJar
is the task name
a
shadowJar worked for me too
d
were your library sources into the
kotlin
dir?