-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
199 lines (173 loc) · 6.17 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
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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
id("org.jetbrains.kotlin.jvm") apply false
id("org.jetbrains.dokka") apply false
id("io.github.gradle-nexus.publish-plugin")
id("com.github.ben-manes.versions")
id("org.jlleitschuh.gradle.ktlint") apply false
`maven-publish`
`signing`
}
allprojects {
group = "org.radarbase"
version = "1.2.1"
}
subprojects {
apply(plugin = "kotlin")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "maven-publish")
apply(plugin = "signing")
val myProject = this
val githubRepoName = "RADAR-base/radar-spring"
val githubUrl = "https://github.com/$githubRepoName.git"
val githubIssueUrl = "https://github.com/$githubRepoName/issues"
repositories {
mavenCentral()
mavenLocal()
}
// Ensure that dokka does not use vulnerable packages
dependencies {
val dokkaVersion: String by project
configurations["dokkaHtmlPlugin"]("org.jetbrains.dokka:kotlin-as-java-plugin:$dokkaVersion")
val jacksonVersion: String by project
val jsoupVersion: String by project
val kotlinVersion: String by project
sequenceOf("dokkaPlugin", "dokkaRuntime")
.map { configurations[it] }
.forEach { conf ->
conf(platform("com.fasterxml.jackson:jackson-bom:$jacksonVersion"))
conf("org.jsoup:jsoup:$jsoupVersion")
conf(platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion"))
}
}
val sourcesJar by tasks.registering(Jar::class) {
from(myProject.the<SourceSetContainer>()["main"].allSource)
archiveClassifier.set("sources")
description = "Main source Jar for the application"
val classes by tasks
dependsOn(classes)
}
val dokkaJar by tasks.registering(Jar::class) {
from("$buildDir/dokka/javadoc")
archiveClassifier.set("javadoc")
description = "Assembles Kotlin docs with Dokka"
val dokkaJavadoc by tasks
dependsOn(dokkaJavadoc)
}
tasks.withType<JavaCompile> {
options.release.set(17)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
apiVersion = "1.8"
languageVersion = "1.8"
}
}
afterEvaluate {
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
}
tasks.withType<Test> {
testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
useJUnitPlatform()
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
}
tasks.withType<Tar> {
compression = Compression.GZIP
archiveExtension.set("tar.gz")
}
tasks.withType<Jar> {
manifest {
attributes(
"Implementation-Title" to myProject.name,
"Implementation-Version" to myProject.version
)
}
}
val assemble by tasks
assemble.dependsOn(sourcesJar)
assemble.dependsOn(dokkaJar)
publishing {
publications {
create<MavenPublication>("mavenJar") {
afterEvaluate {
from(components["java"])
}
artifact(sourcesJar)
artifact(dokkaJar)
pom {
name.set(myProject.name)
description.set(myProject.description)
url.set(githubUrl)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("yatharthranjan")
name.set("Yatharth Ranjan")
email.set("yatharthranjan89@gmail.com")
}
}
issueManagement {
system.set("GitHub")
url.set(githubIssueUrl)
}
organization {
name.set("RADAR-base")
url.set("https://radar-base.org")
}
scm {
connection.set("scm:git:$githubUrl")
url.set(githubUrl)
}
}
}
}
}
signing {
useGpgCmd()
isRequired = true
sign(tasks["sourcesJar"], tasks["dokkaJar"])
sign(publishing.publications["mavenJar"])
}
tasks.withType<Sign> {
onlyIf { gradle.taskGraph.hasTask(myProject.tasks["publish"]) }
}
}
}
fun Project.propertyOrEnv(propertyName: String, envName: String): String? {
return if (hasProperty(propertyName)) {
property(propertyName)?.toString()
} else {
System.getenv(envName)
}
}
nexusPublishing {
repositories {
sonatype {
username.set(propertyOrEnv("ossrh.user", "OSSRH_USER"))
password.set(propertyOrEnv("ossrh.password", "OSSRH_PASSWORD"))
}
}
}
tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
val regex = "RELEASE|FINAL|GA|-jre|^[0-9,.v-]+(-r)?$".toRegex(RegexOption.IGNORE_CASE)
rejectVersionIf {
!regex.containsMatchIn(candidate.version)
}
}
tasks.wrapper {
gradleVersion = "8.0.2"
}