--- On Wed, 4/20/11, Eric Berry <[email protected]> wrote: I actually didn't need to even do that. I can just test for 'project.sourceSets?.main?.java?.srcDirs'. If it's available I use it, otherwise I throw an exception stating that it looks like the Java plugin is not installed, and so I cannot determine the main Java source directory. This should work for a pre-existing project (one defined via settings.gradle and/or build.gradle files), but if it is also intended to help setup a new project from scratch there likely wouldn't be a project specification other than maybe just the name anywhere.
Building from scratch ideally would attempt to either directly query the JavaBasePlugin or potentially do something even more radical such as spitting out a templated build.gradle file that would apply plugin: 'java' and/or apply plugin: 'groovy', etc. then use the aforementioned logic to create the directory structures. Actually, instead of looking for a specifically named sourceSet, it might make sense to simply find all project.sourceSets that have defined "srcDirs" (guess that'd be a convention) and try to create the directory structures they require. That way you wouldn't really have to know or care which plugins were being applied at the directory creation phase, and simply attempt to create missing directories for sourceSets that are defined. -Spencer
