im trying out code generation, this is what i have...
# gradle
l
im trying out code generation, this is what i have rn:
Copy code
val generateSources by tasks.creating {
	outputs.dir("build/generated/")
	doLast {
		File(
			outputs.files.single(),
			"generated.kt"
		).writeText("""fun foo() = println("hello from generated code")""")
	}
}
sourceSets["main"].java.srcDir(generateSources.outputs.files)
it works, but it requires me to put the code generation logic inside
build.gradle
. how do move it into a subproject ?
e
you can't use things defined in subprojects in gradle script's classpath, it'll have to be buildSrc or includedBuild
https://github.com/ephemient/kotlin-numeric currently defines custom generation tasks in buildSrc, but they could totally be made into a proper gradle plugin in an included build like I did in https://kotlinlang.slack.com/files/UJQB4DJF7/F02JTBP361H/variants-example.zip