Bradleycorn
06/04/2025, 2:18 PMbinaries.library()
configuration?
I understand at a high level what it does (produce a distributable node library), but I can't seem to find any documentation for it, or any official information about how/when to use it.Edoardo Luppi
06/04/2025, 3:19 PMlibrary
in the docs.
Generally speaking, executable
will set up additional tasks compared to library
, mostly related to being able to execute the project via Gradle. An executable for the browser will also end up being minified in production runs.
library
is ok when the code will have to be imported somewhere else (e.g. from JS or TS).
Note that if your project will be consumed by other Kotlin projects only, you actually don't need to specify the binary type, as you don't need a distribution.Bradleycorn
06/04/2025, 3:23 PMlibrary
. It works fine. I was really just curious as to what it's doing and how it works.Edoardo Luppi
06/04/2025, 3:34 PMlibrary
will set up a binary object and its associated tasks to create a distribution, which is basically the built package you could upload to npm.Adam Semenenko
06/04/2025, 3:48 PMThe instructionexplicitly instructs the Kotlin compiler to emit executablebinaries.executable()
files. Omitting.js
will cause the compiler to only generate Kotlin-internal library files, which can be used from other projects, but not run on their own.binaries.executable()
Adam Semenenko
06/04/2025, 3:48 PMEdoardo Luppi
06/04/2025, 3:52 PMEdoardo Luppi
06/04/2025, 3:53 PM