Okay, so you have source code generation, now we are moving forward. I make it short: If you do code Generation, it's easier to do that in the project you want to compile the source code as well. So only one project. Lets assume the code is generated by writing text to a kt file. You need three things then: a task that produces the code, a task dependency and a sourceset where to put the sources... Lets call the Task generateSources and you need compileKotlin.dependsOn(generateSources). Third, you need a sources folder in your build folder (because i assume you don't want the code in your src folder as it is checked in), and Register this folder as sources folder. Here
https://stackoverflow.com/questions/28345705/how-can-i-add-a-generated-source-folder-to-my-source-path-in-gradle is an answer how to do that.
You should be done after doing that. The source code Generator could be written inline in the generateSources task, as you can write groovy or kotlin inline. If that's not appropriate for you, i would simply place your code Generator in the buildSrc project... All depending on what you code generator inputs are and what it should generate