-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathbuild.gradle
More file actions
260 lines (227 loc) · 7.94 KB
/
build.gradle
File metadata and controls
260 lines (227 loc) · 7.94 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import net.ltgt.gradle.errorprone.CheckSeverity
import java.text.SimpleDateFormat
plugins {
id 'java'
id 'java-library'
id 'jvm-test-suite'
id 'maven-publish'
id 'signing'
id 'groovy'
id 'biz.aQute.bnd.builder' version '6.2.0'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'com.github.ben-manes.versions' version '0.53.0'
id "me.champeau.jmh" version "0.7.3"
id "net.ltgt.errorprone" version '4.3.0'
// Kotlin just for tests - not production code
id 'org.jetbrains.kotlin.jvm' version '2.2.20'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
kotlin {
compilerOptions {
apiVersion = KotlinVersion.KOTLIN_2_0
languageVersion = KotlinVersion.KOTLIN_2_0
jvmTarget = JvmTarget.JVM_11
javaParameters = true
freeCompilerArgs = [
'-Xemit-jvm-type-annotations',
'-Xjspecify-annotations=strict',
]
}
}
def getDevelopmentVersion() {
def output = new StringBuilder()
def error = new StringBuilder()
def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute()
gitShortHash.waitForProcessOutput(output, error)
def gitHash = output.toString().trim()
if (gitHash.isEmpty()) {
println "git hash is empty: error: ${error.toString()}"
throw new IllegalStateException("git hash could not be determined")
}
def version = "0.0.0-" + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash
println "created development version: $version"
version
}
def releaseVersion = System.env.RELEASE_VERSION
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
group = 'com.graphql-java'
description = 'A pure Java 11 port of Facebook Dataloader'
gradle.buildFinished { buildResult ->
println "*******************************"
println "*"
if (buildResult.failure != null) {
println "* FAILURE - ${buildResult.failure}"
} else {
println "* SUCCESS"
}
println "* Version: $version"
println "*"
println "*******************************"
}
repositories {
mavenCentral()
mavenLocal()
}
jar {
manifest {
attributes('Automatic-Module-Name': 'org.dataloader',
'-exportcontents': 'org.dataloader.*',
'-removeheaders': 'Private-Package')
}
bnd('''
Import-Package: org.jspecify.annotations;resolution:=optional,*
''')
}
dependencies {
api "org.reactivestreams:reactive-streams:$reactive_streams_version"
api "org.jspecify:jspecify:1.0.0"
// this is needed for the idea jmh plugin to work correctly
jmh 'org.openjdk.jmh:jmh-core:1.37'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
errorprone 'com.uber.nullaway:nullaway:0.12.10'
errorprone 'com.google.errorprone:error_prone_core:2.42.0'
// just tests
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
tasks.withType(JavaCompile) {
options.release = 11
options.errorprone {
disableAllChecks = true
check("NullAway", CheckSeverity.ERROR)
//
// end state has us with this config turned on - eg all classes
//
//option("NullAway:AnnotatedPackages", "org.dataloader")
option("NullAway:OnlyNullMarked", "true")
option("NullAway:JSpecifyMode", "true")
}
// Include to disable NullAway on test code
if (name.toLowerCase().contains("test")) {
options.errorprone {
disable("NullAway")
}
}
}
task sourcesJar(type: Jar) {
dependsOn classes
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
javadoc {
options.encoding = 'UTF-8'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
testing {
suites {
test {
useJUnitJupiter(junit_version)
dependencies {
// Testing dependencies
implementation platform("org.junit:junit-bom:$junit_version")
implementation 'org.junit.jupiter:junit-jupiter-api'
implementation 'org.junit.jupiter:junit-jupiter-params'
implementation 'org.junit.jupiter:junit-jupiter-engine'
implementation "org.awaitility:awaitility:$awaitility_version"
implementation "org.hamcrest:hamcrest:$hamcrest_version"
implementation "io.projectreactor:reactor-core:$reactor_core_version"
implementation "com.github.ben-manes.caffeine:caffeine:$caffeine_version"
}
targets.configureEach {
testTask.configure {
testLogging {
exceptionFormat = 'full'
}
}
}
}
}
}
publishing {
publications {
graphqlJava(MavenPublication) {
from components.java
groupId 'com.graphql-java'
artifactId 'java-dataloader'
version project.version
artifact sourcesJar
artifact javadocJar
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'java-dataloader'
description 'A pure Java 11 port of Facebook Dataloader'
url 'https://github.com/graphql-java/java-dataloader'
inceptionYear '2017'
scm {
url 'https://github.com/graphql-java/java-dataloader'
connection 'scm:git@github.com:graphql-java/java-dataloader.git'
developerConnection 'scm:git@github.com:graphql-java/java-dataloader.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'bbakerman'
name 'Brad Baker'
email 'bbakerman@gmail.com'
}
developer {
id 'aschrijver'
name 'Arnold Schrijver'
}
}
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
username = System.env.MAVEN_CENTRAL_USER_NEW
password = System.env.MAVEN_CENTRAL_PASSWORD_NEW
// https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
// GraphQL Java does not publish snapshots, but adding this URL for completeness
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) }
}
}
signing {
required { !project.hasProperty('publishToMavenLocal') }
def signingKey = System.env.MAVEN_CENTRAL_PGP_KEY
useInMemoryPgpKeys(signingKey, "")
sign publishing.publications
}
// all publish tasks depend on the build task
tasks.withType(PublishToMavenRepository) {
dependsOn build
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
// https://github.com/ben-manes/gradle-versions-plugin
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}