forked from randoop/randoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
1171 lines (1037 loc) · 35.8 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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* build.gradle for Randoop
*
* Quick instructions: in project directory run with command
* ./gradlew build
*/
plugins {
id 'com.gradleup.shadow' version '8.3.5'
id 'java'
id 'eclipse'
id 'idea'
id 'jacoco'
// Requires Java 11 or later
id 'com.diffplug.spotless' version '6.25.0' apply false
id('net.ltgt.errorprone') version '4.1.0'
id 'org.checkerframework' version '0.6.46'
id 'org.aim42.htmlSanityCheck' version '1.1.6'
// run: ./gradlew <taskname> taskTree
id 'com.dorongold.task-tree' version '4.0.0'
// https://github.com/n0mer/gradle-git-properties ; target is: generateGitProperties
id 'com.gorylenko.gradle-git-properties' version '2.4.2'
}
/* Common build configuration for Randoop and agents */
allprojects {
apply plugin: 'java'
apply plugin: 'com.gradleup.shadow'
apply plugin: 'net.ltgt.errorprone'
java {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
repositories {
mavenCentral()
mavenLocal()
}
group 'com.github.randoop'
/* Randoop version number - added to generated jar files */
version = '4.3.3'
configurations {
// A collection of all plumelib dependencies required, so that all
// sub-projects use the same versions.
plumelib
}
dependencies {
// To use a local version: plumelib files("${rootDir}/libs/bcel-util-all.jar")
// https://mvnrepository.com/artifact/org.plumelib/bcel-util
// Temporarily use 1.2.1 because 1.2.2 is buggy in that it uses Java 11 bytecodes (classfile version 55.0).
plumelib 'org.plumelib:bcel-util:1.2.1'
// https://mvnrepository.com/artifact/org.plumelib/options
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
plumelib 'org.plumelib:options:2.0.3'
} else {
plumelib 'org.plumelib:options:2.0.3'
}
// https://mvnrepository.com/artifact/org.plumelib/plume-util
plumelib 'org.plumelib:plume-util:1.10.0'
// https://mvnrepository.com/artifact/org.plumelib/reflection-util
plumelib 'org.plumelib:reflection-util:1.1.4'
}
java {
withJavadocJar()
withSourcesJar()
}
}
allprojects { subproject ->
apply plugin: 'org.checkerframework'
checkerFramework {
excludeTests = true
checkers = [
// 'org.checkerframework.checker.nullness.NullnessChecker',
'org.checkerframework.checker.resourceleak.ResourceLeakChecker',
'org.checkerframework.checker.signedness.SignednessChecker',
'org.checkerframework.checker.signature.SignatureChecker',
]
extraJavacArgs = [
// Uncomment -proc:none to disable all annotation processing and speed up the build.
// '-proc:none',
'-Werror',
// '-AcheckPurityAnnotations',
'-ArequirePrefixInWarningSuppressions',
'-AwarnUnneededSuppressions',
'-AwarnRedundantAnnotations',
'-ApermitStaticOwning',
// -processing: suppresses "No processor claimed any of these annotations ..."
// -options: suppresses "target value 8 is obsolete and will be removed in a future release"
'-Xlint:-processing,-options'
]
}
dependencies {
if (project.hasProperty('cfLocal')) {
def cfHome = String.valueOf(System.getenv('CHECKERFRAMEWORK'))
compileOnly files(cfHome + '/checker/dist/checker-qual.jar')
testCompileOnly files(cfHome + '/checker/dist/checker-qual.jar')
checkerFramework files(cfHome + '/checker/dist/checker.jar')
}
}
}
import org.apache.tools.ant.taskdefs.condition.Os
/******
* Configuration specific to Randoop and not agents.
* Configuration for agent FOO appears in agents/FOO/FOO.gradle .
******/
description = 'Randoop automated test generation'
/* Root for working directories for system test generated files */
def workingDirectories = "$buildDir/working-directories"
sourceSets {
/* JUnit tests that must be run with -javaagent */
/* JUnit tests are run in nondeterministic order, but system tests are
run in deterministic order. */
coveredTest
replacecallTest
/* system tests */
systemTest {
resources {
srcDir 'src/testInput/resources'
}
output.dir(workingDirectories, builtBy: 'generateWorkingDirs')
}
/* Code sets used by system tests. There are no actual tests here. */
testInput
test {
resources {
srcDir 'src/testInput/resources'
}
}
}
configurations {
/*
* Used to manage javaagent jar file
*/
jacocoagent
junit
/*
* The agent tests are JUnit tests run with the covered-class-agent, so
* borrow from unit test configurations.
*/
coveredTestImplementation.extendsFrom testImplementation
coveredTestRuntimeOnly.extendsFrom testRuntimeOnly
replacecallTestImplementation.extendsFrom testImplementation
replacecallTestRuntimeOnly.extendsFrom testRuntimeOnly
implementation.extendsFrom(plumelib)
implementation.extendsFrom(junit)
systemTestImplementation.extendsFrom(plumelib)
systemTestImplementation.extendsFrom(junit)
}
ext {
versions = [
checkerFramework : '3.48.2',
commonsExec : '1.4.0',
commonsIo : '2.8.0.1',
errorProne : '2.35.1',
hamcrestAll :'1.3',
jacoco: '0.8.12',
]
isJava17orHigher = JavaVersion.current() >= JavaVersion.VERSION_17
isJava21orHigher = JavaVersion.current() >= JavaVersion.VERSION_21
}
dependencies {
junit 'junit:junit:4.+'
implementation files(project(':replacecall').sourceSets.main.output)
implementation 'com.github.javaparser:javaparser-core:3.26.2'
implementation 'com.google.code.gson:gson:2.11.0'
implementation "org.apache.commons:commons-exec:${versions.commonsExec}"
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation "org.checkerframework.annotatedlib:commons-io:${versions.commonsIo}"
compileOnly "org.checkerframework:checker-qual:${versions.checkerFramework}"
implementation "org.checkerframework:checker-qual:${versions.checkerFramework}"
checkerFramework "org.checkerframework:checker:${versions.checkerFramework}"
/* Jacoco measures coverage of classes and methods under test. */
implementation "org.jacoco:org.jacoco.core:${versions.jacoco}"
implementation group: 'org.jacoco', name: 'org.jacoco.agent', version: "${versions.jacoco}", classifier: 'runtime'
/* sourceSet test uses JUnit and some use testInput source set */
testImplementation 'commons-codec:commons-codec:1.17.1'
testImplementation "org.hamcrest:hamcrest-all:${versions.hamcrestAll}"
testImplementation configurations.junit.dependencies
testImplementation sourceSets.testInput.output
/*
* sourceSet coveredTest uses output from main sourceSet, and agent projects.
* (Also, see configuration block.)
*/
coveredTestImplementation sourceSets.main.output
coveredTestImplementation sourceSets.test.output
coveredTestRuntimeOnly project(':covered-class')
replacecallTestImplementation files(project(':replacecall').sourceSets.main.output)
jacocoagent "org.jacoco:org.jacoco.agent:${versions.jacoco}"
/*
* source set systemTest
*/
systemTestImplementation "org.checkerframework:checker-qual:${versions.checkerFramework}"
systemTestImplementation "org.jacoco:org.jacoco.core:${versions.jacoco}"
systemTestImplementation "org.jacoco:org.jacoco.report:${versions.jacoco}"
systemTestImplementation "org.apache.commons:commons-exec:${versions.commonsExec}"
systemTestImplementation "org.checkerframework.annotatedlib:commons-io:${versions.commonsIo}"
systemTestImplementation "org.hamcrest:hamcrest-all:${versions.hamcrestAll}"
systemTestRuntimeOnly sourceSets.testInput.output
/*
* sourceSet testInput depends on output of main.
* Also, src/testInput/java/ps1/RatPolyTest.java uses JUnit
*/
testInputImplementation sourceSets.main.output
testInputImplementation configurations.junit.dependencies
testInputCompileOnly "org.checkerframework:checker-qual:${versions.checkerFramework}"
errorprone "com.google.errorprone:error_prone_core:${versions.errorProne}"
}
/*
* Configuration for compilation.
*/
compileJava.options.compilerArgs = [
'-g',
'-Werror',
'-Xlint',
'-Xlint:-classfile,-options'
]
compileTestJava.options.compilerArgs = [
'-g',
'-Werror',
'-Xlint',
'-Xlint:-classfile,-options'
]
compileCoveredTestJava.options.compilerArgs = [
'-g',
'-Werror',
'-Xlint',
'-Xlint:-classfile,-options'
]
compileReplacecallTestJava.options.compilerArgs = [
'-g',
'-Werror',
'-Xlint',
'-Xlint:-classfile,-options'
]
compileSystemTestJava.options.compilerArgs = [
'-g',
'-Werror',
'-Xlint',
'-Xlint:-classfile,-options'
]
compileTestInputJava.options.compilerArgs = [
'-g',
'-nowarn',
'-Xlint:-classfile,-options'
]
task compileAll() {
dependsOn compileJava
dependsOn compileTestJava
dependsOn ':covered-class:compileJava'
dependsOn ':covered-class:compileTestJava'
dependsOn ':replacecall:compileJava'
dependsOn ':covered-class:compileTestJava'
dependsOn compileCoveredTestJava
dependsOn compileReplacecallTestJava
dependsOn compileSystemTestJava
}
// Get early notification of compilation failures.
assemble.dependsOn compileAll
// This isn't working; maybe I need to make compileAll run first.
// Get early notification of any compilation failures, before running any tests
build.dependsOn compileAll
ext.isJava11orHigher = JavaVersion.current() >= JavaVersion.VERSION_11
if (isJava11orHigher) {
apply plugin: 'com.diffplug.spotless'
spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
java {
// Use fileTree per https://github.com/diffplug/spotless/issues/399
targetExclude(fileTree("$projectDir/src/testInput") { include('**/*.java') })
googleJavaFormat()
formatAnnotations()
}
groovyGradle {
target '**/*.gradle'
greclipse() // which formatter Spotless should use to format .gradle files.
indentWithSpaces(2)
trimTrailingWhitespace()
// endWithNewline() // Don't want to end empty files with a newline
}
}
}
// Error Prone linter
allprojects {
dependencies {
errorprone("com.google.errorprone:error_prone_core:${versions.errorProne}")
}
}
allprojects { subproject ->
tasks.withType(JavaCompile).configureEach { t ->
if (t.name.equals('compileTestInputJava') || t.name.equals('compileTestJava')) {
options.errorprone.enabled = false
} else {
// options.compilerArgs << '-Xlint:all,-processing' << '-Werror'
options.errorprone {
enabled = JavaVersion.current() != JavaVersion.VERSION_1_8
// TODO: uncomment once we run the Interning Checker on Randoop.
// disable('ReferenceEquality') // Use Interning Checker instead.
disable('StringSplitter') // Obscure case isn't likely.
disable('AnnotateFormatMethod') // Error Prone doesn't use Checker Framework @FormatMethod.
excludedPaths = '.*/testInput/.*'
}
options.errorprone.enabled = isJava17orHigher
}
}
}
/*
* Configuration for clean
*/
clean.dependsOn ':replacecall:clean'
clean.dependsOn ':covered-class:clean'
/*
* Configuration for testing.
* In terms of build, we have two kinds of tests, both using JUnit.
* * Those in src/coveredTest require the covered-class Java agent.
* * Those in src/test are run without the agent.
* This second group includes tests that run the full Randoop over
* classes that (mostly) are located in src/testInput.
*/
/*
* Configuration of test task from Java plugin.
* Runs all tests in test sourceSet except those excluded below.
*/
test {
/*
* Set the working directory for JUnit tests to the resources directory
* instead of the project directory.
*/
workingDir = file("$buildDir/resources")
/*
* Show as much as possible to console.
*/
testLogging {
events 'started', 'passed'
showStandardStreams = true
exceptionFormat = 'full'
}
/* Turn off HTML reports -- handled by testReport task */
reports.html.required = false
/*
* Temporary exclusion b/c script file uses generics as raw types and conflicts with
* other uses of parsing.
*/
exclude '**/randoop/test/SequenceTests.*'
/*
* Temporary exclusion b/c incomplete.
*/
exclude '**/randoop/output/JUnitCreatorTest.*'
/*
* Problematic tests excluded during Gradle setup that need to be evaluated.
* Unless otherwise noted, these are tests that were not previously run by
* Makefile. However, some included tests were also not run, but are not
* failing.
*/
exclude 'randoop/test/NonterminatingInputTest.*'
exclude 'randoop/test/EmptyTest.*'
exclude 'randoop/test/RandoopPerformanceTest.*' /* had target but not run */
exclude 'randoop/test/ForwardExplorerPerformanceTest.*'
exclude 'randoop/test/ForwardExplorerTests2.*' /* sporadic heap space issue */
exclude 'randoop/test/Test_SomeDuplicates.*'
exclude 'randoop/test/Test_SomePass.*'
exclude 'randoop/operation/OperationParserTests.*'
}
task coveredTest(type: Test, dependsOn: [
shadowJar,
'copyJars',
'compileTestJava'
]) {
description 'Run covered-class tests'
/*
* Set the working directory for JUnit tests to the resources directory
* instead of the project directory.
*/
workingDir = sourceSets.coveredTest.output.resourcesDir
testClassesDirs = sourceSets.coveredTest.output.classesDirs
classpath = sourceSets.coveredTest.runtimeClasspath
jvmArgs "-javaagent:$buildDir/libs/covered-class-${version}.jar"
/*
* Show as much as possible to console.
*/
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
/* Turn off HTML reports -- handled by testReport task */
reports.html.required = false
}
/*
* Link the coveredTest task into project check task. Includes agent tests into
* the project build task.
*/
check.dependsOn coveredTest
task replacecallTest(type: Test, dependsOn: 'copyJars') {
description 'Run replace-call tests'
workingDir = sourceSets.replacecallTest.output.resourcesDir
testClassesDirs = sourceSets.replacecallTest.output.classesDirs
classpath = sourceSets.replacecallTest.runtimeClasspath + files("$buildDir/libs/replacecall-${version}.jar")
// use the replacecall agent using the exclusions file from replacecallTest/resources
jvmArgs "-javaagent:$buildDir/libs/replacecall-${version}.jar=--dont-transform=replacecall-exclusions.txt"
jvmArgs "-Xbootclasspath/a:$buildDir/libs/replacecall-${version}.jar"
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
/* Turn off HTML reports -- handled by testReport task */
reports.html.required = false
}
check.dependsOn replacecallTest
jacoco {
toolVersion = "${versions.jacoco}"
}
jacocoTestReport {
group 'Report'
reports {
xml.required = true
html.required = true
}
}
// Expects these files to exist in build/javcoco/:
// agentTest.exec
// coveredTest.exec
// systemTest.exec
// test.exec
// What is creating the agentTest.exec files, and how do I create it?
// test.exec is the default, though it is also greated by "gradle test".
// jacocoTestReport.dependsOn agentTest
jacocoTestReport.dependsOn coveredTest
jacocoTestReport.dependsOn test
check.dependsOn jacocoTestReport
/*
* Task to build the root directory of working directories used by the
* JUnit tests in the systemTest task.
* If the directory exists then cleans out the contents.
*/
task generateWorkingDirs {
doLast {
def generated = file(workingDirectories)
if (! generated.exists()) {
generated.mkdir()
} else {
def workingFiles = fileTree(workingDirectories) {
include '**/*.java'
include '**/*.class'
include '**/*.exec'
include '**/*.txt'
}
delete workingFiles
}
}
}
/*
* Extracts JaCoCo javaagent into build/jacocoagent
*/
task extractJacocoAgent(type: Copy) {
from {
configurations.jacocoagent.collect { zipTree(it) }
}
into "$buildDir/jacocoagent/"
copy {
from "$buildDir/jacocoagent/jacocoagent.jar"
into "$buildDir/libs"
}
}
/*
* Runs JUnit over all classes in systemTest sourceSet.
* JUnit tests assume that working directories can be found in the build directory.
*/
task systemTest(type: Test, dependsOn: [
'extractJacocoAgent',
'generateWorkingDirs',
'assemble'
]) {
group 'Verification'
description 'Run system tests'
/*
* Set system properties for jar paths, used by randoop.main.SystemTestEnvironment
*/
doFirst {
systemProperty 'jar.randoop', shadowJar.archiveFile.get()
systemProperty 'jar.replacecall.agent', project(':replacecall').shadowJar.archiveFile.get()
systemProperty 'jar.covered.class.agent', project(':covered-class').shadowJar.archiveFile.get()
}
workingDir = file("$buildDir")
testClassesDirs = sourceSets.systemTest.output.classesDirs
classpath = sourceSets.systemTest.runtimeClasspath
/*
* Show as much as possible to console.
*/
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
/* Turn off HTML reports -- handled by testReport task */
reports.html.required = false
}
systemTest.dependsOn shadowJar
/*
* Link the systemTest task into the project check task.
* Includes system tests into the project build task.
*/
check.dependsOn systemTest
jacocoTestReport.dependsOn systemTest
tasks.withType(Test) {
/*
* Set the destination directory for JUnit XML output files
*/
reports.junitXml.outputLocation = file("$buildDir/test-results/${name}")
/*
* Set the heap size and GC for running tests.
*/
jvmArgs '-Xmx3000m'
/*
* Pass along any system properties that begin with "randoop."
* Used by randoop.main.RandoopOptions in systemTest.
*/
System.properties.each { k,v->
if (k.startsWith('randoop.')) {
systemProperty k, v
}
}
}
/*
* Write HTML reports into build/reports/allTests for all tests.
* [
* Note that this may not work correctly if different Test tasks use the same
* test classes. Fine here because sourceSets use different packages for test
* classes.
* ]
*/
task testReport(type: TestReport) {
group 'Report'
description 'Creates HTML reports for tests results'
destinationDirectory = file("$buildDir/reports/allTests")
for (Task t:tasks.withType(Test)){
testResults.from(t.getBinaryResultsDirectory())
}
}
task printJunitJarPath {
description 'Print the path to junit.jar'
doFirst { println configurations.junit.asPath }
}
//****************** Building distribution *****************
/*
* Only want the jar file to include class files from main source set.
* (Task part of build by default.)
*/
jar {
from sourceSets.main.output
}
task copyJars(type: Copy, dependsOn: [
':covered-class:jar',
':replacecall:jar'
]) {
from subprojects.collect { it.tasks.withType(Jar) }
into "$buildDir/libs"
}
assemble.dependsOn copyJars
shadowJar {
// The jar file name is randoop-all-$version.jar
archiveBaseName = 'randoop-all'
archiveClassifier = ''
exclude '**/pom.*'
exclude '**/default-*.txt'
// don't include either mocks or agent classes
// otherwise creates problems for replacement creation of replacecall agent
exclude '**/randoop/mock/*'
exclude '**/randoop/instrument/*'
relocate 'com.github.javaparser', 'randoop.com.github.javaparser'
relocate 'com.google', 'randoop.com.google'
relocate 'com.jcraft.jsch', 'randoop.com.jcraft.jsch'
relocate 'com.sun.javadoc', 'randoop.com.sun.javadoc'
relocate 'com.sun.jna', 'randoop.com.sun.jna'
relocate 'com.trilead.ssh2', 'randoop.com.trilead.ssh2'
relocate 'de.regnis.q.sequence', 'randoop.de.regnis.q.sequence'
relocate 'net.fortuna.ical4j', 'randoop.net.fortuna.ical4j'
relocate 'nu.xom', 'randoop.nu.xom'
relocate 'org.antlr', 'randoop.org.antlr'
relocate 'org.apache', 'randoop.org.apache'
relocate 'org.ccil.cowan.tagsoup', 'randoop.org.ccil.cowan.tagsoup'
relocate 'org.checkerframework', 'randoop.org.checkerframework'
relocate 'org.ini4j', 'randoop.org.ini4j'
relocate 'org.plumelib', 'randoop.org.plumelib'
relocate 'org.slf4j', 'randoop.org.slf4j'
relocate 'org.tigris.subversion', 'randoop.org.tigris.subversion'
relocate 'org.tmatesoft', 'randoop.org.tmatesoft'
}
assemble.dependsOn shadowJar
task distributionZip (type: Zip , dependsOn: [
'shadowJar',
'copyJars',
'manual',
'extractJacocoAgent'
]) {
group 'Publishing'
description 'Assemble a zip file with jar files and user documentation'
def dirName = "${base.archivesBaseName}-${version}"
from 'build/libs/'
from ('src/docs/manual/index.html') {
into 'doc/manual'
}
from ('src/docs/manual/stylesheets') {
into 'doc/manual/stylesheets'
}
from 'src/distribution/resources/README.txt'
into (dirName)
exclude { details ->
details.file.name.contains('randoop') && ! details.file.name.contains('-all-')
}
}
/********************* Building manual *******************/
/*
* The "manual" gradle target creates the contents of the manual directory
* within src/, which will eventually be moved to the gh-pages branch.
*
* Has structure:
* src/
* docs/
* api/ - contains javadoc for main source set
* manual/
* dev.html - developer documentation
* index.html - user documentation
* *example.txt - example configuration files for user manual
* stylesheets/ - contains css file for web pages
*/
/*
* Clone or update repositories containing executable scripts.
*
* Grgit has too many limitations. Use exec instead.
*/
task cloneLibs( dependsOn: [
'cloneChecklink',
'cloneHtmlTools',
'clonePlumeScripts'
]) { }
task cloneChecklink {
doLast {
if ( ! file("$buildDir/utils/checklink").exists() ) {
exec {
commandLine 'git', 'clone', '--depth=1', 'https://github.com/plume-lib/checklink.git', "$buildDir/utils/checklink"
}
} else {
// Ignore exit value so this does not halt the build when not connected to the Internet.
exec {
workingDir "$buildDir/utils/checklink"
ignoreExitValue true
commandLine 'git', 'pull', '-q'
}
}
}
}
task cloneHtmlTools {
doLast {
if ( ! file("$buildDir/utils/html-tools").exists() ) {
exec {
commandLine 'git', 'clone', '--depth=1', 'https://github.com/plume-lib/html-tools.git', "$buildDir/utils/html-tools"
}
} else {
// Ignore exit value so this does not halt the build when not connected to the Internet.
exec {
workingDir "$buildDir/utils/html-tools"
ignoreExitValue true
commandLine 'git', 'pull', '-q'
}
}
}
}
task clonePlumeScripts {
doLast {
if ( ! file("$buildDir/utils/plume-scripts").exists() ) {
exec {
commandLine 'git', 'clone', '--depth=1', 'https://github.com/plume-lib/plume-scripts.git', "$buildDir/utils/plume-scripts"
}
} else {
// Ignore exit value so this does not halt the build when not connected to the Internet.
exec {
workingDir "$buildDir/utils/plume-scripts"
ignoreExitValue true
commandLine 'git', 'pull', '-q'
}
}
}
}
/*
* Set destination directory to build/docs/api, and restrict to classes in
* main sourceSet.
*/
javadoc {
destinationDir = file("${buildDir}/docs/api")
source sourceSets.main.allJava
options.memberLevel = JavadocMemberLevel.PRIVATE
// Use of Javadoc's -linkoffline command-line option makes Javadoc generation
// much faster, especially in CI.
if (JavaVersion.current().isJava11()) {
options.with {
linksOffline 'https://docs.oracle.com/en/java/javase/11/docs/api/', 'https://docs.oracle.com/en/java/javase/11/docs/api/'
}
} else if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
options.with {
linksOffline 'https://docs.oracle.com/en/java/javase/17/docs/api/', 'https://docs.oracle.com/en/java/javase/17/docs/api/'
}
}
// JDK 17 gets lots of 'missing' warnings that JDK 11 did not.
options.addStringOption('Xdoclint:all,-missing', '-quiet')
failOnError = true // does not fail on warnings
doLast {
ant.replaceregexp(match:"@import url\\('resources/fonts/dejavu.css'\\);\\s*", replace:'',
flags:'g', byline:true) {
fileset(dir: destinationDir)
}
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
if (!new File("$projectDir/src/docs/api").exists() ) {
ant.symlink(resource: '../../build/docs/api', link: "$projectDir/src/docs/api")
}
}
}
}
check.dependsOn javadoc
// Make Javadoc fail on most warnings
// From https://stackoverflow.com/a/49544352/173852
//
// This used to be
// tasks.withType(Javadoc) { ... }
// but that passes the options to OptionsDoclet which cannot interpret them.
// How can I apply the options only to Javadoc invocations that use the standard doclet?
javadoc {
options.addStringOption('Xwerror', '-Xdoclint:all,-missing')
}
configurations {
requireJavadoc
}
dependencies {
requireJavadoc 'org.plumelib:require-javadoc:1.0.9'
}
task requireJavadoc(type: JavaExec, group: 'Documentation') {
description = 'Ensures that Javadoc documentation exists.'
mainClass = 'org.plumelib.javadoc.RequireJavadoc'
classpath = configurations.requireJavadoc
args 'agent', 'src/main/java', '--exclude=replacecall/src/main/java/randoop/mock'
}
// This doesn't yet pass. TODO: make it pass.
// check.dependsOn requireJavadoc
// needed for javadoc.doLast
javadoc.dependsOn cloneLibs
javadoc.doLast {
//check if perl is available
boolean isPerlInstalled = true
try {
def process = "perl -version".execute()
process.waitFor()
if (process.exitValue()) {
isPerlInstalled = false
}
} catch (Exception ex) {
isPerlInstalled = false
}
if (isPerlInstalled) {
def preplace = file("$buildDir/utils/plume-scripts/preplace")
// Work around Javadoc bug
exec {
commandLine 'perl', preplace, "<dt><span class=\"memberNameLink\"><a href=\".*\\(\\)</a></span> - Constructor for enum [a-zA-Z0-9_.]*<a href=\".*</a></dt>", '', 'build/docs/api/index-all.html'
}
// Permit validateAPI to pass
exec {
commandLine 'perl', preplace, '^(<meta http-equiv=\"Refresh\" content=\"0;)([^ ])', '\\1 url=\\2', 'build/docs/api/'
}
// Reduce size of diffs (when it's copied over to gh-pages branch whech is under
// version control). Note that build/docs/api/ is the same as src/docs/api/.
exec {
commandLine 'perl', preplace, '^<!-- Generated by javadoc \\(.* -->\$', '', 'build/docs/api/'
}
exec {
commandLine 'perl', preplace, "^<meta name=\"date\" content=\"[-0-9]+\">\$", '', 'build/docs/api/'
}
}
}
build.dependsOn javadoc
/* Update the table-of-contents for the user documentation. */
// No group so it doesn't show up in `./gradlew tasks`
task updateUserTOC( type:Exec, dependsOn: ['cloneLibs']) {
executable file("$buildDir/utils/html-tools/html-update-toc")
args file("${projectDir}/src/docs/manual/index.html")
environment PATH: "$System.env.PATH:$buildDir/utils/html-tools"
}
/* Update table of contents in developer documentation. */
// No group so it doesn't show up in `./gradlew tasks`
task updateDevTOC( type:Exec, dependsOn: ['cloneLibs']) {
executable file("$buildDir/utils/html-tools/html-update-toc")
args file("${projectDir}/src/docs/manual/dev.html")
environment PATH: "$System.env.PATH:$buildDir/utils/html-tools"
}
// No group so it doesn't show up in `./gradlew tasks`
task updateUserOptions(type: Javadoc, dependsOn: 'assemble') {
description 'Updates printed documentation of command-line arguments.'
source = sourceSets.main.allJava.files.sort()
classpath = project.sourceSets.main.compileClasspath
options.memberLevel = JavadocMemberLevel.PRIVATE
options.docletpath = project.sourceSets.main.runtimeClasspath as List
options.doclet = 'org.plumelib.options.OptionsDoclet'
options.addStringOption('docfile', "${projectDir}/src/docs/manual/index.html")
options.addStringOption('i', '-quiet')
// For compatibility with JDK 8 Javadoc, whose standard doclet has no -noTimestamp option
options.noTimestamp = false
title = ''
}
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
updateUserOptions.enabled = false
}
/* Requires that the html5validator program is installed */
task html5validatorExists {
doLast {
def command = 'command -v html5validator'
def stdout = new ByteArrayOutputStream()
def stderr = new ByteArrayOutputStream()
def result = exec {
ignoreExitValue = true
executable 'bash' args '-l', '-c', command
standardOutput = stdout
errorOutput = stderr
}
if (result.getExitValue() != 0) {
println "Command failed: $command";
println "Standard output: $stdout";
println "Standard error: $stderr";
ant.fail('html5validator is not installed. See https://randoop.github.io/randoop/manual/dev.html#prerequisites .')
}
}
}
html5validatorExists.onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
updateUserTOC.onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
updateDevTOC.onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
/*
* Generate/update and move documentation into build/docs directory.
*/
task manual(type: DefaultTask, dependsOn: [
'updateUserOptions',
'updateUserTOC',
'updateDevTOC',
'html5validatorExists'
]) {
group 'Documentation'
description 'Adds options and TOC to documentation in src/docs'
doLast {
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
exec {
environment PATH: "$System.env.PATH"
commandLine "html5validator", '--root', file("${projectDir}/src/docs/manual")
}
}
}
}
// This is cross-platform and pulls in all required dependencies. However,
// it emits false positives and cannot be run in an automated build.
// Output goes in ${buildDir}/reports/htmlSanityCheck/index.html .
htmlSanityCheck {
// sourceDir = new File( "${projectDir}/src/docs/manual" )
sourceDir = new File( "${projectDir}/src/docs" )
sourceDocuments = fileTree(sourceDir) {
include 'index.html', 'projectideas.html', 'publications.html', 'manual/dev.html', 'manual/index.html'
}
failOnErrors = true
}
build.dependsOn manual
/*
* Applies HTML5 validator to API javadoc.
*/
task validateAPI(type: Exec, dependsOn: [
'javadoc',
'html5validatorExists'
]) {
group 'Documentation'
description 'Run html5validator to find HTML errors in API documentation'
// Prior to Java 9, javadoc does not comply with HTML5.
if (JavaVersion.current().isJava9Compatible()) {
environment PATH: "$System.env.PATH"
commandLine 'html5validator', '--root', file("${buildDir}/docs/api")
} else {
commandLine 'echo', 'WARNING: HTML validation of API is only run in Java 9+.'