I’m new to Gradle and am trying to figure out wither to use subprojects or sourcesets to partition my multi-module build.
My setup: - I have several modules, some of which depend on each other. - Each module has its own set of test files. - Each module has a different set of dependencies (e.g. dependencies from Maven and dependencies on JARs in the filesystem) - All the modules are versioned together (i.e. I release all the JARs together with the same version number, but users can decide which subset of the JARs they want to use).
Things that would be nice, but I can live without: - If some dependencies are not available (e.g. the Android JARs), I’d still like to be able to build all the modules that don’t need the missing dependency. - I’d like to be able to say “these three modules go into the same JAR” (I separate them out as modules so that my dependencies are cleaner, but I still ship them in a single JAR to make the set of JARs easier to understand for the user).
My first try used subprojects, but I ran into two small problems (that might be correctable): - I need to have a separate Gradle file in every subproject. Not a huge issue – just slightly harder to see what’s going on. - I end up with a ‘build’ directory in each subproject directory. I’m going to have lots of subprojects (one for each example) and it would be nice to be able to nuke the build output by just deleting one directory.
Anyway, I was hoping someone with more experience could suggest a Gradle setup that best fits my build setup. Thanks!