forked from us1415/wire-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
203 lines (180 loc) · 6.3 KB
/
build.gradle
File metadata and controls
203 lines (180 loc) · 6.3 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlinVersion = '1.2.41'
repositories {
maven {
url "https://dl.bintray.com/wire-android/third-party"
}
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.mutualmobile.gradle.plugins:dexinfo:0.1.2'
classpath 'com.wire:gradle-android-scala-plugin:1.5.0'
classpath 'com.google.gms:google-services:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins {
id "com.github.hierynomus.license" version "0.13.1"
}
license {
header = file('LICENSE_HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'Wire Swiss GmbH'
skipExistingHeaders = true
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task licenseFormatAndroid(type: nl.javadude.gradle.plugins.license.License) {
source = fileTree(dir: getRootDir()).include([
"**/*.java",
"**/*.scala",
"**/*.gradle",
"**/*.xml",
]).exclude([
"**/*build*",
"**/*target*",
"**/*gen*",
"**/*generated*",
])
}
licenseFormat.dependsOn licenseFormatAndroid
ext {
compileSdkVersion = 27
// When upgrading minimum sdk you might want to search for occurrences of Build.VERSION_CODES.
// There are some classes with possibility of being simplified.
minSdkVersion = 21
targetSdkVersion = 27
buildToolsVersion = '27.0.3'
sourceCompatibilityVersion = JavaVersion.VERSION_1_8
targetCompatibilityVersion = JavaVersion.VERSION_1_8
}
allprojects {
repositories {
mavenLocal()
maven { url "https://dl.bintray.com/wire-android/releases" }
maven { url "https://dl.bintray.com/wire-android/snapshots" }
maven { url "https://dl.bintray.com/wire-android/third-party" }
maven { url 'https://maven.google.com' }
mavenCentral()
}
}
task ci(dependsOn: [
':app:assembleDevDebug',
':app:lintDevDebug',
// By default on whole app
//':app:checkstyle',
':app:pmd'
]) {
doLast {
def lintReportsPattern = /\/?(.*)\/build\/outputs\/lint-results\-(devDebug|debug)\.xml/
def pmdReportsPattern = /\/?(.*)\/build\/reports\/pmd\/pmd\.xml/
def checkstyleReportsPattern = /\/?(.*)\/reports\/checkstyle\/checkstyle\.xml/
def results = new HashMap<String, Map<String, List<Issue>>>()
def totalIssues = 0
def findFilenameClosure = {
if (it.isDirectory()) {
return;
}
def absolutePath = it.getAbsolutePath()
def foundIssues = new ArrayList<Issue>()
def type = ''
if (absolutePath.matches(lintReportsPattern)) {
def issues = new XmlParser().parse(it)
type = 'Lint'
issues.issue.each {
def id = it.'@summary'
it.location.each { foundIssues.add(new LintIssue(id, it)) }
}
} else if (absolutePath.matches(pmdReportsPattern)) {
def issues = new XmlParser().parse(it)
type = 'PMD'
issues.file.each {
def file = new File(it.'@name')
it.violation.each { foundIssues.add(new PmdIssue(file, it)) }
}
} else if (absolutePath.matches(checkstyleReportsPattern)) {
def files = new XmlParser().parse(it)
type = 'Checkstyle'
files.file.findAll { it.children().size() > 0 }.each {
def file = new File(it.'@name')
it.error.each { foundIssues.add(new CheckstyleIssue(file, it)) }
}
}
if (foundIssues.size() > 0) {
if (!results.containsKey(type)) {
results.put(type, new HashMap<String, List<Issue>>())
}
results.get(type).put(it, foundIssues)
totalIssues += foundIssues.size()
}
}
rootProject.rootDir.eachFileRecurse(findFilenameClosure)
if (totalIssues > 0) {
def message = new StringBuilder()
message.append("Found ${totalIssues} issue${totalIssues == 1 ? '' : 's'}\n\n")
for (def entry : results.entrySet()) {
def issues = new StringBuilder()
def count = 0;
for (def file : entry.value.entrySet()) {
issues.append("> ${file.value.size()} in ${file.key}\n")
file.value.each { issues.append("\t${it}\n")}
count += file.value.size()
}
message.append("${entry.key}: ${count} issue${count == 1 ? '' : 's'}\n")
.append(issues.toString())
.append('\n')
}
throw new Exception(message.toString())
} else {
println 'No issues found'
}
}
}
class Issue {
File file
String line
String column
String error
@Override
public String toString() {
return "${file}:${line}:${column}: ${error}";
}
}
class LintIssue extends Issue {
def LintIssue(String error, Node location) {
file = new File(location.'@file')
line = location.'@line'
column = location.'@column'
this.error = error
}
}
class PmdIssue extends Issue {
def PmdIssue(File file, Node violation) {
this.file = file
def beginline = violation.'@beginline'
def endline = violation.'@endline'
line = beginline == endline ? beginline : "${beginline}-${endline}"
column = violation.'@begincolumn'
error = violation.text().replaceAll(/\n/, '')
}
}
class CheckstyleIssue extends Issue {
def CheckstyleIssue(File file, Node node) {
this.file = file
line = node.'@line'
column = node.'@column'
error = node.'@message'
}
}