forked from mozilla/rhino
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
515 lines (452 loc) · 16.1 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'distribution'
id 'checkstyle'
id 'com.diffplug.spotless' version "5.12.1"
id 'com.github.spotbugs' version "4.7.1"
}
tasks.withType(JavaCompile) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = "UTF-8"
options.compilerArgs = [ "-Xlint:deprecation,unchecked" ]
}
compileTestJava {
options.compilerArgs = [ ]
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDirs 'src', 'toolsrc', 'xmlimplsrc'
}
resources {
srcDirs 'src', 'toolsrc'
exclude "build.xml"
exclude "manifest"
}
}
test {
java {
srcDirs "testsrc", 'examples'
exclude 'tests/**'
}
resources {
srcDirs "testsrc"
}
}
jmh {
java {
srcDirs "benchmarks"
}
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}
}
dependencies {
testImplementation "junit:junit:4.13.2"
testImplementation "org.yaml:snakeyaml:1.28"
testImplementation "javax.xml.soap:javax.xml.soap-api:1.4.0"
jmhImplementation project
jmhImplementation 'org.openjdk.jmh:jmh-core:1.27'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.27'
}
test {
useJUnit()
exclude "**/benchmarks/**"
jvmArgs += '-Xss1280k'
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
jvmArgs += ['--add-opens', 'java.desktop/javax.swing.table=ALL-UNNAMED']
}
jacoco.excludes = ['**/testsrc_tests_ecma_3_RegExp_perlstress*']
systemProperty 'java.awt.headless', 'true'
systemProperty 'mozilla.js.tests', 'testsrc/tests'
systemProperty 'mozilla.js.tests.timeout', 60000
systemProperty 'user.language', 'en'
systemProperty 'user.country', 'US'
systemProperty 'user.timezone', 'America/Los_Angeles'
systemProperty 'file.encoding', 'UTF-8'
if (System.getProperty('quick') != null) {
systemProperty 'TEST_OPTLEVEL', -1
} else if (System.getProperty('optLevel')) {
systemProperty 'TEST_OPTLEVEL', System.getProperty('optLevel')
}
systemProperty 'test262properties', System.getProperty('test262properties')
if (System.getProperty('updateTest262properties') != null) {
systemProperty 'updateTest262properties', System.getProperty('updateTest262properties')
}
maxHeapSize = "1g"
testLogging.showStandardStreams = true
// Many tests do not clean up contexts properly. This makes the tests much
// more resilient at the expense of performance.
forkEvery = 1
maxParallelForks = 64
}
task sunSpiderBenchmark(type: JavaExec) {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-f', '1', '-bm', 'avgt', 'SunSpider'
}
task v8Benchmark(type: JavaExec) {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-f', '1', '-i', '10', '-bm', 'avgt', '-tu', 'us', 'V8'
}
task testBenchmark() {}
testBenchmark.dependsOn sunSpiderBenchmark
testBenchmark.dependsOn v8Benchmark
task microBenchmark(type: JavaExec, description: 'JMH micro benchmark') {
def benchmark = System.getProperty('benchmark')
if (benchmark == null) {
benchmark = "MathBenchmark"
}
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-f', '1', '-bm', 'avgt', '-tu', 'ns', '-r', '5', benchmark
}
task listBenchmarks(type: JavaExec, description: 'JMH benchmarks') {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-lp'
}
task jmhHelp(type: JavaExec, description: 'JMH benchmarks') {
classpath = sourceSets.jmh.runtimeClasspath
mainClass = 'org.openjdk.jmh.Main'
args '-help'
}
idea {
module {
excludeDirs += file('testsrc/tests/src')
excludeDirs += file('buildGradle')
excludeDirs += file('build')
excludeDirs += file('.idea')
excludeDirs += file('lib')
}
}
tasks.withType(AbstractArchiveTask).configureEach {
// Reproducible jar files
preserveFileTimestamps = false
reproducibleFileOrder = true
}
task runtimeJar(type: Jar) {
dependsOn compileJava
archiveBaseName = 'rhino-runtime'
from sourceSets.main.output
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
excludes = ["org/mozilla/javascript/tools", "org/mozilla/javascript/engine/**", "META-INF/services/**"]
manifest {
attributes(
"Manifest-Version": "1.0",
"Implementation-Version": project.version,
"Implementation-Title": "Mozilla Rhino",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Bundle-ManifestVersion": "2",
"Bundle-SymbolicName": "org.mozilla.rhino-runtime",
"Bundle-Version": project.version.replaceAll("-.*", ""),
"Export-Package": "org.mozilla.javascript,org.mozilla.javascript.ast,org.mozilla.javascript.annotations",
"Import-Package": "javax.lang.model,javax.script"
)
}
}
task engineJar(type: Jar) {
dependsOn compileJava
archiveBaseName = 'rhino-engine'
from (sourceSets.main.output) {
include 'org/mozilla/javascript/engine/**'
include 'META-INF/services/**'
}
from ('LICENSE.txt') {
into 'META-INF'
}
manifest {
attributes(
"Manifest-Version": "1.0",
"Implementation-Version": project.version,
"Implementation-Title": "Mozilla Rhino ScriptEngine",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Automatic-Module-Name": "org.mozilla.rhino.engine"
)
}
}
jar {
dependsOn compileJava
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
from ('NOTICE-tools.txt') {
into 'META-INF'
}
from sourceSets.main.output
excludes = ["org/mozilla/javascript/engine/**", "META-INF/services/**"]
// Class ImplementationVersion uses 'Implementation-Title'
manifest {
attributes(
"Manifest-Version": "1.0",
"Main-Class": "org.mozilla.javascript.tools.shell.Main",
"Implementation-Version": project.version,
"Implementation-Title": "Mozilla Rhino",
"Implementation-Vendor": "Mozilla Foundation",
"Implementation-URL": "http://www.mozilla.org/rhino",
"Automatic-Module-Name": "org.mozilla.rhino",
"Bundle-ManifestVersion": "2",
"Bundle-SymbolicName": "org.mozilla.rhino",
"Bundle-Version": project.version.replaceAll("-.*", ""),
"Export-Package": "org.mozilla.javascript,org.mozilla.javascript.ast,org.mozilla.javascript.annotations",
"Import-Package": "javax.lang.model,javax.script"
)
}
}
javadoc {
options.addBooleanOption("-allow-script-in-comments", true)
options.addStringOption('Xdoclint:html', '-quiet')
}
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
}
task runtimeJavadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
exclude 'org/mozilla/javascript/tools', 'org/mozilla/javascript/engine'
}
task engineJavadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
include 'org/mozilla/javascript/engine/**'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
from ('NOTICE-tools.txt') {
into 'META-INF'
}
}
task runtimeSourceJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
exclude 'org/mozilla/javascript/tools', 'org/mozilla/javascript/engine'
from ('LICENSE.txt') {
into 'META-INF'
}
from ('NOTICE.txt') {
into 'META-INF'
}
}
task engineSourceJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
include 'org/mozilla/javascript/engine/**'
from ('LICENSE.txt') {
into 'META-INF'
}
}
publishing {
publications {
rhino(MavenPublication) {
groupId 'org.mozilla'
artifactId 'rhino'
artifacts = [jar, sourceJar, javadocJar]
pom.withXml {
def root = asNode()
root.appendNode('description', """
Rhino is an open-source implementation of JavaScript written entirely in Java.
It is typically embedded into Java applications to provide scripting to end users.
Full jar including tools, excluding the JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
p.appendNode("artifactId", "oss-parent")
p.appendNode("version", "7")
def l = root.appendNode("licenses").appendNode("license")
l.appendNode("name", "Mozilla Public License, Version 2.0")
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt")
def scm = root.appendNode("scm")
scm.appendNode("connection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("developerConnection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("url", "git@github.com:mozilla/rhino.git")
def o = root.appendNode("organization")
o.appendNode("name", "The Mozilla Foundation")
o.appendNode("url", "http://www.mozilla.org")
}
}
rhinoruntime(MavenPublication) {
groupId 'org.mozilla'
artifactId 'rhino-runtime'
artifacts = [runtimeJar, runtimeSourceJar, runtimeJavadocJar]
pom.withXml {
def root = asNode()
root.appendNode('description', """
Rhino JavaScript runtime jar, excludes tools & JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
p.appendNode("artifactId", "oss-parent")
p.appendNode("version", "7")
def l = root.appendNode("licenses").appendNode("license")
l.appendNode("name", "Mozilla Public License, Version 2.0")
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt")
def scm = root.appendNode("scm")
scm.appendNode("connection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("developerConnection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("url", "git@github.com:mozilla/rhino.git")
def o = root.appendNode("organization")
o.appendNode("name", "The Mozilla Foundation")
o.appendNode("url", "http://www.mozilla.org")
}
}
rhinoengine(MavenPublication) {
groupId 'org.mozilla'
artifactId 'rhino-engine'
artifacts = [engineJar, engineSourceJar, engineJavadocJar]
pom.withXml {
def root = asNode()
root.appendNode('description', """
Rhino Javascript JSR-223 Script Engine wrapper.
""")
root.appendNode("url", "https://mozilla.github.io/rhino/")
def p = root.appendNode("parent")
p.appendNode("groupId", "org.sonatype.oss")
p.appendNode("artifactId", "oss-parent")
p.appendNode("version", "7")
def l = root.appendNode("licenses").appendNode("license")
l.appendNode("name", "Mozilla Public License, Version 2.0")
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt")
def scm = root.appendNode("scm")
scm.appendNode("connection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("developerConnection", "scm:git:git@github.com:mozilla/rhino.git")
scm.appendNode("url", "git@github.com:mozilla/rhino.git")
def o = root.appendNode("organization")
o.appendNode("name", "The Mozilla Foundation")
o.appendNode("url", "http://www.mozilla.org")
def deps = root.appendNode("dependencies")
def rhino = deps.appendNode("dependency")
rhino.appendNode("groupId", "org.mozilla")
rhino.appendNode("artifactId", "rhino")
rhino.appendNode("version", getVersion())
}
}
}
if (project.hasProperty("mavenPassword")) {
repositories {
maven {
credentials {
username mavenUser
password mavenPassword
}
if (project.version.endsWith('-SNAPSHOT')) {
url mavenSnapshotRepo
} else {
url mavenReleaseRepo
}
}
}
}
}
signing {
if (project.hasProperty('SIGNINGKEY')) {
// Check for ORG_GRADLE_PROJECT_SIGNINGKEY environment variable for use in CI system.
// Otherwise, do not sign.
def signingKey = getProperty('SIGNINGKEY')
def signingPassword = getProperty('SIGNINGPASSWORD')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.rhino
sign publishing.publications.rhinoengine
sign publishing.publications.rhinoruntime
}
}
spotbugs {
effort = "less"
reportLevel = "medium"
excludeFilter = file("./spotbugs-exclude.xml")
}
spotless {
java {
googleJavaFormat().aosp()
}
}
if (JavaVersion.current() > JavaVersion.VERSION_15
&& (!System.properties.containsKey('org.gradle.jvmargs')
|| !System.properties.get('org.gradle.jvmargs').contains('com.sun.tools.javac.api'))
&& (!project.hasProperty('org.gradle.jvmargs')
|| !project.property('org.gradle.jvmargs').contains('com.sun.tools.javac.api'))) {
tasks.named('check') {
doFirst {
logger.warn('WARNING: spotless plugin removed from check due to bug, ' + \
'see README for a workaround when building with Java 16+.')
}
}
spotless.enforceCheck false
}
jacocoTestReport {
dependsOn test
reports {
csv.required = true
html.required = true
}
}
checkstyle {
configFile = file("${projectDir}/checkstyle.xml")
sourceSets = [ project.sourceSets.main ]
}
distributions {
main {
contents {
from(sourceSets.main.java) {
into 'rhino' + project.version + '/src'
}
from(sourceSets.main.resources) {
exclude '**/*.java'
into 'rhino' + project.version + '/src'
}
from(javadoc.destinationDir) {
into 'rhino' + project.version + '/docs'
}
from(jar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
from(runtimeJar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
from(engineJar.outputs.files) {
into 'rhino' + project.version + '/lib'
}
from(file(".")) {
include '*.txt', '*.md', 'build.gradle', 'gradle.properties',
'gradle/**', 'gradlew', 'man/*.1'
into 'rhino' + project.version
}
into "/"
}
}
}
distTar {
dependsOn javadoc, jar
compression = Compression.GZIP
archiveExtension = 'tar.gz'
}
distZip.dependsOn javadoc, jar, sourceJar, runtimeSourceJar