Maven

See the basic example at: examples/basic-di/pom.xml

Add dinject as a dependency.

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

Java APT - dinject-generator

Add dinject-generator as a dependency with provided scope.

<!-- Annotation processor -->
<dependency>
  <groupId>io.dinject</groupId>
  <artifactId>dinject-generator</artifactId>
  <version>1.11</version>
  <scope>provided</scope>
</dependency>

Kotlin KAPT - dinject-generator

See example at: examples/basic-di-kotlin-maven/pom.xml

For use with Kotlin we register dinject-generator as a KAPT processor to the Kotlin compiler.

The easiest way to do this is to add the io.dinject.kapt:dinject:1.11 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:dinject:1.11</tile>
        </tiles>
      </configuration>
    </plugin>

  </plugins>
</build>

The above includes the dinject-generator annotation processor only. For use with Javalin we instead include the io.dinject.kapt:javalin:1.11 tile.

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