Building a Kotlin Dropwizard Maven REST API from scratch

Part 1: Configuring Maven

Kotlin is a great JVM language, that started being popular with Android development but has started increasing its popularity with other types of development, including backend services.

However most of the tutorials on the internet use Kotlin with Gradle, and while that is a great way to build your Kotlin application, sometimes you will want or need to use Maven instead. The good news is that it also is actually incredibly easy to do as well.

Dropwizard is a light-weight, high performance RESTful API framework, similar to Spring Boot in that it makes it easy to start building something useful quickly, it doesn’t come with a lot of the bloat that Spring applications often do.

This series will run you through every step of the way. You can do all of this manually (after installing Maven and the Java 8 JDK), but I would highly recommend using IntelliJ Community Edition. It’s free and made by the same creators of the Kotlin language. If you are using IntelliJ, click Create New Project, Select Maven, JDK 1.8, next, enter details, next, next, finish.

If doing it manually, after creating a new folder for your project, the first task you will need to do is create a “Project Object Model” file for Maven, named pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation=""
        xmlns="" xmlns:xsi="">




All we have done here is defined some properties about the artefact and some version numbers. Next we need to use Maven for its primary purpose, avoiding dependency hell, and add some libraries to our project. You should not but surprised by this as it’s the topic of this guide, we will be adding Kotlin & Dropwizard, to do this add the below between </properties> and </project>:



Unfortunately, Maven is still not ready to use yet. To finish it off, we need to add the Kotlin plugin so our code can be compiled to bytecode so it can run on the JVM. Just before the </project> closing tag, add the below XML.


Wow! A lot of stuff happening. Let’s break it down into three parts. The two source directory items are just configuring the build tool, telling them where to look for our code that will be added in the next section.

The <plugin> section is configuring the Kotlin plugin to do the compiling our source code for us. Lucky for us the plugin does all the hard work so we don’t have to. Remember the languageVersion and jvmTarget we defined at the beginning? This tells the compiler what version of the JDK we are targeting (Java 8) and what version of the Kotlin language we want to use, 1.3.

Congratulations, you have now completed your POM file, now to start coding.

About the Author


Mannan is a software engineering enthusiast and has been madly coding since 2002. When he isn't coding he loves to travel, so you will find both of these topics on this blog.

Leave a Reply

Your email address will not be published. Required fields are marked *