Getting started with Maven

Add dinject and dinject-controller dependencies.

<dependency>
  <groupId>io.dinject</groupId>
  <artifactId>dinject</artifactId>
  <version>1.8</version>
</dependency>

<dependency>
  <groupId>io.dinject</groupId>
  <artifactId>dinject-controller</artifactId>
  <version>1.6</version>
</dependency>

Java APT

For Java we add the APT Annotation processors dinject-generator and javalin-generator. We typically use provided scope for these APT processors.

<!-- APT processors -->

<dependency>
  <groupId>io.dinject</groupId>
  <artifactId>dinject-generator</artifactId>
  <version>1.8</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>io.dinject</groupId>
  <artifactId>javalin-generator</artifactId>
  <version>1.6</version>
  <scope>provided</scope>
</dependency>

Kotlin KAPT

For use with Kotlin we register both javalin-generator and dinject-generator as a KAPT processors to the Kotlin compiler.

The easiest way to do this is to add the io.dinject.kapt:javalin:1.6 maven tile in build / plugins like:

<build>
  <plugins>

    <plugin>
      <groupId>io.repaint.maven</groupId>
      <artifactId>tiles-maven-plugin</artifactId>
      <version>2.12</version>
      <extensions>true</extensions>
      <configuration>
        <tiles>
          <tile>io.dinject.kapt:javalin:1.6</tile>
        </tiles>
      </configuration>
    </plugin>

  </plugins>
</build>

With Kotlin KAPT the source code isn't generated automatically on compile (as it is with Java) but instead we can specify the source code to be re-generated via:

Maven - Project - Right mouse - Generate Sources and update folders