// tag::managed-type-plugin-and-dsl[] // tag::managed-type-and-plugin[] // tag::managed-type[] @Managed interface Person { // tag::property-type-string[] void setFirstName(String name) String getFirstName() // end::property-type-string[] void setLastName(String name) String getLastName() // end::managed-type[] // end::managed-type-and-plugin[] // end::managed-type-plugin-and-dsl[] // tag::property-type-int[] void setAge(int age) int getAge() // end::property-type-int[] // tag::property-type-boolean[] void setEmployed(boolean isEmployed) boolean isEmployed() // end::property-type-boolean[] // tag::property-type-managed[] void setMother(Person mother) Person getMother() // end::property-type-managed[] void setFather(Person father) Person getFather() // tag::property-type-managedset[] ModelSet getChildren() // end::property-type-managedset[] // tag::property-type-file[] void setHomeDirectory(File homeDir) File getHomeDirectory() // end::property-type-file[] // tag::property-type-long[] void setId(Long id) Long getId() // end::property-type-long[] // tag::property-type-enum[] void setMaritalStatus(MaritalStatus status) MaritalStatus getMaritalStatus() // end::property-type-enum[] // tag::property-type-collection-scalar[] void setUserGroups(List groups) List getUserGroups() // end::property-type-collection-scalar[] // tag::managed-type-plugin-and-dsl[] // tag::managed-type-and-plugin[] // tag::managed-type[] } // end::managed-type[] // tag::rule-source-plugin[] class PersonRules extends RuleSource { // tag::create-rule[] @Model void person(Person p) {} // end::create-rule[] // tag::plugin-mutate-rule[] //Create a rule that modifies a Person and takes no other inputs @Mutate void setFirstName(Person p) { p.firstName = "John" } // end::plugin-mutate-rule[] // tag::task-create-rule[] //Create a rule that modifies a ModelMap and takes as input a Person @Mutate void createHelloTask(ModelMap tasks, Person p) { tasks.create("hello") { doLast { println "Hello $p.firstName $p.lastName!" } } } // end::task-create-rule[] } apply plugin: PersonRules // end::rule-source-plugin[] // end::managed-type-and-plugin[] // tag::dsl[] model { person { lastName = "Smith" } } // end::dsl[] // end::managed-type-plugin-and-dsl[] enum MaritalStatus { SINGLE, MARRIED }