Slackbot
08/14/2023, 1:11 PMVampire
08/14/2023, 1:24 PMdependsOn
or mustRunAfter
as these are in 98.7 % of cases just symptom treatment. (number made up)Vampire
08/14/2023, 1:24 PMVampire
08/14/2023, 1:24 PMsrcDir
on the source directory set.Adam
08/14/2023, 1:25 PMThe example is a plugin that generates sources in build/generated and adds the path to the main source setIs this a plugin you control? Do you know how it's adding the sources? My guess is that it's not adding a new srcDir by mapping the generation task? E.g.
// build.gradle.kts
sourceSets {
main {
resources {
// add a new resource dir that is produced by the generation task
srcDir(myCodeGenerationTask.map { it.temporaryDir })
}
}
}
Vampire
08/14/2023, 1:25 PMThomas Keller
08/14/2023, 1:38 PMsourceSets.getByName("main") {
kotlin.srcDir("$buildDir/generated/source/api/src/main/kotlin")
}
The task that fills the directory with things is setup like this:
tasks.withType<GenerateTask>().configureEach {
generatorName.set("kotlin")
outputDir.set("$buildDir/generated/source/api")
...
}
I guess this is the culprit then, since itโs a hard-wired path and not a DirectoryProperty
. Even more so, the plugin has the outputDir
defined as Property<String>
Thomas Keller
08/14/2023, 1:40 PMProperty<String>
wiring suffice here or would Gradle still complain then?Adam
08/14/2023, 1:42 PMoutputDir
is marked with @OutputDirectory
and that the generation tasks are converted to file-providers and added as SrcDirs to the Android SourceSet, so Gradle will be able to figure out the task dependenciesThomas Keller
08/14/2023, 1:45 PMVampire
08/14/2023, 1:47 PM