forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
277 lines (236 loc) · 8.49 KB
/
build.gradle
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import java.text.SimpleDateFormat
plugins {
id "com.jfrog.bintray" version "1.8.4"
id 'java'
id 'java-library'
id 'maven'
id 'maven-publish'
id 'antlr'
id "com.github.johnrengelman.shadow" version "6.1.0"
// id 'osgi' doesn't work anymore for gradle 6.6
}
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 = new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash
println "created development version: $version"
version
}
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
def msg = String.format("This build must be run with java 1.8 - you are running %s - gradle finds the JDK via JAVA_HOME=%s",
JavaVersion.current(), System.getenv("JAVA_HOME"))
throw new GradleException(msg)
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
def reactiveStreamsVersion = '1.0.2'
def slf4jVersion = '1.7.30'
def releaseVersion = System.env.RELEASE_VERSION
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
group = 'com.graphql-java'
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'groovy'
jar {
from "LICENSE.md"
from "src/main/antlr/Graphql.g4"
from "src/main/antlr/GraphqlOperation.g4"
from "src/main/antlr/GraphqlSDL.g4"
from "src/main/antlr/GraphqlCommon.g4"
manifest {
attributes('Automatic-Module-Name': 'com.graphql-java')
}
}
dependencies {
implementation 'org.antlr:antlr4-runtime:4.8'
implementation 'org.slf4j:slf4j-api:' + slf4jVersion
api 'com.graphql-java:java-dataloader:2.2.3'
api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion
antlr "org.antlr:antlr4:4.8"
implementation 'com.google.guava:guava:30.0-jre'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'
testImplementation 'org.codehaus.groovy:groovy-all:2.5.13'
testImplementation 'cglib:cglib-nodep:3.3.0'
testImplementation 'org.objenesis:objenesis:2.1'
testImplementation 'com.google.code.gson:gson:2.8.0'
testImplementation 'org.eclipse.jetty:jetty-server:9.4.26.v20200117'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.2'
testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion
testImplementation 'org.awaitility:awaitility-groovy:3.0.0'
testImplementation 'com.github.javafaker:javafaker:0.13'
testImplementation 'org.reactivestreams:reactive-streams-tck:' + reactiveStreamsVersion
testImplementation "io.reactivex.rxjava2:rxjava:2.1.5"
testImplementation 'org.testng:testng:6.1.1' // use for reactive streams test inheritance
testImplementation 'org.openjdk.jmh:jmh-core:1.21'
testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.21'
}
shadowJar {
minimize()
archiveClassifier.set('')
configurations = [project.configurations.compileClasspath]
relocate('com.google.common', 'graphql.com.google.common') {
include 'com.google.common.collect.*'
include 'com.google.common.base.*'
include 'com.google.common.math.*'
include 'com.google.common.primitives.*'
}
dependencies {
include(dependency('com.google.guava:guava:30.0-jre'))
}
from "LICENSE.md"
from "src/main/antlr/Graphql.g4"
from "src/main/antlr/GraphqlOperation.g4"
from "src/main/antlr/GraphqlSDL.g4"
from "src/main/antlr/GraphqlCommon.g4"
manifest {
attributes('Automatic-Module-Name': 'com.graphqljava')
}
}
task removeNotNeededGuava(type: Zip) {
from({ zipTree({"build/libs/graphql-java-${project.version}.jar"})}) {
exclude('/com/**')
}
archiveFileName = "graphql-java-tmp.jar"
destinationDirectory = file("${project.buildDir}/libs")
doLast {
delete("build/libs/graphql-java-${project.version}.jar")
file("build/libs/graphql-java-tmp.jar").renameTo(file("build/libs/graphql-java-${project.version}.jar"))
}
}
shadowJar.finalizedBy removeNotNeededGuava
task testng(type: Test) {
useTestNG()
}
check.dependsOn testng
compileJava.source file("build/generated-src"), sourceSets.main.java
generateGrammarSource {
includes = ['Graphql.g4']
maxHeapSize = "64m"
arguments += ["-visitor"]
outputDirectory = file("${project.buildDir}/generated-src/antlr/main/graphql/parser/antlr")
}
generateGrammarSource.inputs.dir('src/main/antlr')
task sourcesJar(type: Jar) {
dependsOn classes
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
options.encoding = 'UTF-8'
}
artifacts {
archives sourcesJar
archives javadocJar
}
test {
testLogging {
exceptionFormat = 'full'
}
}
allprojects {
tasks.withType(Javadoc) {
exclude('**/antlr/**')
}
}
publishing {
publications {
graphqlJava(MavenPublication) {
version version
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
pom.withXml {
// The ANTLR-related code below--introduced in `1ac98bf`--addresses an issue with
// the Gradle ANTLR plugin. `1ac98bf` can be reverted and this comment removed once
// that issue is fixed and Gradle upgraded. See https://goo.gl/L92KiF and https://goo.gl/FY0PVR.
//
// We are removing here guava because the classes we want to use is "shaded" into the jar itself
// via the shadowJar task
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.artifactId.text() == 'antlr4' || it.artifactId.text() == 'guava'
}.each() {
it.parent().remove(it)
}
pomNode.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'graphql-java'
description 'GraphqL Java'
url "https://github.com/graphql-java/graphql-java"
scm {
url "https://github.com/graphql-java/graphql-java"
connection "https://github.com/graphql-java/graphql-java"
developerConnection "https://github.com/graphql-java/graphql-java"
}
licenses {
license {
name 'MIT'
url 'https://github.com/graphql-java/graphql-java/blob/master/LICENSE.md'
distribution 'repo'
}
}
developers {
developer {
id 'andimarek'
name 'Andreas Marek'
}
}
}
}
}
}
}
bintray {
user = System.env.BINTRAY_USER ?: project["bintray.user"]
key = System.env.BINTRAY_API_KEY ?: project["bintray.key"]
publications = ['graphqlJava']
publish = true
pkg {
repo = 'graphql-java'
name = 'graphql-java'
desc = 'GraphQL in Java'
licenses = ['MIT']
vcsUrl = 'https://github.com/graphql-java/graphql-java'
version {
name = project.version
desc = project.description
released = new Date()
vcsTag = 'v' + project.version
gpg {
sign = true
}
mavenCentralSync {
sync = true
user = System.env.MAVEN_CENTRAL_USER
password = System.env.MAVEN_CENTRAL_PASSWORD
close = '1'
}
}
}
}
// all publish tasks depend on the build task
tasks.withType(PublishToMavenRepository) {
dependsOn build
}
task myWrapper(type: Wrapper) {
gradleVersion = '6.6.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}