/
build.gradle
107 lines (89 loc) · 2.38 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// 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<Person> 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<String> groups)
List<String> 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<Task> and takes as input a Person
@Mutate void createHelloTask(ModelMap<Task> 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
}