Question

Gradle multiproject structure

In RootProject, I have the build.gralde and settings.gradle. common,subProj1 and subProj2 are subprojects in settings.gradle

intermediateDir IS NOT a subproject! It is used only for grouping the subProj1, subProj2 since they are related.

Everytime I run "gradle eclipse" in the root directory, I get .classpath and .project files also in the intermediateDir, which I shouldn't since this is not a sub project! So basically intermediateDir is considered a sub project for some tasks, even if not in settings.gradle. Any quick way around this?

Was it helpful?

Solution

The way you've written settings.gradle, the intermediate directory is a subproject. Often this is desirable, as it allows you to easily configure and execute its child projects in one go, even if the intermediate project doesn't have any files or tasks of its own.

To get rid of unwanted behavior for an intermediate project, either make sure to not apply that behavior (e.g. apply plugin: "eclipse") to that project (probably you are applying it to allprojects right now), or change settings.gradle to not create an intermediate project. For example:

include "common"   
// name it any way you like, but not 
// "intermediateDir:subProj1", i.e. no ":"
include "subProj1" 
include "subProj2"

project(":subProj1").projectDir = file("intermediateDir/subProj1")
project(":subProj2").projectDir = file("intermediateDir/subProj2")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top