-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathbuild.gradle
264 lines (241 loc) · 8.32 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
import me.champeau.jmh.JmhBytecodeGeneratorTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'java-library'
id 'org.jetbrains.kotlin.jvm' version '1.8.20'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'com.github.hexomod.macro.preprocessor' version '0.9'
id 'me.champeau.jmh' version '0.7.0' apply false
id 'checkstyle'
id 'org.ajoberstar.grgit' version '5.2.2'
}
repositories {
mavenCentral()
}
if (!hasProperty('buildProfile')) {
ext.buildProfile = 'default'
}
if (buildProfile == 'experimental') {
apply plugin: 'me.champeau.jmh'
}
group 'org.joml'
version '1.10.9-SNAPSHOT'
configurations {
buildhelper
}
dependencies {
buildhelper 'org.ow2.asm:asm:9.7'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.3'
compileOnly 'org.jetbrains:annotations:24.1.0'
if (buildProfile == 'default') {
compileOnly files('libs/jre-stubs.jar')
}
}
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = buildProfile == 'experimental' ? JavaVersion.current() : JavaVersion.VERSION_1_8
targetCompatibility = buildProfile == 'experimental' ? JavaVersion.current() : JavaVersion.VERSION_1_8
}
kotlin {
explicitApi()
}
tasks.withType(KotlinCompile) {
kotlinOptions {
jvmTarget = buildProfile == 'experimental' ? JavaVersion.current().toString() : "1.8"
}
}
test {
useJUnitPlatform()
}
tasks.register('compileBuildHelper', JavaCompile) {
source = fileTree(dir: 'buildhelper', include: '*.java')
classpath = files(configurations.buildhelper)
destinationDirectory.set(file('build/buildhelper'))
}
tasks.register('java6to2', JavaExec) {
dependsOn compileBuildHelper
group = "Execution"
description = "Run the Java 6 to 2 conversion"
classpath = files(configurations.buildhelper, 'build/buildhelper')
mainClass.set('Java6to2')
args('build/classes/java/main')
}
tasks.register('moduleInfoGenerator', JavaExec) {
dependsOn compileBuildHelper
group = "Execution"
description = "Run module-info.class generator"
classpath = files(configurations.buildhelper, 'build/buildhelper')
mainClass.set('ModuleInfoGenerator')
args('build/classes/java/main', version)
}
if (buildProfile == 'default') {
compileJava.finalizedBy(java6to2, moduleInfoGenerator)
}
jar {
manifest {
attributes(
'Created-By': 'Gradle',
'Implementation-Title': 'JOML',
'Implementation-Version': version,
'Implementation-Vendor': 'JOML',
'Bundle-ManifestVersion': '2',
'Bundle-Name': 'JOML',
'Bundle-SymbolicName': 'org.joml',
'Bundle-Version': version,
'Export-Package': 'org.joml,org.joml.sampling',
'Implementation-Build': grgit.head().id,
)
}
}
nexusPublishing {
repositories {
sonatype()
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = buildProfile == 'experimental' ? 'joml-experimental' : 'joml'
from components.java
pom {
name = 'JOML'
description = 'Java OpenGL Math Library'
url = 'http://joml.org'
licenses {
license {
name = 'MIT License'
url = 'https://www.opensource.org/licenses/mit-license.php'
}
}
organization {
name = 'JOML'
url = 'http://joml.org'
}
developers {
developer {
id = 'kburjack'
name = 'Kai Burjack'
}
}
scm {
url = 'https://github.com/JOML-CI/JOML'
connection = 'scm:git:https://github.com/JOML-CI/JOML.git'
developerConnection = 'scm:git:https://github.com/JOML-CI/JOML.git'
}
}
// Exclude the dependency on the Kotlin Stdlib for Java
// introduced by the Kotlin plugin.
pom.withXml {
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.artifactId.text() == 'kotlin-stdlib-jdk8'
}.each() {
it.parent().remove(it)
}
}
}
}
}
if (project.hasProperty("sign")) {
signing {
def signingKey = findProperty("signingKey") as String
def signingPassword = findProperty("signingPassword") as String
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}
checkstyle {
configDirectory.set(file('config'))
}
checkstyleMain {
exclude '**/module-info.java'
}
ext.PREPROCESSOR_DEFINES = [
__HAS_NIO__ : "1",
__HAS_UNSAFE__: '1',
]
if (buildProfile == 'experimental') {
ext.PREPROCESSOR_DEFINES += [
__HAS_JVMCI__ : '1',
]
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
ext.PREPROCESSOR_DEFINES += [
__HAS_VECTOR_API__: '1',
]
}
if (JavaVersion.current() >= JavaVersion.VERSION_19) {
ext.PREPROCESSOR_DEFINES += [
__HAS_FOREIGN_MEMORY_ACCESS_API__: '1',
]
}
test {
doFirst {
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
jvmArgs += [
'--add-modules', 'jdk.incubator.vector',
'-Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK=0',
]
}
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
jvmArgs += [
'-XX:+UnlockExperimentalVMOptions',
'-XX:+EnableJVMCI',
'--enable-preview',
'--add-modules', 'jdk.internal.vm.ci',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED',
]
}
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
'--enable-preview',
'--add-modules', 'jdk.internal.vm.ci,jdk.incubator.vector',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED',
]
}
tasks.withType(JmhBytecodeGeneratorTask).configureEach {
jvmArgs.set([
'--enable-preview',
'--add-modules', 'jdk.internal.vm.ci,jdk.incubator.vector',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED',
'--add-exports', 'jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED',
])
}
javadoc {
enabled = false
}
}
macroPreprocessorSettings {
inPlace = false
remove = false
java {
enable = true
inPlace = false
remove = false
}
resources {
enable = false
inPlace = false
remove = false
}
vars = PREPROCESSOR_DEFINES
}
tasks.named("sourcesJar").configure { dependsOn("macroPreprocessorJava") }