-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.gradle
231 lines (204 loc) · 7.45 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
import me.champeau.jmh.JmhBytecodeGeneratorTask
import org.ajoberstar.grgit.Grgit
import org.gradle.internal.os.OperatingSystem
import java.time.Duration
plugins {
id 'java'
id 'scala'
id 'me.champeau.jmh' version '0.7.1'
id 'org.ajoberstar.grgit' version '5.2.0'
id 'pl.allegro.tech.build.axion-release' version '1.15.5'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'maven-publish'
id 'signing'
}
scmVersion {
versionCreator('versionWithBranch')
tag {
prefix = ''
}
}
group = 'org.simdjson'
version = scmVersion.version
repositories {
mavenCentral()
}
java {
// It seems that specifying the minimum supported Java version while allowing the use of newer
// ones isn't possible in Gradle. To test the library against multiple Java versions, the
// workaround proposed in https://github.com/gradle/gradle/issues/16256 has been applied:
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_18)) {
toolchain {
languageVersion = JavaLanguageVersion.of(18)
}
}
withJavadocJar()
withSourcesJar()
}
ext {
junitVersion = '5.10.2'
jsoniterScalaVersion = '2.28.4'
}
dependencies {
jmhImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.17.0'
jmhImplementation group: 'com.alibaba.fastjson2', name: 'fastjson2', version: '2.0.49'
jmhImplementation group: 'com.github.plokhotnyuk.jsoniter-scala', name: 'jsoniter-scala-core_2.13', version: jsoniterScalaVersion
jmhImplementation group: 'com.google.guava', name: 'guava', version: '32.1.2-jre'
compileOnly group: 'com.github.plokhotnyuk.jsoniter-scala', name: 'jsoniter-scala-macros_2.13', version: jsoniterScalaVersion
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.24.2'
testImplementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
testImplementation group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.2.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: junitVersion
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
}
tasks.register('downloadTestData') {
doFirst {
def testDataDir = new File("${project.projectDir.getAbsolutePath()}/testdata")
if (!testDataDir.exists()) {
testDataDir.mkdir()
}
def numbersTestDataDir = new File("${testDataDir}/parse-number-fxx-test-data")
if (!numbersTestDataDir.exists()) {
def grgit = Grgit.clone(dir: numbersTestDataDir, uri: 'https://github.com/nigeltao/parse-number-fxx-test-data.git')
grgit.close()
}
}
}
tasks.register('test256', Test) {
dependsOn downloadTestData
useJUnitPlatform()
jvmArgs += [
'--add-modules', 'jdk.incubator.vector',
'-Xmx2g',
'-Dorg.simdjson.species=256'
]
testLogging {
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
}
}
tasks.register('test512', Test) {
dependsOn downloadTestData
useJUnitPlatform()
jvmArgs += [
'--add-modules', 'jdk.incubator.vector',
'-Xmx2g',
'-Dorg.simdjson.species=512'
]
testLogging {
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
}
}
test {
dependsOn 'test256'
dependsOn 'test512'
}
tasks.withType(JmhBytecodeGeneratorTask).configureEach {
jvmArgs.set(["--add-modules=jdk.incubator.vector"])
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add("--add-modules=jdk.incubator.vector")
}
tasks.compileJmhScala.classpath = sourceSets.main.compileClasspath
tasks.compileJmhJava.classpath += files(sourceSets.jmh.scala.classesDirectory)
compileTestJava {
options.compilerArgs += [
'--add-modules', 'jdk.incubator.vector'
]
}
javadoc.options {
addStringOption('-add-modules', 'jdk.incubator.vector')
}
jmh {
fork = 1
warmupIterations = 3
iterations = 5
jvmArgsPrepend = [
'--add-modules=jdk.incubator.vector'
]
if (OperatingSystem.current().isLinux()) {
def profilerList = []
if (getBooleanProperty('jmh.asyncProfilerEnabled', false)) {
createDirIfDoesNotExist('./profilers/async')
profilerList += ['async:verbose=true;output=flamegraph;event=cpu;dir=./profilers/async;libPath=' + getLibPath('LD_LIBRARY_PATH')]
}
if (getBooleanProperty('jmh.perfAsmEnabled', false)) {
createDirIfDoesNotExist('./profilers/perfasm')
profilerList += ['perfasm:intelSyntax=true;saveLog=true;saveLogTo=./profilers/perfasm']
}
if (getBooleanProperty('jmh.perfEnabled', false)) {
profilerList += ['perf']
}
profilers = profilerList
}
if (project.hasProperty('jmh.includes')) {
includes = [project.findProperty('jmh.includes')]
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = project.name
description = 'A Java version of simdjson, a high-performance JSON parser utilizing SIMD instructions.'
url = 'https://github.com/simdjson/simdjson-java'
issueManagement {
system = 'GitHub Issue Tracking'
url = 'https://github.com/simdjson/simdjson-java/issues'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'piotrrzysko'
name = 'Piotr Rżysko'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/simdjson/simdjson-java'
connection = 'scm:[email protected]:simdjson/simdjson-java.git'
developerConnection = 'scm:[email protected]:simdjson/simdjson-java.git'
}
}
}
}
}
if (System.getenv('GPG_KEY_ID')) {
signing {
useInMemoryPgpKeys(
System.getenv('GPG_KEY_ID'),
System.getenv('GPG_PRIVATE_KEY'),
System.getenv('GPG_PRIVATE_KEY_PASSWORD')
)
sign publishing.publications.mavenJava
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri('https://s01.oss.sonatype.org/service/local/')
snapshotRepositoryUrl = uri('https://s01.oss.sonatype.org/content/repositories/snapshots/')
stagingProfileId = '3c0bbfe420699e'
username = System.getenv('SONATYPE_USERNAME')
password = System.getenv('SONATYPE_PASSWORD')
}
}
connectTimeout = Duration.ofMinutes(3)
clientTimeout = Duration.ofMinutes(3)
}
def getBooleanProperty(String name, boolean defaultValue) {
Boolean.valueOf((project.findProperty(name) ?: defaultValue) as String)
}
static def getLibPath(String envVarName) {
System.getenv(envVarName) ?: System.getProperty('java.library.path')
}
static createDirIfDoesNotExist(String dir) {
File file = new File(dir)
file.mkdirs()
}