Hi,
I’m trying to put a domain object inside a named domain object in a container, but does not really work. Example plugin:
class DevelopmentEnvironmentInstallation {
String hest
}
class Product {
final String name
DevelopmentEnvironmentInstallation developmentEnvironmentInstallation
Product(String name) {
this.name = name
}
void developmentEnvironmentInstallation(Action<? super DevelopmentEnvironmentInstallation> action) {
action.execute(developmentEnvironmentInstallation)
}
}
class PlatformPlugin implements Plugin<Project> {
void apply(Project project) {
def products = project.container(Product)
project.extensions.products = products
products.all {
developmentEnvironmentInstallation = project.getObjects().newInstance(DevelopmentEnvironmentInstallation)
}
}
}
apply plugin: PlatformPlugin
products {
prod1 {
}
prod2 {
developmentEnvironmentInstallation {
hest = "pony"
}
}
}
task listProducts {
doLast {
products.each { product -> println "$product.name"}
}
}
The “hest” field seems to catch scope from Product object and not DevelopmentEnvironmentInstallation object as intended. Any suggestions how to do this correctly? The error I get is
Could not find method hest() for arguments [pony] on object of type Product.