-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
78 lines (62 loc) · 2.13 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
plugins {
id "me.champeau.gradle.jmh" version "0.4.8"
}
apply plugin: 'java'
sourceCompatibility = java_version
targetCompatibility = java_version
// Set up dependencies.
repositories {
mavenCentral()
}
dependencies {
implementation "org.slf4j:slf4j-api:$slf4j_version"
testCompile "junit:junit:$junit_version"
testCompile "ch.qos.logback:logback-classic:$logback_version"
jmh "org.openjdk.jmh:jmh-core:$jmh_version"
jmh "org.openjdk.jmh:jmh-generator-annprocess:$jmh_version"
}
//add JNI library path for JMH and tests
def root = project.projectDir
allprojects{
tasks.withType(Test) {
filter{
includeTestsMatching "*Test"
}
//add JNIDBus JNI library to path
jvmArgs "-Djava.library.path=${root}/src/main/resources"
//set JNI in berserk mode
//jvmArgs "-Xcheck:jni"
//show only failed test and their full exception
testLogging {
events "failed"
exceptionFormat "full"
//showStandardStreams = true
}
//always execute tests
outputs.upToDateWhen {false}
//launch tests in parallel
maxParallelForks = 4
//fail the test task as soon as one test is failing
failFast = true
}
}
jmh{
//the JMH gradle plugin do not pass env variable around when forking, so we set a Java parameter containing the env variable
//and use it from the benchmark code
String dbus_bus_path = System.getenv().get("DBUS_SESSION_BUS_ADDRESS")
jvmArgs = ['-Djava.library.path='+project.projectDir+'/src/main/resources','-Ddbus.busPath='+dbus_bus_path+'']
jmhVersion jmh_version
}
//generate headers automatically on java > 8 (before javac do not have the -h option)
compileJava {
if(JavaVersion.current() > JavaVersion.VERSION_1_8){
options.compilerArgs += ["-h", file("src/main/jni/src/headers")]
}
}
//add task for JNI code compilation
task compileJNI(type: Exec, dependsOn: compileJava) {
workingDir project.projectDir
commandLine "${project.projectDir}/src/scripts/compileJNI.sh"
}
test.dependsOn compileJNI
apply from: rootProject.file('maven.gradle')