-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathcheckstyle.gradle
55 lines (45 loc) · 1.39 KB
/
checkstyle.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
apply plugin: 'checkstyle'
checkstyle {
toolVersion = '10.12.3'
}
def filterCheckstyleFiles(String diffFiles){
ArrayList<String> filterList = new ArrayList<String>();
String [] files = diffFiles.split("\\n")
for (String file : files) {
if (file.endsWith(".java")
|| file.endsWith(".xml")
|| file.endsWith(".properties")
) {
filterList.add(file)
}
}
return filterList
}
task checkstyle(type: Checkstyle) {
source 'src'
exclude '**/gen/**'
exclude '**/test/**'
exclude '**/androidTest/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
exclude '**/authpack.java'
if (project.hasProperty('commit_diff_files')) {
def ft = filterCheckstyleFiles(project.property('commit_diff_files'))
if (ft.size() > 0) {
for (int i = 0; i < ft.size(); i++) {
String splitter = ft[i];
String[] fileName = splitter.split("/");
include '**/' + fileName[fileName.size() - 1];
}
} else {
include 'null'
}
println("checkstyle >> check commit diff files...")
println("checkstyle >> " + includes.toList())
} else {
include '**/*.java'
println("checkstyle >> check all java files...")
}
configFile new File(rootDir, "checkstyle.xml")
classpath = files()
}