forked from SecretMessengerApp/secret-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
228 lines (199 loc) · 7.16 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import groovy.json.JsonSlurper
import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Credentials
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://www.jitpack.io' }
maven { url "https://pms2021u.isecret.im/nexus3/repository/maven-public/"}
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:${Versions.PLUGIN_GRADLE_VERSION}"
classpath "com.mutualmobile.gradle.plugins:dexinfo:${Versions.PLUGIN_DEXINFO_VERSION}"
classpath "com.wire:gradle-android-scala-plugin:${Versions.PLUGIN_SCALA_VERSION}"
classpath "com.google.gms:google-services:${Versions.PLUGIN_GMS_VERSION}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KOTLIN_VERSION}"
classpath "org.ajoberstar.grgit:grgit-core:${Versions.PLUGIN_GRGIT_VERSION}"
classpath 'com.github.os72:protoc-jar:3.0.0-b1'
classpath 'com.github.ghik:silencer-plugin_2.11:0.6'
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
}
}
plugins {
id "com.github.hierynomus.license" version "0.13.1"
}
ext {
// directory where customization files live
wireConfig = new File("$rootDir/default.json")
isCleanTask = gradle.startParameter.taskNames.contains("clean")
customFolder = System.getenv("CUSTOM_FOLDER") ?: ''
customRepository = System.getenv("CUSTOM_REPOSITORY") ?: ''
token = System.getenv("API_TOKEN") ?: ''
repoDir = "$rootDir/custom"
customDir = repoDir
if (!customFolder.isEmpty()) {
customDir = customDir + '/' + customFolder
}
customConfig = file("$customDir/custom.json")
def repo = file(repoDir)
if (repo.exists()) {
delete repo
}
def slurper = new JsonSlurper()
config = null
if (!customRepository.isEmpty() && !token.isEmpty()) {
credentials = new Credentials(token, '')
Grgit.clone(dir: repoDir, uri: customRepository, credentials: credentials)
project.logger.info("Cloned $repoDir to $customRepository")
config = slurper.parseText(customConfig.text)
} else {
config = slurper.parseText(wireConfig.text)
}
}
license {
header = file('LICENSE_HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'Secret'
skipExistingHeaders = true
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
maven { url 'https://www.jitpack.io' }
maven { url "https://pms2021u.isecret.im/nexus3/repository/maven-public/"}
maven { url "https://jitpack.io" }
mavenCentral()
}
}
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
task ci(dependsOn: [
':app:assembleDevDebug',
':app:lintDevDebug',
':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'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
def repo = file(repoDir)
if (repo.exists()) {
delete repo
}
}
class Issue {
File file
String line
String column
String error
@Override
String toString() {
return "${file}:${line}:${column}: ${error}"
}
}
class LintIssue extends Issue {
LintIssue(String error, Node location) {
file = new File(location.'@file')
line = location.'@line'
column = location.'@column'
this.error = error
}
}
class PmdIssue extends Issue {
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 {
CheckstyleIssue(File file, Node node) {
this.file = file
line = node.'@line'
column = node.'@column'
error = node.'@message'
}
}