This message was deleted.
# android
s
This message was deleted.
e
I believe this might be deprecated but still works
Copy code
android {
    applicationVariants.all { // or as appropriate
        registerJavaGeneratingTask(task, outputDir) // not Provider, unfortunately
🚫 1
s
yeah, but,
applicationVariants
is only accessible from
AppExtension
and not from
BaseExtension
and, it only adds to the main source set of a variant, but I need to add my generated sources to all source sets
e
for the first issue, you could do a hack like
Copy code
android {
    val variants = when (this) {
        is AppExtension -> applicationVariants
        is LibraryExtension -> libraryVariants
        else -> throw GradleException("unsupported")
    }
for the second, how much does it matter? if it's in the main source set, it's visible in the test source sets too
if that doesn't work for you, then maybe add the task to prebuild dependencies, which isn't great but I don't think there's another API to handle this cleanly
c
s
@ephemient yeah, that could work if the goal was to only make these sources visible to test/variant sources, but the problem that I’m trying to solve here is to trigger java compilation within these source sets when they don’t have any java sources