-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
72 lines (56 loc) · 1.57 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
tasks.register("test", TestTask) {
out = new File(project.buildDir, "test.out")
def forward = new Forward()
forward.backingFile = project.file("${project.rootDir}/src/forward.txt")
messages.add(forward)
def backward = new Backward()
backward.backingFile = project.file("${project.rootDir}/src/backward.txt")
messages.add(backward)
def delegate = new Backward()
delegate.backingFile = project.file("${project.rootDir}/src/delegate.txt")
def chained = new Chained()
chained.delegate = delegate
chained.backingFile = project.file("${project.rootDir}/src/chained.txt")
messages.add(chained)
}
class TestTask extends DefaultTask {
@Nested
List<MessageProvider> messages = new ArrayList<MessageProvider>()
@OutputFile
File out
@TaskAction
void sayGreeting() {
def msg = messages.collect({it.value}).join(",")
println msg
out.text = msg
}
}
interface MessageProvider {
String getValue()
}
class Forward implements MessageProvider {
@InputFile
File backingFile
@Internal
public String getValue() {
return backingFile.text.trim()
}
}
class Backward implements MessageProvider {
@InputFile
File backingFile
@Internal
public String getValue() {
return backingFile.text.trim().reverse()
}
}
class Chained implements MessageProvider {
@Nested
MessageProvider delegate
@InputFile
File backingFile
@Internal
public String getValue() {
return delegate.getValue() + "..." + backingFile.text
}
}