forked from nstdio/rsql-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
203 lines (168 loc) · 5.13 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
200
201
202
plugins {
groovy
jacoco
`java-library`
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("org.javacc.javacc") version "3.0.3"
}
repositories {
mavenCentral()
}
dependencies {
compileOnly("net.jcip:jcip-annotations:1.0")
testImplementation("nl.jqno.equalsverifier:equalsverifier:3.17.5")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.3")
testImplementation("org.spockframework:spock-core:2.4-M4-groovy-4.0")
javacc("net.java.dev.javacc:javacc:7.0.13")
}
group = "com.github.jensborch"
description = "RSQL-parser"
java {
withSourcesJar()
withJavadocJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
sourceSets {
main {
java.srcDirs(project.layout.buildDirectory.dir("generated/javacc"))
}
}
}
publishing {
publications.create<MavenPublication>("java") {
from(components["java"])
pom {
name.set("RSQL-parser")
description.set("Parser of RSQL / FIQL (query language for RESTful APIs) written in JavaCC.")
url.set("https://github.com/jensborch/rsql-parser")
inceptionYear.set("2011")
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("jirutka")
name.set("Jakub Jirutka")
organization.set("CTU in Prague")
organizationUrl.set("https://www.cvut.cz")
}
developer {
id.set("nstdio")
name.set("Edgar Asatryan")
email.set("[email protected]")
}
developer {
id.set("jensborch")
name.set("Jens Borch Christiansen")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:[email protected]:jensborch/rsql-parser.git")
developerConnection.set("scm:git:[email protected]:jensborch/rsql-parser.git")
url.set("https://github.com/jensborch/rsql-parser")
}
ciManagement {
system.set("GitHub Actions")
url.set("https://github.com/jensborch/rsql-parser/actions")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/jensborch/rsql-parser/issues")
}
}
}
}
signing {
isRequired = (version as String).endsWith("SNAPSHOT")
val signingKey = findProperty("SIGNING_KEY") as String?
val signingPassword = findProperty("SIGNING_PASSWORD") as String?
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["java"])
}
nexusPublishing {
repositories {
sonatype {
val baseUri = uri("https://oss.sonatype.org")
nexusUrl.set(baseUri.resolve("/service/local/"))
snapshotRepositoryUrl.set(baseUri.resolve("/content/repositories/snapshots/"))
username = findProperty("SONATYPE_USERNAME") as String?
password = findProperty("SONATYPE_PASSWORD") as String?
}
}
}
tasks {
test {
useJUnitPlatform()
}
withType<JacocoReport> {
reports {
val isCI = System.getenv("CI").toBoolean()
xml.required.set(isCI)
html.required.set(!isCI)
}
}
withType<Test> {
finalizedBy(named("jacocoTestReport"))
}
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
(options as? StandardJavadocDocletOptions)?.tags(
"apiNote:a:API Note:"
)
}
withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
compileJavacc {
outputDirectory = outputDirectory.resolve("cz/jirutka/rsql/parser")
}
named("sourcesJar") {
dependsOn(compileJavacc)
}
}
val newVersion: String? by project
tasks.register("bumpVersion") {
this.doFirst {
bumpVersion("gradle.properties", "version=")
bumpVersion("README.adoc", "version: ", true)
}
}
tasks.register("toSnapshot") {
this.doFirst {
val file = file("gradle.properties")
val snapshot = version.toString().contains("-SNAPSHOT")
if (!snapshot) {
file.readText().apply {
println("Adding SNAPSHOT")
val content = this.replace("version=$version", "version=$version-SNAPSHOT")
file.writeText(content)
}
}
}
}
fun bumpVersion(fileName: String, versionPattern: String, removeSnapshot: Boolean = false) {
val file = file(fileName)
val snapshot = version.toString().contains("-SNAPSHOT")
val newVersion = takeIf { newVersion.isNullOrBlank() }?.let {
val versionArray = version.toString().removeSuffix("-SNAPSHOT").split(".")
"${versionArray[0]}.${versionArray[1]}.${if (snapshot) versionArray.last().toInt() else versionArray.last().toInt().plus(1)}"
} ?: newVersion
val oldVersion = if (snapshot && removeSnapshot) version.toString().removeSuffix("-SNAPSHOT") else version.toString()
println("Bumping from version $oldVersion to $newVersion in $fileName")
file.readText().apply {
val content = this.replace("$versionPattern$oldVersion", "$versionPattern$newVersion")
file.writeText(content)
}
}