-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.blog
114 lines (95 loc) · 1.97 KB
/
build.gradle.blog
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
108
109
110
111
112
113
114
apply from: 'other.gradle'
task test {
doLast {
println "版本 : ${version}\n地址 : ${url}"
}
}
task hello {
group = 'build'
description = 'hello world'
doLast {
println "任务分组: ${group}"
println "任务描述: ${description}"
}
}
def Task hello2 = task(hello2, group: BasePlugin.BUILD_GROUP)
hello2.doLast {
println "Hello World 2"
}
tasks.create(name: "hello3") {
doLast {
println "Hello World 3"
}
}
task go(dependsOn: hello) {
doLast {
println "go for it"
}
}
3.times { number ->
task "task$number" {
doLast {
println "task $number"
}
}
}
task methodTest {
doLast {
/*add(1, 2)
println "minus result = ${minus(1, 2)}"*/
for (i in 0..3) {
println i
}
}
}
def add(int num1, int num2) {
println num1 + num2
}
int minus(int num1, int num2) {
return num1 - num2
}
task classTest {
doLast {
def person = new Person()
person.increaseAge 5
println person.age
}
}
class Person {
String name
Integer age = 10
def increaseAge(Integer years) {
this.age += years
}
}
task listTest {
doLast {
/*def number = [1, 2, 3]
assert number instanceof List
def linkedList = [1, 2, 3] as LinkedList
assert linkedList instanceof LinkedList*/
def number = [1, 2, 3, 4]
assert number[1] == 2
assert number[-1] == 4
number << 5
assert number[4] == 5
assert number[-1] == 5
}
}
task mapTest {
doLast {
def name = [one: "魏无羡", two: "杨影枫", three: "张无忌"]
assert name['one'] == "魏无羡"
assert name.two == "杨影枫"
}
}
task fileTest {
doLast {
def fileName = 'F:\\Test\\git_pro\\build.gradle'
def file = new File(fileName)
/*file.eachLine {
println it
}*/
println file.text
}
}