On 13/08/2013, at 9:10 AM, Alex Ruiz <alr...@google.com> wrote: > Hi Adam, > > I have a question regarding obtaining models for sub-projects in a > multi-project project. Currently, without this new API we query an > IdeaProject, then we iterate through each IdeaModule in the IdeaProject and > get an AndroidProject (our custom model type) per IdeaModule (if available.) > > Doing the same with the new API would be something like: > > 1 public class MyAction implements BuildAction<Models>, Serializable { > 2 @Override > 3 public Models execute(BuildController controller) { > 4 IdeaProject ideaProject = controller.getModel(IdeaProject.class); > 5 DomainObjectSet<? extends IdeaModule> modules = > ideaProject.getModules(); > 6 for (IdeaModule module : modules) { > 7 AndroidProject androidProject = > controller.getModel(AndroidProject.class, module.getGradleProject()); > 8 // or AndroidProject androidProject = > controller.getModel(AndroidProject.class, > module.getGradleProject().getBuildScript()); > 9 } > 10 // create a configure the Models instance to return > 11 } > 12 } > > Currently we cannot do that because BuildController.getModel only takes a > model type and works on the top-level project only. There is no way to > specify the sub-project we'd like to obtain the model from (something like > line #7 or # 8 in the code snippet, unless I'm missing something.)
That's right. BuildController is currently just a placeholder to get things started, which is why there's just a single method on it. We can add whatever other stuff you need. > I remember you mentioned that you prefer not to pass a > org.gradle.api.Project. Would a GradleProject or GradleScript be a better > alternative? It would be a GradleProject. -- Adam Murdoch Gradle Co-founder http://www.gradle.org VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting http://www.gradleware.com