bod
11/01/2019, 7:29 PM// Create a Version.kt file and add it to the source set
task generateSources {
def outputDir = file("$buildDir/generated/source/kotlin")
outputs.dir outputDir
doFirst {
def outputWithPackageDir = new File(outputDir, "com/example/mylib")
outputWithPackageDir.mkdirs()
new File(outputWithPackageDir, "Version.kt").write("package com.example.mylib\ninternal const val VERSION = \"$project.version\"")
}
}
compileKotlin.dependsOn generateSources
compileKotlin.source += generateSources.outputs.files
But that doesn't work in my multiplatform module. I've tried to replace compileKotlin
by compileKotlinCommon
but doesn't work either.
Ideas?h0tk3y
11/05/2019, 3:41 PMkotlin.sourceSets.commonMain.kotlin.srcDir(generateSources.outputs.files)
. IIRC it will also add the appropriate task dependencies, so no need to specify <...>.dependsOn generateSources
. If it doesn't, use generateSources.outputs.files.builtBy(generateSources)
.bod
11/05/2019, 4:29 PMh0tk3y
01/20/2020, 1:14 AM