Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin Multiplatform Support (2500USD Bounty) #3867

Open
4 tasks
lihaoyi opened this issue Oct 29, 2024 · 5 comments
Open
4 tasks

Kotlin Multiplatform Support (2500USD Bounty) #3867

lihaoyi opened this issue Oct 29, 2024 · 5 comments
Labels

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Oct 29, 2024


From the maintainer Li Haoyi: I'm putting a 2000USD bounty on this issue, payable by bank transfer on a merged PR implementing this.


The goal of this bounty is to flesh out the missing parts of Kotlin-Multi-Platform support. Previous Kotlin support in Mill is mostly for the JVM (#3451) with some support for web and very basic Kotlin-JS use cases (#3611). The goal here is to flesh out the Kotlin-JS functionality, add support for Kotlin-Native, and improve the overall multi-platform support e.g. publishing and consuming KMP modules and writing KMP applications

  • Example for Kotlin/JS support of browser executables and test runner with selectors (500USD)

    • Currently we only support node executables
  • Example for Kotlin/Native support (1000USD)

    • This should be the equivalent of example/kotlinlib/basic/1-simple as well as example/scalalib/native/2-interop but written using Kotlin-Native.
  • Publishing Kotlin-Multi-Platform modules

    • Proper support for .module files such that they can be resolved by Gradle's kotlin-multi-platform integration (500USD)
  • Example of a hello-world Kotlin-Multi-Platform app that uses Jetpack-Compose-Multi-Platform to support Desktop/Android/Web (500USD)

    • This can be a relatively trivial Hello-World application, but it should work on all three platforms using the same Kotlin code

These milestones are open for discussion, and can be modified or additional milestones added if necessary

@c0d33ngr
Copy link
Contributor

c0d33ngr commented Nov 4, 2024

Hello @lihaoyi do you want item 2 to use just KotlinModule and the kotlin/native cli compiler or it's something much more than that

@lihaoyi
Copy link
Member Author

lihaoyi commented Nov 4, 2024

@c0d33ngr i expect we would need a KotlinNativeModule, since kotlin native would have its own flags and configuration. This would be similar to ScalaNativeModule

@c0d33ngr
Copy link
Contributor

c0d33ngr commented Nov 4, 2024 via email

lihaoyi added a commit that referenced this issue Nov 7, 2024
This PR partially addresses #3670: it contains working example, but
doesn't contain any docs.

This example contains compilation and test execution for all the modules
of https://github.com/arrow-kt/arrow for the JVM and JS (Node) targets,
except
[arrow-optics-compose](https://github.com/arrow-kt/arrow/tree/main/arrow-libs/optics/arrow-optics-compose)
module (it requires better Android support by Mill).

Full example run takes 6 minutes on my machine, so it is extracted into
a dedicated CI job.

The following Gradle plugins are not added to the example build script,
because their respective tooling is Gradle-dependent (no raw-jar or
CLI):

* https://github.com/xvik/gradle-animalsniffer-plugin (although maybe it
is possible to use options from
https://www.mojohaus.org/animal-sniffer/)
* https://github.com/Kotlin/kotlinx-knit
* https://github.com/Kotlin/binary-compatibility-validator
* https://github.com/diffplug/spotless

There is also no publication support in this example (requires Kotlin
Multiplatform publishing support, see
#3867)

I faced the following issues while writing this example:

* There is quite a lot of duplication for JVM/JS configuration, because
there is no support of [Kotlin Multiplatform
hierarchies](https://kotlinlang.org/docs/multiplatform-hierarchy.html)
* Each Maven or Module dependency should be with JS/JVM/etc. target
qualifier, which also quite explodes amount of code to be written. This
is also a question of Kotlin Multiplatform hierarchies support and
resolution.
* Until KMP hierarchies and target resolution support is not
implemented, adding a new compilation target will bring quite a lot of
new code in the build script. And there is a lot of targets in Arrow:
https://github.com/arrow-kt/arrow-gradle-config/blob/97ba7b5eab810a336cf4070eb717f05533d208a8/arrow-gradle-config-kotlin/src/main/kotlin/io.arrow-kt.arrow-gradle-config-kotlin.gradle.kts#L34-L69
* There is no possibility to disable tests for the particular module (so
I had to use a hack with overriding `compile` / `test` tasks) - this is
because tests is dedicated module, but if comes as a part of the trait,
we cannot add / remove it dynamically. Having such control is handy when
certain multiplatform modules have a common trait for the main
compilation unit, but some of them may have no tests.

Regarding docs: I think it is too early to write any comparison with
Gradle, because clearly new functionality will be added to the Kotlin
support in Mill which will affect overall execution time and also the
comparison should be done not only for JVM targets, but for Kotlin/JS
and Kotlin/Native targets as well. And ideally it should be a defined
methodology for such testing (for example, certain Gradle plugins should
be removed from the Arrow Gradle build script, to have the same set as
Mill build script; compiler execution time should be excluded (it may be
different because of the different flags passed to it under the hood)).

So I propose to open a dedicated bounty for writing such doc.

---------

Co-authored-by: 0xnm <0xnm@users.noreply.github.com>
Co-authored-by: Li Haoyi <haoyi.sg@gmail.com>
@c0d33ngr
Copy link
Contributor

@0xnm the example about kotlin/native support that @lihaoyi included. What kind of implementation do you expect for the KotlinNative module?
With the android and python modules which both use cli tool under the hood.
Is that what you expect for a KotlinNative module? Using the kotlin native compiler under the hood.
I want to confirm cause the kotlin-native doc says it won't scale well for very larger project with lots of files and libraries

@0xnm
Copy link
Contributor

0xnm commented Dec 21, 2024

Any target supported by Kotlin/Native, they are listed here. Obviously, some targets may require additional setup/compiler flags and moreover require a certain platform to be compiled on (e.g. Apple targets can be compiled only on Apple boxes), so if you want to try tackle it I would suggest starting with Linux or Windows target.

The exact use of Kotlin/Native depends on the way compiler is distributed, you may want to check first how Kotlin and Kotlin/JS code is implemented in mill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants