Multi module included build query

We have an conventional plugin that applies the dependencies for subprojects. And we are looking to add the lint module to the dependency list.

Problem: Lint module is not getting resolved when we add that in the conventional plugin (or even if we use directly) unless i add an explict include for that lint module in the root settings.gradle. Is that really necessary

Project structure at high level

root project

	- settings.gradle
	- mainapp
		- subproject 1
		...
	- buildModule
		- submodule 1
			- conventional plugin 1 - applies the lib dependencies across subprojects in the mainapp
			- conventional plugin 2
		- submodule 2
		- lint module
		- settings.gradle (has includes for all submodules)

settings.gradle

	includeBuild(:buildModule)

	//it works if i add these 2 lines but AndroidStdio reports duplicate content (which is sort of understandable)
	include(:lintModule)
	project(:lintModule).projectDir = File(....)

conventional_plugin1.gradle

...
...
dependencies {
	
	....
	lintChecks(project(":lintModule"))
}

Understanding is that by including the buildModule in the root, we would be able to refer all the submodules inside. What am i missing here, can some one please help here. Appreciate any inputs

You should never ever ever ever ever try to include a project in more than one build, or you are always on the edge of hell breaking lose.

Your convention plugin at application time executes project(":lintModule") and thus searches for a project with that name in the build your apply it to. But in that build no such project exists, only in the sub-build, unless you do that evil include.

Use the normal coordinates of the project instead, you can leave out the version. You can for example find it as capability in the output of the outgoingVariants task.

1 Like

Sorry abt the late response. Yes referring the project using normal group reference worked. Thanks for the help

1 Like