1
- apply plugin : ' java-library '
2
- apply plugin : ' kotlin '
1
+ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2
+ import org.gradle.api.tasks.testing.logging.TestLogEvent
3
3
4
- tasks.withType(JavaCompile ).configureEach {
4
+ plugins {
5
+ id(" java-library" )
6
+ id(" kotlin" )
7
+ }
8
+
9
+ tasks.withType<JavaCompile > {
5
10
// Note: use release flag instead of sourceCompatibility and targetCompatibility to ensure only JDK 8 API is used.
6
11
// https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation
7
12
options.release.set(8 )
@@ -10,64 +15,73 @@ tasks.withType(JavaCompile).configureEach {
10
15
}
11
16
12
17
// Produce Java 8 byte code, would default to Java 6.
13
- tasks.withType( org.jetbrains.kotlin.gradle.tasks.KotlinCompile ).configureEach {
18
+ tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > {
14
19
kotlinOptions {
15
20
jvmTarget = " 1.8"
16
21
}
17
22
}
18
23
19
24
repositories {
20
25
// Native lib might be deployed only in internal repo
21
- if (project.hasProperty(' gitlabUrl' )) {
22
- println " gitlabUrl=$gitlabUrl added to repositories."
26
+ if (project.hasProperty(" gitlabUrl" )) {
27
+ val gitlabUrl = project.property(" gitlabUrl" )
28
+ println (" gitlabUrl=$gitlabUrl added to repositories." )
23
29
maven {
24
- url " $gitlabUrl /api/v4/groups/objectbox/-/packages/maven"
25
- name " GitLab"
26
- credentials(HttpHeaderCredentials ) {
27
- name = project.hasProperty (" gitlabTokenName" ) ? gitlabTokenName : " Private-Token"
28
- value = gitlabPrivateToken
30
+ url = uri( " $gitlabUrl /api/v4/groups/objectbox/-/packages/maven" )
31
+ name = " GitLab"
32
+ credentials(HttpHeaderCredentials :: class ) {
33
+ name = project.findProperty (" gitlabTokenName" )?.toString() ? : " Private-Token"
34
+ value = project.property( " gitlabPrivateToken" ).toString()
29
35
}
30
36
authentication {
31
- header( HttpHeaderAuthentication )
37
+ create< HttpHeaderAuthentication >( " header " )
32
38
}
33
39
}
34
40
} else {
35
- println " Property gitlabUrl not set."
41
+ println ( " Property gitlabUrl not set." )
36
42
}
37
43
}
38
44
45
+ val obxJniLibVersion: String by rootProject.extra
46
+
47
+ val kotlinVersion: String by rootProject.extra
48
+ val coroutinesVersion: String by rootProject.extra
49
+ val essentialsVersion: String by rootProject.extra
50
+ val junitVersion: String by rootProject.extra
51
+
39
52
dependencies {
40
- implementation project(' :objectbox-java' )
41
- implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion "
42
- implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion "
43
- implementation project(' :objectbox-kotlin' )
44
- implementation " org.greenrobot:essentials:$essentialsVersion "
53
+ implementation( project(" :objectbox-java" ) )
54
+ implementation( " org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion " )
55
+ implementation( " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion " )
56
+ implementation( project(" :objectbox-kotlin" ) )
57
+ implementation( " org.greenrobot:essentials:$essentialsVersion " )
45
58
46
59
// Check flag to use locally compiled version to avoid dependency cycles
47
- if (! project.hasProperty(' noObjectBoxTestDepencies' ) || ! noObjectBoxTestDepencies) {
48
- println " Using $obxJniLibVersion "
49
- implementation obxJniLibVersion
60
+ if (! project.hasProperty(" noObjectBoxTestDepencies" )
61
+ || project.property(" noObjectBoxTestDepencies" ) == false ) {
62
+ println (" Using $obxJniLibVersion " )
63
+ implementation(obxJniLibVersion)
50
64
} else {
51
- println " Did NOT add native dependency"
65
+ println ( " Did NOT add native dependency" )
52
66
}
53
67
54
- testImplementation " junit:junit:$junitVersion "
68
+ testImplementation( " junit:junit:$junitVersion " )
55
69
// To test Coroutines
56
70
testImplementation(" org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion " )
57
71
// To test Kotlin Flow
58
- testImplementation ' app.cash.turbine:turbine:0.5.2'
72
+ testImplementation( " app.cash.turbine:turbine:0.5.2" )
59
73
}
60
74
61
- test {
75
+ tasks. test {
62
76
if (System .getenv(" TEST_WITH_JAVA_X86" ) == " true" ) {
63
77
// To run tests with 32-bit ObjectBox
64
78
// Note: 32-bit JDK is only available on Windows
65
- def javaExecutablePath = System .getenv(" JAVA_HOME_X86" ) + " \\ bin\\ java.exe"
79
+ val javaExecutablePath = System .getenv(" JAVA_HOME_X86" ) + " \\ bin\\ java.exe"
66
80
println (" Will run tests with $javaExecutablePath " )
67
81
executable = javaExecutablePath
68
82
} else if (System .getenv(" TEST_JDK" ) != null ) {
69
83
// To run tests on a different JDK, uses Gradle toolchains API (https://docs.gradle.org/current/userguide/toolchains.html)
70
- def sdkVersionInt = System .getenv(" TEST_JDK" ) as Integer
84
+ val sdkVersionInt = System .getenv(" TEST_JDK" ).toInt()
71
85
println (" Will run tests with JDK $sdkVersionInt " )
72
86
javaLauncher.set(javaToolchains.launcherFor {
73
87
languageVersion.set(JavaLanguageVersion .of(sdkVersionInt))
@@ -76,19 +90,22 @@ test {
76
90
77
91
// This is pretty useless now because it floods console with warnings about internal Java classes
78
92
// However we might check from time to time, also with Java 9.
79
- // jvmArgs ' -Xcheck:jni'
93
+ // jvmArgs " -Xcheck:jni"
80
94
81
95
filter {
82
96
// Note: Tree API currently incubating on Linux only.
83
- if (! System .getProperty(" os.name" ).toLowerCase ().contains(' linux' )) {
84
- excludeTestsMatching " io.objectbox.tree.*"
97
+ if (! System .getProperty(" os.name" ).lowercase ().contains(" linux" )) {
98
+ excludeTestsMatching( " io.objectbox.tree.*" )
85
99
}
86
100
}
87
101
88
102
testLogging {
89
103
showStandardStreams = true
90
- exceptionFormat = ' full '
104
+ exceptionFormat = TestExceptionFormat . FULL
91
105
displayGranularity = 2
92
- events ' started' , ' passed'
106
+ events = setOf (
107
+ TestLogEvent .STARTED ,
108
+ TestLogEvent .PASSED
109
+ )
93
110
}
94
111
}
0 commit comments