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
33
4- tasks.withType(JavaCompile ).configureEach {
4+ plugins {
5+ id(" java-library" )
6+ id(" kotlin" )
7+ }
8+
9+ tasks.withType<JavaCompile > {
510 // Note: use release flag instead of sourceCompatibility and targetCompatibility to ensure only JDK 8 API is used.
611 // https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation
712 options.release.set(8 )
@@ -10,64 +15,73 @@ tasks.withType(JavaCompile).configureEach {
1015}
1116
1217// 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 > {
1419 kotlinOptions {
1520 jvmTarget = " 1.8"
1621 }
1722}
1823
1924repositories {
2025 // 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." )
2329 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()
2935 }
3036 authentication {
31- header( HttpHeaderAuthentication )
37+ create< HttpHeaderAuthentication >( " header " )
3238 }
3339 }
3440 } else {
35- println " Property gitlabUrl not set."
41+ println ( " Property gitlabUrl not set." )
3642 }
3743}
3844
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+
3952dependencies {
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 " )
4558
4659 // 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)
5064 } else {
51- println " Did NOT add native dependency"
65+ println ( " Did NOT add native dependency" )
5266 }
5367
54- testImplementation " junit:junit:$junitVersion "
68+ testImplementation( " junit:junit:$junitVersion " )
5569 // To test Coroutines
5670 testImplementation(" org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion " )
5771 // To test Kotlin Flow
58- testImplementation ' app.cash.turbine:turbine:0.5.2'
72+ testImplementation( " app.cash.turbine:turbine:0.5.2" )
5973}
6074
61- test {
75+ tasks. test {
6276 if (System .getenv(" TEST_WITH_JAVA_X86" ) == " true" ) {
6377 // To run tests with 32-bit ObjectBox
6478 // 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"
6680 println (" Will run tests with $javaExecutablePath " )
6781 executable = javaExecutablePath
6882 } else if (System .getenv(" TEST_JDK" ) != null ) {
6983 // 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()
7185 println (" Will run tests with JDK $sdkVersionInt " )
7286 javaLauncher.set(javaToolchains.launcherFor {
7387 languageVersion.set(JavaLanguageVersion .of(sdkVersionInt))
@@ -76,19 +90,22 @@ test {
7690
7791 // This is pretty useless now because it floods console with warnings about internal Java classes
7892 // However we might check from time to time, also with Java 9.
79- // jvmArgs ' -Xcheck:jni'
93+ // jvmArgs " -Xcheck:jni"
8094
8195 filter {
8296 // 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.*" )
8599 }
86100 }
87101
88102 testLogging {
89103 showStandardStreams = true
90- exceptionFormat = ' full '
104+ exceptionFormat = TestExceptionFormat . FULL
91105 displayGranularity = 2
92- events ' started' , ' passed'
106+ events = setOf (
107+ TestLogEvent .STARTED ,
108+ TestLogEvent .PASSED
109+ )
93110 }
94111}
0 commit comments