-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
163 lines (140 loc) · 4.73 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
/*
* Copyright © 2017-2024 Kynetics, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
import java.util.function.BinaryOperator
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext{
kotlin_version = '1.8.21'
detekt_version = '1.0.0-RC16'
dokka_version = '1.7.10'
}
repositories {
google()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "kotlinx-serialization" version "$kotlin_version" apply true
id "io.gitlab.arturbosch.detekt" version "$detekt_version"
id "org.jetbrains.dokka" version "$dokka_version"
id 'org.ajoberstar.grgit' version '5.0.0'
id "org.sonarqube" version "4.4.1.3373"
// ... another plugins
}
sonar {
properties {
property "sonar.projectKey", "Kynetics_uf-service-api"
property "sonar.projectName", "uf-service-api"
property "sonar.organization", "kynetics"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.host.url", "https://sonarcloud.io"
}
}
apply from: 'gradle/grgit.gradle'
detekt {
config = files("$rootDir/default-detekt-config.yml", "$rootDir/detekt-config.yml")
toolVersion = "1.0.0-RC16"
input = files("$projectDir")
filters = ".*/resources/.*,.*/build/.*"
}
allprojects {
apply from: "$rootDir/ktlint.gradle"
apply plugin: "org.sonarqube"
repositories {
google()
mavenLocal()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
String getBody(url) {
def connection = new URL(url).openConnection()
connection.requestMethod = 'GET'
try {
if(connection.responseCode == 200 ){
new BufferedReader(new InputStreamReader(connection.getInputStream()))
.lines().reduce(new BinaryOperator<String>() {
@Override
String apply(String s, String s2) {
println "${s} \n${s2}"
return "${s} \n${s2}"
}
}).orElse("{}")
} else if(connection.responseCode == 404 ){
"\"status\":\"NotFound\""
} else {
"{}"
}
} catch (IOException error) {
""
}
}
task checkJitpackBuild(){
group 'Jitpack'
doLast {
def url = "https://jitpack.io/api/builds/com.github.Kynetics/uf-service-api/${versionFromGit(project)}"
def attempts = 10
def body = "{}"
while (attempts > 0 && !(body.length() > 5)){
body = getBody(url)
if(body.contains("\"status\":\"NotFound\"")){
body = getBody(url.toLowerCase())
}
if(body.length() < 5){
println "Waiting for ${url}, attempts remaning ${--attempts} ..."
sleep(30000)
}
}
if(body.contains("\"status\":\"Error\"")){
throw new IllegalStateException("jitpack build fails!")
} else if(body.contains("\"status\":\"NotFound\"")){
throw new IllegalStateException("jitpack build fails! Tag not found")
} else if(body.contains("\"status\":\"ok\"")){
println "jitpack build works!"
} else {
throw new IllegalStateException("jitpack build timeout!")
}
}
}
void configureDokka(String taskName, Project pr){
def currentYear = new Date().getYear() + 1900
if(pr.tasks.findByName(taskName)) {
pr.tasks.named(taskName).configure {
outputDirectory.set(file("$rootDir/kdoc/html"))
pluginsMapConfiguration.set(
[
"org.jetbrains.dokka.base.DokkaBase": """{
"footerMessage": "Copyright @ $currentYear Kynetics"
}"""
]
)
}
}
}
def dokkaProjects = ['uf-client-service-api']
subprojects{
if(dokkaProjects.contains(it.name)){
it.afterEvaluate {
configureDokka('dokkaHtml', it)
configureDokka('dokkaHtmlPartial', it)
}
}
}