Building Ktor From Source

Estimated reading time: 2 minutes

Ktor is an OpenSource project hosted at GitHub: https://github.com/ktorio/ktor

We usually provide binary version previews at bintray: https://bintray.com/kotlin/ktor/ktor

In addition, you can use jitpack to get bleeding edge artifacts compiled from master: https://jitpack.io/#ktorio/ktor

Downloading the sources

You can get the lastest version of Ktor using GIT to clone Ktor’s repository:

git clone https://github.com/ktorio/ktor.git
cd ktor

Building

Ktor uses gradle for building. It should work with any gradle version greater than 4.3, but for best results we provide a gradle wrapper, which should work with any supported system with a JDK installed:

./gradlew build

Right now Ktor doesn’t compile with Java 9. So for now, you should stick to Java 8.

Installing locally

Ktor provides a gradle install task, that installs ktor artifacts in your local maven repository:

./gradlew install

Troubleshooting

If you get an error similar to:

* Where:
Build file '/.../ktor/ktor-server/ktor-server-benchmarks/build.gradle' line: 2

* What went wrong:
An exception occurred applying plugin request [id: 'me.champeau.gradle.jmh', version: '0.4.4']
> Failed to apply plugin [id 'me.champeau.gradle.jmh']
   > Could not generate a proxy class for class me.champeau.gradle.JMHPluginExtension.

You might have forgotten to use the gradle wrapper (./gradlew) or your default installed gradle version is lower than 4.3.

To ensure that it works, please use the gradle wrapper instead.