On 30/08/2013, at 8:32 AM, Alex Ruiz <alr...@google.com> wrote: > Hi Adam, > > The new API works great. Thanks a lot! > > This is how I used it: > > GradleBuild build = controller.getBuildModel(); > DomainObjectSet<? extends HierarchicalElement> projects = > build.getProjects(); > for (HierarchicalElement project : projects) { > try { > AndroidProject model = controller.getModel(project, > AndroidProject.class); > System.out.println(model.getName()); > } catch (Throwable e) { > e.printStackTrace(); > } > } > > I did some debugging ant the projects returned by GradleBuild#getProjects are > proxies that wrap instances of > org.gradle.tooling.internal.gradle.BasicGradleProject. > > It would be great if we could to pass a > org.gradle.tooling.model.GradleProject, to BuildController#getModel, so we > could have something like this: > > IdeaProject ideaProject = controller.getModel(IdeaProject.class); > DomainObjectSet<? extends IdeaModule> modules = > ideaProject.getModules(); > for (IdeaModule module : modules) { > GradleProject gradleProject = module.getGradleProject(); > try { > controller.getModel(gradleProject, AndroidProject.class); > } catch (Throwable e) { > e.printStackTrace(); > } > } > > The reason for this is that we need the relationship between IdeaModule and > AndroidProject. > > An alternative would be if we could get the Gradle path of the > org.gradle.tooling.internal.gradle.BasicGradleProjects that are returned by > GradleBuild#getProjects, so we can recreate the relationship between > IdeaModule and AndroidProject based on that path.
I want to do both those things. This was just an initial pass to get something working. -- Adam Murdoch Gradle Co-founder http://www.gradle.org VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting http://www.gradleware.com Join us at the Gradle eXchange 2013, Oct 28th in London, UK: http://skillsmatter.com/event/java-jee/gradle-exchange-2013