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

First Party Support for the Kotlin language (2000USD) #3451

Closed
lihaoyi opened this issue Sep 3, 2024 · 13 comments
Closed

First Party Support for the Kotlin language (2000USD) #3451

lihaoyi opened this issue Sep 3, 2024 · 13 comments
Labels
Milestone

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Sep 3, 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.


https://github.com/lefou/mill-kotlin/ exists, but it is a standalone project without many examples, and not enough for a newbie to pick up and begin using Mill with Kotlin. This ticket is to do the following:

  1. In-source https://github.com/lefou/mill-kotlin/ into the Mill repo as a kotlinlib submodule
  2. Write Kotlin versions of the example/javalib/{basic,builds,module,testing} example integration tests, where reasonable
  3. Flesh out whatever missing functionality is needed to do the above (I'm sure we'll hit things!)

As this ticket is large, I am splitting the bounty into two parts:

  1. 1000USD to get the mill-kotlin in-sourced and the example/javalib/basic examples converted to Kotlin and included on the docsite
  2. 1000USD to get the remaining examples in example/javalib/{builds,module,testing,publishing} converted to Kotlin and included on the docsite

The end result is that we have a suite of tested example documentation demonstrating how to use the Mill build tool to build a large variety of Kotlin projects mirroring the example documentation for Java and Scala projects.

Some code may be adaptable from https://github.com/rife2/bld-kotlin. ChatGPT (or claude or whatever) would probably also be a great help translating the examples; I used it heavily when setting up the Java example tests, but in the end the human still needs to debug things and polish it up so it's presentable for pedagogical purposes

@lefou lefou added the bounty label Sep 3, 2024
@llvee
Copy link

llvee commented Sep 3, 2024

If I claim this, can others also claim or start work on the bounty?

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 3, 2024

@githubbin765 As mentioned in https://github.com/orgs/com-lihaoyi/discussions/5, bounties remain open until completed.

In this case I (just) broke up the bounty into two phases so it's not such a big all-or-nothing ticket, and I can break it up further if you think it would be useful.

But fundamentally there is no locking of bounties, so others can pick it up as well, and first PR wins (at my discretion)

@llvee
Copy link

llvee commented Sep 4, 2024

I see, that makes sense. Changing the bounty rules based on specific participation seems like a good idea potentially.

Ok I seem to have identified how to in-source the library may be able to complete translating remaining examples today for the first part of this.

I will create two separate PRs one for the in-sourcing, another for examples.

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 4, 2024

I would suggest doing everything in (1) above in one PR: both the insourced library and the translated example/javalib/basic. Easier to review together with the example tests validating that the insourcing works

@llvee
Copy link

llvee commented Sep 8, 2024

The above isn't ChatGPT output. You also suggested using ChatGPT in the first post in order to help resolve this bounty. I shared the above because you stated wanting the example/javalib/basic examples converted to Kotlin and included on the docsite so I created a docsite format using Markdown. For the docsite, does the above look ok to you?

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 8, 2024

@githubbin765 I don't think the output you gave above is relevant to the bounty at hand. I'm going to clean up the thread to make space for any further discussion that may occur. Feel free to open a PR when you have the working examples and we can take it from there

@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 8, 2024
@llvee
Copy link

llvee commented Sep 8, 2024

@lihaoyi I see. I will do that. I will open a second PR for the second bounty with the doc site code.

lihaoyi pushed a commit that referenced this issue Sep 14, 2024
This PR solves Part 1 from
#3451:

* It in-sources https://github.com/lefou/mill-kotlin with minimal
changes
* It adds basic samples

I still need to finalize it (especially automated test for example
`4-builtin-commands` fails right now), but most of the work is done.

Things I noticed in the original implementation
(https://github.com/lefou/mill-kotlin):

* Kotlin stdlib is added by overriding `ivyDeps`, meaning that if the
user of `KotlinModule` wants to add its own deps and forget to call
`super.ivyDeps() ++ <their deps>` and just does `def ivyDeps = <their
deps>`, then no stdlib will be in the classpath during the compilation
and it will fail with cryptic error. Such approach is thus error-prone.
* No Kotlin Reflection library is added automatically to the compile
classpath, meaning that if code to compile contains any Kotlin
Reflection classes, compilation will fail (because `-nostdlib`
[flag](https://kotlinlang.org/docs/compiler-reference.html#nostdlib) is
used for compilation)

@lihaoyi Feel free to give your feedback while this is in a Draft state
if you want.

---------

Co-authored-by: 0xnm <[email protected]>
@0xnm
Copy link
Contributor

0xnm commented Sep 14, 2024

@lihaoyi I may look into Part 2 as well. Do you have any ideas/suggestions about Kotlin libraries/frameworks you would like to see there?

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 14, 2024

@0xnm most of the rest of the kotlinlib/ examples are roughly mechanical translations of the javalib/ examples re-arranging the stuff you already have in kotlinlib/basic/, but there are a few things that are worth calling out. Let me go through the folders below:

  • kotlinlib/builds/ should be pretty mechanical and not require anything new. It's mostly just a few different re-arrangements of the basic/ examples

  • kotlinlib/module/ should be mostly mechanical as well, except compilation-execution-flags should include some example showing off Kotlin compiler flags (I assume they have some?) and 6-annotation-processors should be replaced by some example showing a kotlin compiler plugin

  • kotlinlib/publishing/ is just one example and should be a mechanical conversion.

  • kotlinlib/testing/ should be mostly mechanical re-arrangements of stuff you already have in the test suite of the basic/ examples

  • kotlinlib/linting/ has a lot more flexibility in what we want to put in there. Let's have an example using an autoformatter (maybe https://github.com/facebook/ktfmt ?) and some linter (maybe https://github.com/pinterest/ktlint ?)

  • kotlinlib/web/ is also similarly flexible; maybe a hello world and todomvc example using https://github.com/ktorio/ktor ? There are a few examples online like https://github.com/jamowei/fritz2-ktor-todomvc that we may be able to adapt like I did for the Java micronaut/springboot todomvc examples in javalib/web/. A Kotlin-JS example would also certainly be nice, but I'd call that a nice to have and not really core

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 14, 2024

TBH the list of stuff above seems like a lot. I'd be ok if you skipped the web/ folder and did all the other stuff. We can pick up the web stuff later in a separate ticket

@lefou
Copy link
Member

lefou commented Sep 16, 2024

I think the compiler plugin stuff is essential. Showcasing usage of kotlinx.serialization might be a good candidate.

@llvee
Copy link

llvee commented Sep 16, 2024

@lefou
Is that wanted in the documentation?

Anyone else notice that the GH Issues UI creates text overflow when resizing browser windows?

@com-lihaoyi com-lihaoyi deleted a comment from llvee Sep 16, 2024
@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 16, 2024

@llvee Please open a PR if you have one that satisfies the bounty requirements, otherwise there isnt that much to continue discussing here

lihaoyi pushed a commit that referenced this issue Sep 18, 2024
This PR partially addresses Part 2 of
#3451, it add `builds` and
`linting` examples.

For the linting example I used
[detekt](https://github.com/detekt/detekt) for the static code analysis
(`error-prone` doesn't support Kotlin) and
[ktlint](https://github.com/pinterest/ktlint) for formatting.

Note: `builds/8-compat-modules` used `src/java` structure which is
dictated by the `MavenModule`, but ideally it should be `src/kotlin` for
Kotlin files and _maybe_ `src/java` for Java files.

---------

Co-authored-by: 0xnm <[email protected]>
lihaoyi pushed a commit that referenced this issue Sep 22, 2024
This PR adds more stuff for #3451, namely `example/kotlinlib/module`
examples.

Few notes about things being done:

* `1-compilation-execution-flags` - there is not so many flags which can
be passed to the Kotlin Compiler itself. I simply used
[-Werror](https://kotlinlang.org/docs/compiler-reference.html#werror).
* `6-annotation-processors` - I used `kotlinx.serialization` as proposed
by @lefou. It seems Kotlin Compiler doesn't automatically pick
compilation plugins from the classpath, so I had to pass path to it
explicitly using `-Xplugin` option.
* `7-dokkajar` - obviously `javadoc` cannot be used to generate docs for
Kotlin classes, so I added support for
[Dokka](https://github.com/Kotlin/dokka) to `KotlinModule` and added a
forwarding of `docJar` calls to `dokkaJar`.
* `13-jni` - there is no possibility to generate header files from
Kotlin files (unless an ugly trick is used to take compiled `.class`
files, decompile them back, clean-up and pass to `javac` to generate
headers), so I dropped header generation.

---------

Co-authored-by: 0xnm <[email protected]>
lihaoyi added a commit that referenced this issue Sep 22, 2024
Another addition for #3451: it adds `publishing` and `testing` examples
for Kotlin.

The only thing that needs to be mentioned is test filtering in Kotest:
it doesn't have `package.class.method` format to do the filtering,
instead it is using `specs` + `classes` parameters (see
[here](https://kotest.io/docs/framework/conditional/conditional-tests-with-gradle.html)).

Also `mockito-kotlin` requires JVM bytecode target to be 11.

Co-authored-by: 0xnm <[email protected]>
Co-authored-by: Li Haoyi <[email protected]>
@lihaoyi lihaoyi closed this as completed Sep 22, 2024
@lefou lefou added this to the 0.12.0-RC3 milestone Sep 23, 2024
@com-lihaoyi com-lihaoyi deleted a comment from llvee Oct 14, 2024
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

4 participants