How can I add a generated Source Folder to my Source Path in Gradle?

What others answered overwrites my original directories, so I found a workaround – if you don’t want to overwrite the original directory list, you can do it like this:

sourceSets.main.java.srcDirs += myDir
sourceSets.main.kotlin.srcDirs += myDir

The key is to use += here. It’s essentially the same as stating it like this:

sourceSets {
  main {
    java.srcDirs += myDir
    kotlin.srcDirs += myDir
  }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)