Buildeverything.One tool.
One small build language and one command line for Kotlin, Java, Android, C, C++ and Go. xkit downloads its own JDK, compilers and libraries, and project.lock pins every library and plugin.
curl -L https://github.com/xkit-build/xkit/releases/latest/download/xkit-aarch64-apple-darwin.tar.gz | tar xz && mv xkit-aarch64-apple-darwin/xkit ~/.local/bin/ ~/shop xkit[gateway] Running go build[api] JDK ~/.xkit/jdks/temurin-21-macos-aarch64/Contents/Home[api] Resolving dependencies (Kotlin 2.4.21)[api] Compiling 1 Kotlin file(s)[pricing] Compiling 1 C/C++ file(s)[gateway] Done: ~/shop/gateway/build/commands/gateway/gateway[pricing] Done: ~/shop/pricing/build/lib/libpricing.a[api] Done: ~/shop/api/build/libs/api.jar~/shop xkit[gateway] Up to date[api] Up to date[pricing] Up to date 01 / Languages
Same commands.
Every language.
build, run, test, new and add work the same everywhere. What they do comes from the language: run starts a jar with its JDK, but installs an Android app on a device. Other languages come as plugins.
- Kotlin
use kotlinjars, fat jars, KSP, compiler plugins - Java
use javajars, annotation processors, JUnit - Android
use androidapks, app bundles, R8, instrumented tests - C++
use cppprograms, libraries, vcpkg, CMake, JNI - C
use cprograms, static and shared libraries - Go
use goprograms, also for other systems - Yours
use "owner/repo"any compiler, driven by a build script
available · status as of the repository
02 / The build language
Your build script
is a real language.
Java has no official build tool, only a third-party one, Maven, and a third party on top of that, Gradle. The same program in both worlds: a Kotlin app with Gson that starts with java -jar.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>hello</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<kotlin.version>2.4.21</kotlin.version>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.class>MainKt</main.class>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.14.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>21</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
use kotlin
build_kotlin(
"hello",
list("com.google.code.gson:gson:2.14.0"),
list(maven_central()),
main_class = "MainKt",
)
xkit run downloads the JDK, Kotlin and Gson, builds the jar and starts it.
use kotlin
use go
repositories = list(maven_central())
jdk = if env("CI", default = "false") == "true" { "17" } else { "21" }
// what every service shares, in one place
service = fn (name: str, dependencies: list<str | module> = list()) -> module {
build_kotlin(
name,
dependencies,
repositories,
main_class = "MainKt",
jdk = jdk,
directory = name,
)
}
core = service("core")
api = service("api", list(core, "com.google.code.gson:gson:2.15.0"))
// a Go program for the servers, from the official plugin
build_go("gateway", goos = "linux", goarch = "arm64", directory = "gateway")
- Functions with typed parameters and defaults. What every module shares is written once.
- Conditions are values. The block that runs is the result, like the JDK of a CI build.
- Strings as types.
"auto" | "local"takes exactly those two, a typo names the nearest one. - Plugins are build scripts too. The Go support is a 66-line build script (opens in a new tab) that downloads Go and runs it. Write your own →
- No loops.
No IO.
No HTTP. - On purpose: building has to be simple and reproducible.
03 / How it works
From script
to artifact.
build reads the script, resolves what its modules need, compiles every language with its own compiler and builds modules that do not depend on each other at the same time. A module whose inputs did not change is up to date and does not build again.
Every module keeps a fingerprint of its inputs in build/fingerprints/ · nothing changed: [api] Up to date
04 / Quickstart
Three commands.
Once build is installed, a Kotlin program is three commands away. The JDK and the Kotlin compiler come with the first build.
-
Create a project
xkit new kotlin helloCreated kotlin project hello in hello with the package com.example.hello -
Build it
cd hello && xkit[hello] JDK ~/.xkit/jdks/temurin-21-macos-aarch64/Contents/Home[hello] Resolving dependencies (Kotlin 2.4.21)[hello] Compiling 1 Kotlin file(s)[hello] Done: ~/hello/./build/libs/hello.jar
-
Run it
xkit run[hello] Up to date> Running helloHello from hello