Generating .rc files for native build from gradle

I’m trying to auto-generate Windows DLL resource files using a gradle task. The generation is fine, but unfortunately when I try to configure the WindowsResourceSet to use those files, the relevant tasks for compiling the .rc files are not generated, presumably because the generated .rc files are not yet present at the time of configuration.

apply plugin: "windows-resources"
model {

components {
    main(NativeLibrarySpec) {
        sources {
            rc {
                source {
                    srcDirs "$buildDir/rc"
                    include "**/*.rc"
                }
            }
        }
    }
}

}

Short of doing the file generation during the gradle configuration phase, is there another way to ensure that the compile*Rc tasks are actually created?