Java doesn’t need such a hierarchy either. The challenge is to find a convention that works for a mix of Java, C++, and arbitrary other languages, in the same project. Of course, all of this is reconfigurable.
The C++ stuff is a work in progress, and we plan to make it easy for you to just grab the language support and define your own conventions. In ‘gradle-1.7-rc-1’, you should be able to handle your proposed source layout like:
cpp {
sourceSets {
main {
source {
srcDir "src"
include "**/*.cpp"
}
// Gradle currently has no concept of 'private' headers
exportedHeaders {
srcDir "src"
// There no convenient way to include headers recursively (this is a bug)
srcDirs "include/project1", "include/project2"
}
}
}
Note that in ‘gradle-1.8’ (latest nightly) the syntax has changed slightly to: sources {
One more point: there are already ways for gradle to automatically download the dependency header files to include when building your project, so you shouldn’t need to include them in your source tree. This is also true in the case of a multi-project build.
Check out the ‘cpp/dependencies’ and ‘cpp/multi-build’ samples.
In the future we plan to make this a lot more convenient.
And finally: I’ve just fixed the bug that prevented recursive inclusion of header files, so with the next gradle nightly you should be able to do: sources {
One more point: there are already ways for gradle to automatically download the dependency header files to include when building your project, so you shouldn’t need to include them in your source tree. This is also true in the case of a multi-project build. >>> >>>Check out the cpp/dependencies and cpp/multi-build samples. >>> >>>In the future we plan to make this a lot more convenient.
I think this misses the point. Those aren’t header files that are external. They are the header files for the current project. Are you also saying that in a multi-project build, the tool will copy header files from one directory to another if there are project-to-project dependencies? That would be an awful waste of resources, and make the build extremely slow. It is not unusual for a .cpp file to recursively #include 100s if not 1000s of header files.
No I’m not saying that the header files will be copied. I’m saying that they will be included. If they are external they will be downloaded, unzipped and included; if they are available in another project then they will be included directly.
You can see this happening in the samples I mentioned earlier: ‘cpp/dependencies’ and ‘cpp/multi-project’.
Thanks for the feedback. Remember that this is a work in progress, and many features are still to be implemented. Getting input from experienced C++ devs like yourself can really help us to shape the C++ support in Gradle to be something great.
If you’re interested in the current development plans, you might want to read the design spec.