-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
68 lines (60 loc) · 2.05 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
plugins {
id 'com.gradle.build-scan' version '1.16'
}
def branch = findProperty('branch')
def message = findProperty('message')
task branchAll {
group 'Git Branching'
description "Branches git branch name -Pbranch=$branch"
}
task statusAll {
group 'Git Status'
description 'List Git status for all submodules'
}
task commitAll {
group 'Git Commit'
description "Commit all with message -Pmessage=$message"
}
task requireBranch {
doLast {
if (branch == null || branch.trim() == "" || branch.trim() != branch) {
throw new Exception('You need to specify a branch with -Pbranch=')
}
}
}
task requireMessage {
doLast {
if (message == null || message.trim() == "" || message.trim() != message) {
throw new Exception('You need to specify a message with -Pmessage=')
}
}
}
subprojects.forEach { project ->
println(project.name)
def newTask = tasks.create(name: "branch${project.name}", type: Exec) {
group 'Git Branching'
description "Branches git for submodule in ${it.name}, branch name -Pbranch=$branch"
commandLine 'git', '-C', project.name, 'checkout', '-b', branch
dependsOn requireBranch
}
branchAll.dependsOn(newTask)
def newStatusTask = tasks.create(name: "status${project.name}", type: Exec) {
group 'Git Status'
description "Git status for submodule in ${it.name}"
commandLine 'git', '-C', project.name, 'status'
ignoreExitValue true
}
statusAll.dependsOn(newStatusTask)
def newCommitTask = tasks.create(name: "commit${project.name}", type: Exec) {
group 'Git Commit'
description "Git commit for submodule in ${it.name} with message -Pmessage=${findProperty('message')}"
commandLine 'git', '-C', project.name, 'commit', '-a', "-m${findProperty('message')}"
ignoreExitValue true
dependsOn requireMessage
}
commitAll.dependsOn(newCommitTask)
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}