15
15
* limitations under the License.
16
16
*/
17
17
18
- import org.apache.lucene.gradle.ProfileResults ;
19
-
20
18
def recordings = files()
21
19
22
20
allprojects {
23
21
plugins. withType(JavaPlugin ) {
24
22
ext {
25
23
testOptions + = [
26
- [propName : ' tests.profile' , value : false , description : " Enable java flight recorder profiling." ]
24
+ [propName : ' tests.profile' , value : false , description : " Enable Java Flight Recorder profiling." ]
27
25
]
28
26
}
29
27
30
28
if (resolvedTestOption(" tests.profile" ). toBoolean()) {
31
- allprojects {
29
+ if (rootProject . hasJavaFlightRecorder) {
32
30
tasks. withType(Test ) {
33
31
jvmArgs(" -XX:StartFlightRecording=dumponexit=true,maxsize=250M,settings=" + rootProject. file(" gradle/testing/profiling.jfc" ),
34
32
" -XX:+UnlockDiagnosticVMOptions" ,
@@ -41,17 +39,20 @@ allprojects {
41
39
recordings = recordings. plus fileTree(dir : workingDir, include : ' *.jfr' )
42
40
}
43
41
}
42
+ } else {
43
+ throw new GradleException (' Module jdk.jfr is not available; Java Flight Recorder profiles cannot be enabled.' )
44
44
}
45
45
}
46
46
}
47
47
}
48
48
49
49
gradle. buildFinished {
50
50
if (! recordings. isEmpty()) {
51
- ProfileResults . printReport(recordings. getFiles(). collect { it. toString() },
52
- propertyOrDefault(ProfileResults . MODE_KEY , ProfileResults . MODE_DEFAULT ) as String ,
53
- Integer . parseInt(propertyOrDefault(ProfileResults . STACKSIZE_KEY , ProfileResults . STACKSIZE_DEFAULT )),
54
- Integer . parseInt(propertyOrDefault(ProfileResults . COUNT_KEY , ProfileResults . COUNT_DEFAULT )),
55
- Boolean . parseBoolean(propertyOrDefault(ProfileResults . LINENUMBERS_KEY , ProfileResults . LINENUMBERS_DEFAULT )))
51
+ def pr = org.apache.lucene.gradle.ProfileResults ;
52
+ pr. printReport(recordings. getFiles(). collect { it. toString() },
53
+ propertyOrDefault(pr. MODE_KEY , pr. MODE_DEFAULT ) as String ,
54
+ Integer . parseInt(propertyOrDefault(pr. STACKSIZE_KEY , pr. STACKSIZE_DEFAULT )),
55
+ Integer . parseInt(propertyOrDefault(pr. COUNT_KEY , pr. COUNT_DEFAULT )),
56
+ Boolean . parseBoolean(propertyOrDefault(pr. LINENUMBERS_KEY , pr. LINENUMBERS_DEFAULT )))
56
57
}
57
58
}
0 commit comments