I have a multi-project C ++ Gradle build that creates several libraries and executables. I am trying to get subprojects of executable files (but not libraries) to compile with a fingerprint object. This works great if I cover something like this in separate build.gradle subprojects:
compileMain.doFirst { // code to generate a 'BuildInfo.cpp' from from a template. // embeds name of executable in so has to be generated anew for each exe }
Following the principles of DRY, I would rather do it once and for all at the top level of build.gradle . This is my attempt to apply it only to subprojects using the cpp-exe plugin by following these instructions :
configure(subprojects.findAll { it.plugins.hasPlugin('cpp-exe') }) { compileMain.doFirst { // same code as above } }
Alas, this does not work. However, if I put smth, like this, in a less restrictive configure block, this demonstrates that the idea of ββa plugin request should work:
configure(subprojects.findAll { true }) { task mydebug << { if ( project.plugins.hasPlugin( 'cpp-exe' ) ) { println ">>> $project.name has it!" } } }
Could it be that plugins are not applied to subprojects during the evaluation of configure close (at the top level of build.gradle )? Maybe a much easier way to achieve this?
source share