-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
164 lines (146 loc) · 5.33 KB
/
build.gradle.kts
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
import java.io.FileOutputStream
import java.net.URL
plugins {
id("com.diffplug.spotless")
id("io.gitlab.arturbosch.detekt")
id("com.avast.gradle.docker-compose")
id("org.jetbrains.kotlin.jvm") apply false
}
val probeGroup: String by project
val projectVersion: String by project
val skywalkingAgentVersion: String by project
val jacksonVersion: String by project
val vertxVersion: String by project
group = probeGroup
version = project.properties["probeVersion"] as String? ?: projectVersion
repositories {
mavenCentral()
}
subprojects {
repositories {
mavenCentral()
maven(url = "https://pkg.sourceplus.plus/sourceplusplus/protocol")
}
apply(plugin = "com.diffplug.spotless")
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
val startYear = 2022
val currentYear = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)
val copyrightYears = if (startYear == currentYear) {
"$startYear"
} else {
"$startYear-$currentYear"
}
val probeProject = findProject(":probes:jvm") ?: rootProject
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
.find(File(probeProject.projectDir, "LICENSE").readText())!!
.value.lines().joinToString("\n") {
if (it.trim().isEmpty()) {
" *"
} else {
" * " + it.trim()
}
}
val formattedLicenseHeader = buildString {
append("/*\n")
append(
licenseHeader.replace(
"Copyright [yyyy] [name of copyright owner]",
"Source++, the continuous feedback platform for developers.\n" +
" * Copyright (C) $copyrightYears CodeBrig, Inc."
).replace(
"http://www.apache.org/licenses/LICENSE-2.0",
" http://www.apache.org/licenses/LICENSE-2.0"
)
)
append("/")
}
licenseHeader(formattedLicenseHeader)
}
}
apply(plugin = "io.gitlab.arturbosch.detekt")
detekt {
parallel = true
buildUponDefaultConfig = true
config.setFrom(arrayOf(File(project.rootDir, "detekt.yml")))
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
}
}
tasks {
register("downloadSkywalkingAgent") {
doLast {
val f = File(buildDir, "agent/apache-skywalking-java-agent-$skywalkingAgentVersion.tgz")
if (!f.exists()) {
f.parentFile.mkdirs()
println("Downloading Apache SkyWalking - Java agent")
URL("https://downloads.apache.org/skywalking/java-agent/$skywalkingAgentVersion/apache-skywalking-java-agent-$skywalkingAgentVersion.tgz")
.openStream().use { input ->
FileOutputStream(f).use { output ->
input.copyTo(output)
}
}
println("Downloaded Apache SkyWalking - Java agent")
}
}
inputs.property("skywalkingAgentVersion", skywalkingAgentVersion)
outputs.file(File(buildDir, "agent/apache-skywalking-java-agent-$skywalkingAgentVersion.tgz"))
outputs.cacheIf { true }
}
register("assembleUp") {
if (findProject(":probes:jvm") != null) {
dependsOn(":probes:jvm:boot:build", "composeUp")
} else {
dependsOn(":boot:build", "composeUp")
}
}
}
dockerCompose {
waitForTcpPorts.set(false)
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
}
detekt {
parallel = true
buildUponDefaultConfig = true
config.setFrom(arrayOf(File(project.rootDir, "detekt.yml")))
}
spotless {
kotlin {
target("**/*.kt")
val startYear = 2022
val currentYear = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)
val copyrightYears = if (startYear == currentYear) {
"$startYear"
} else {
"$startYear-$currentYear"
}
val protocolProject = findProject(":protocol") ?: rootProject
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
.find(File(protocolProject.projectDir, "LICENSE").readText())!!
.value.lines().joinToString("\n") {
if (it.trim().isEmpty()) {
" *"
} else {
" * " + it.trim()
}
}
val formattedLicenseHeader = buildString {
append("/*\n")
append(
licenseHeader.replace(
"Copyright [yyyy] [name of copyright owner]",
"Source++, the continuous feedback platform for developers.\n" +
" * Copyright (C) $copyrightYears CodeBrig, Inc."
).replace(
"http://www.apache.org/licenses/LICENSE-2.0",
" http://www.apache.org/licenses/LICENSE-2.0"
)
)
append("/")
}
licenseHeader(formattedLicenseHeader)
}
}