How to find the project root from a software model Rules class?

software-model
plugins

(Andreas Axelsson) #1

There are several roundabout ways to get hold of the project root within a Rules, and this topic says the project was not bound back in October, but that’s many versions ago now. Has there been any updates?

The methods I’ve tried, and which work, include adding an extension object to the model, as those can be initialized with the project, as well s grabbing the project from realized tasks, as tasks all have a project property. However both those methods feel abusive to me.

I’m working with a project layout which is a standard layout for the specific environment, but which does not follow the standard Gradle layout, and I’d prefer if users didn’t have to manually inject the root into my model object, which is the third method I’ve used, although that doesn’t give me the project root while running @Default rules.