Woes in porting our project (current Kotlin multip...
# multiplatform
p
Woes in porting our project (current Kotlin multiplatform for 1.9.10) to 2.1.20, a thread. 🧵 (any feedback/guidance is welcome)
This is the project: https://gitlab.com/islandoftex/arara We basically have 6 modules: •
api
cli
(main entry) •
core
kotlin-dsl
lua
mvel
Source code has bits in
common
and
jvm
. We target only JVM at the moment, and pack everything via the
shadow
plugin. Back then, we tried to target Java 8, but we are keen on raising the bar to Java 11. (continued)
We tried to port our codebase to Multiplatform targeting the latest and greatest Kotlin, but that didn't work. I then tried desperate measures in rewriting most of the stuff from scratch and adding bits here and there. My attempt is here: https://gitlab.com/islandoftex/arara/-/tree/clone-protocol-66 (continued)
I bumped Gradle version, libraries as well as Kotlin version. I think I advanced a good length, however, I cannot make
shadow
work for whatever reason. I even came to a point where
Copy code
$ ./gradlew run
was actually working, but no way I could make
build
generate a fat
.jar
for us. (continued)
Apologies for this convoluted, huge codebase, but unfortunately we had a hard time trying to make our way through the docs (specially when things get mixed up with Compose). If someone can shed some light on what we could do to make it work, or even make it better maintainable, we appreciate it! Thanks in advance! gratitude thank you
t
Check this or try beta release of shadow plugin: https://github.com/GradleUp/shadow/releases/tag/9.0.0-beta15
p
Hey @tapchicoma, that's amazing! 🔥 Now I don't get any errors regarding
shadow
, thank you! gratitude thank you Out of curiosity, I thought
shadowJar
would be automatically tied up to
build
, so when
Copy code
$ ./gradlew build
was called, I'd also have my fat
.jar
built as well, but it seems this is not the case here. What I did, and I don't know if it's advisable, is to add
Copy code
tasks {
    build {
        dependsOn("shadowJar")
    }

...
}
to my
cli/build.gradle.kts
, so
shadowJar
would be triggered in the
build
phase (to the best of my understanding). Thanks again, now there's only one additional thing I need to figure out. 🙂
👍 1
I was wondering what would be the best way of setting the
jvm
target to, e.g, Java 11. At the moment, I have
Copy code
subprojects {
    configure<KotlinMultiplatformExtension> {
        jvm {
            compilerOptions {
                jvmTarget.set(JvmTarget.JVM_11)
            }
        }
    }
...
}
in my main
build.gradle.kts
, but I don't think it's working. I used to rely on
jvmToolchain(11)
in other projects, but I've never done this in a multi-module Multiplatform, so any hints would be appreciated. 🙂 (I also might need a newbie intro to that, because my brain is frying from this overflow 😁_)_
t
jvm {}
basically creates a JVM target - otherwise your snippet should work
jvmToolchain(11)
does the same and available for
KotlinBaseExtension
(doc) which
KotlinMultiplatformExtension
inherits
p
Ah that's great! I think I prefer
Copy code
configure<KotlinMultiplatformExtension> {
   jvmToolchain(11)
}
to make it less cluttered. 😉 Edit: this does not work, oopsie. 😅
Just expanding a bit, it seems using
jvmToolchain
raises me another error:
Copy code
Task with name 'jvmTest' not found in project ':api'.
whereas my code above seems to work...
t
because your code above is also creating JVM target in the projects
✔️ 1
👍 1
p
Oopsie, full ack @tapchicoma! 😅