Skip to content

kotlin_jvm_binary

Runnable Kotlin target for the Java virtual machine.

Description

Compiles Kotlin sources into a Java archive and runs a required main class through the host Java runtime. It uses the same dependency roles and compiler attributes as kotlin_jvm_library.

Binary Attributes

AttributeTypeRequiredDefaultDescription
main_classstringyesFully qualified Kotlin main class, such as dev.once.hello.MainKt
argslist<string>no[]Arguments passed to the main class
jvm_flagslist<string>no[]Flags passed to the Java virtual machine before the classpath
run_envmap<string,string>no{}Environment variables passed to the Java runtime
env_inheritlist<string>no[]Host environment variable names inherited before run_env overrides
javastringnohost toolOverride the Java runtime path

The common attributes from kotlin_jvm_library also apply.

Dependency Edges

EdgeAcceptsDescription
depskotlin_jvm_library, java_libraryLibraries used for compilation and runtime
associateskotlin_jvm_libraryFriend modules whose internal declarations are visible during compilation
exported_depskotlin_jvm_library, java_libraryLibraries exported to downstream compile and runtime classpaths
provided_depskotlin_jvm_library, java_libraryLibraries available for compilation but omitted from runtime
runtime_depskotlin_jvm_library, java_libraryLibraries added only to runtime

Providers

The target emits kotlin_jvm_binary.

Capabilities

CapabilityOutput groupsRequired output groups
builddefault, jarnone
rundefaultjar

Outputs

OutputLocation
Java archive.once/out/<target>/<output>
Run log.once/out/<target>/run/stdout.log
Run result.once/out/<target>/run/run.json

Example

toml
[[target]]
name = "Hello"
kind = "kotlin_jvm_binary"
srcs = ["src/main/kotlin/**/*.kt"]
deps = ["./Greeting"]

[target.dependencies]
runtime_deps = ["./RuntimeSupport"]

[target.attrs]
main_class = "dev.once.hello.MainKt"
args = ["Once"]

Limitations

The target runs a main class on the host. It does not produce a self-contained distribution, shaded Java archive, native launcher, or platform installer.

Released under an open-source license.