-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle.kts
174 lines (150 loc) · 5.21 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.spotbugs.snom.Effort
plugins {
id("java")
id("maven-publish")
id("com.github.mfarsikov.kewt-versioning") version "1.0.0"
id("se.patrikerdes.use-latest-versions") version "0.2.18"
id("com.github.ben-manes.versions") version "0.51.0"
id("pmd")
id("com.github.spotbugs") version "6.0.23"
id("org.gradle.signing")
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.adarshr.test-logger") version "4.0.0"
}
allprojects {
apply {
plugin("com.github.mfarsikov.kewt-versioning")
plugin("se.patrikerdes.use-latest-versions")
plugin("com.github.ben-manes.versions")
}
repositories {
mavenCentral()
}
kewtVersioning.configuration {
separator = ""
}
version = kewtVersioning.version
group = "io.github.open-coap"
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { candidate.version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isNonStable = !(stableKeyword || regex.matches(candidate.version))
// newer version of logback-classic is not java8 compatible
// newer version of kewt-versioning plugin requires java 21
isNonStable || listOf("logback-classic", "mockito-core", "com.github.mfarsikov.kewt-versioning.gradle.plugin").contains(candidate.module)
}
}
}
subprojects {
apply {
plugin("java")
plugin("pmd")
plugin("com.github.spotbugs")
plugin("jacoco")
plugin("maven-publish")
plugin("org.gradle.signing")
plugin("com.adarshr.test-logger")
}
val projSourceSets = extensions.getByName("sourceSets") as SourceSetContainer
tasks {
withType<Test> {
useJUnitPlatform()
}
withType<JavaCompile> {
if (!JavaVersion.current().isJava8) {
options.release.set(8)
}
options.encoding = "UTF-8"
}
withType<JacocoReport> {
reports {
xml.required.set(true)
html.required.set(true)
}
}
withType<Javadoc> {
(options as CoreJavadocOptions).addBooleanOption("Xdoclint:accessibility,html,syntax,reference", true)
}
create<Jar>("sourceJar") {
archiveClassifier.set("sources")
from(projSourceSets["main"].allSource)
}
create<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
from(javadoc)
}
named("pmdTest").get().enabled = false
named("spotbugsTest").get().enabled = false
}
pmd {
toolVersion = "6.55.0"
isConsoleOutput = true
ruleSets = emptyList()
ruleSetFiles = files(rootProject.file("pmd-rules.xml"))
}
spotbugs {
effort.set(Effort.MAX)
excludeFilter.set(rootProject.file("spotbugs-exlude.xml"))
}
configurations.named("spotbugs").configure {
resolutionStrategy.eachDependency {
if (requested.group == "org.ow2.asm") {
useVersion("9.5")
because("Asm 9.5 is required for JDK 21 support")
}
}
}
publishing {
publications {
create<MavenPublication>("OSSRH") {
from(components["java"])
groupId = "io.github.open-coap"
artifact(tasks["sourceJar"])
artifact(tasks["javadocJar"])
pom {
name.set("Java CoAP")
description.set("Java implementation of CoAP protocol")
url.set("https://github.com/open-coap/java-coap")
scm {
url.set("https://github.com/open-coap/java-coap")
}
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Szymon Sasin")
email.set("[email protected]")
}
}
}
}
}
}
signing {
val signingKeyId: String? by project
val signingKey: String? by project
val signingPassword: String? by project
if (signingKey != null) {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications["OSSRH"])
}
}
}
nexusPublishing {
repositories {
sonatype {
val ossrhUserName: String? by project
val ossrhPassword: String? by project
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(ossrhUserName)
password.set(ossrhPassword)
}
}
}