Skip to content

Commit

Permalink
Add arrow-kt example (#3886)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent a63c840 commit 1a5605a
Show file tree
Hide file tree
Showing 6 changed files with 796 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:
millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.testCached'"
- java-version: 17
millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.testCached'"
- java-version: '17'
millargs: "'example.thirdparty[arrow].local.testCached'"
- java-version: '11'
millargs: "'example.{depth,extending}.__.local.testCached'"

Expand Down
3 changes: 2 additions & 1 deletion example/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ object `package` extends RootModule with Module {
"commons-io" -> ("apache/commons-io", "b91a48074231ef813bc9b91a815d77f6343ff8f0"),
"netty" -> ("netty/netty", "20a790ed362a3c11e0e990b58598e4ac6aa88bef"),
"mockito" -> ("mockito/mockito", "97f3574cc07fdf36f1f76ba7332ac57675e140b1"),
"gatling" -> ("gatling/gatling", "3870fda86e6bca005fbd53108c60a65db36279b6")
"gatling" -> ("gatling/gatling", "3870fda86e6bca005fbd53108c60a65db36279b6"),
"arrow" -> ("arrow-kt/arrow", "bc9bf92cc98e01c21bdd2bf8640cf7db0f97204a")
)
object thirdparty extends Cross[ThirdPartyModule](build.listIn(millSourcePath / "thirdparty"))
trait ThirdPartyModule extends ExampleCrossModule {
Expand Down
Loading

0 comments on commit 1a5605a

Please sign in to comment.