Another solution would be to make a gradle plugin that uses the kotlin parser to parse an AST from common code and use that to allow to generate new code before actually compiling everything but I unfortunately don't have the time to work on such plugin