Gradle

See the example at: examples/javalin-gradle-java-basic/build.gradle

Gradle 5.2+

Use Gradle version 5.2 or greater which has better support for annotation processing.

Also review the IntelliJ IDEA Gradle settings - see below.

Dependencies

Add dinject as a compile dependency and dinject-generator as an annotation processor.

dependencies {
  ...
  compile('io.dinject:dinject:1.11')

  annotationProcessor('io.dinject:dinject-generator:1.11')
  ...
}

Kotlin KAPT

See example at: https://github.com/dinject/examples/blob/master/basic-di-kotlin-maven/pom.xml

For use with Kotlin we register dinject-generator as a kapt processor to the Kotlin compiler rather than annotationProcessor.

dependencies {
    ...
    kapt('io.dinject:dinject-generator:1.11')
    ...
}

IntelliJ IDEA with Gradle

We want to delegate the build to Gradle (to properly include the annotation processing) so check our IDEA settings.

Settings / Build / Compiler / Annotation processors

Ensure that Enable annotation processing is disabled so that the build is delegated to Gradle (including the annotation processing):

Settings / Build / Build tools / Gradle

Make sure Build and run is delegated to Gradle.

Optionally set Run tests using to Gradle but leaving it to IntelliJ IDEA should be ok.