Importing types from plugin RuleSource


(Liam Fisk) #1

I’m trying to figure out the “right” way to add model types from a plugin.

Say I had:

@Managed
interface Foo {
  ... some properties ...
  ModelMap<Bar> getBars()
}

class FooRuleSource extends RuleSource {

  @Model void foo(Foo foo) {}

}

model {
  foo {
    ... some config ...
    bars {
      baz(Bar) {
         ... some config ...
      }
  }
}

I would be perfectly fine if the plugin was defined in the build.gradle where it was used. However, if I extract the plugin to a standalone project, Bar will no longer be available. As a result, users would have to do:

import org.hello.world.Bar

in order to use the plugin. Is there a way around this? Or a better way to add Bars to the model map without needing to declare the type?