Why sorceSest doesn't obey builtBy

Hi

I’m trying to make java ‘compileJava’ task depends on code generation.

So so I started naively(I read it is the preferred way):

sourceSets {
    main {
        java {
            srcDirs += files(generatedDir) {
                builtBy generate
            }

        }
    }
}

then tried:


sourceSets {
    main {
        java {
            srcDirs += generate.outputs.files;
        }
    }
}

The generate code compiled but there is no dependency between the tasks.only this does the work:

tasks.compileJava.dependsOn generate

Is the ‘builtBy’ supposed to work ?

Thanks
Boaz