Skip to content

Commit a8d62b4

Browse files
Merge branch 'release-2.9.0'
2 parents 7e4e2e7 + 518a399 commit a8d62b4

File tree

19 files changed

+702
-188
lines changed

19 files changed

+702
-188
lines changed

Jenkinsfile

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ String gradleArgs = '-Dorg.gradle.daemon=false --stacktrace'
66
boolean isPublish = BRANCH_NAME == 'publish'
77
String versionPostfix = isPublish ? '' : BRANCH_NAME // Build script detects empty string as not set.
88

9+
// Note: using single quotes to avoid Groovy String interpolation leaking secrets.
10+
def internalRepoArgs = '-PinternalObjectBoxRepo=$MVN_REPO_URL ' +
11+
'-PinternalObjectBoxRepoUser=$MVN_REPO_LOGIN_USR ' +
12+
'-PinternalObjectBoxRepoPassword=$MVN_REPO_LOGIN_PSW'
13+
def uploadRepoArgs = '-PpreferredRepo=$MVN_REPO_UPLOAD_URL ' +
14+
'-PpreferredUsername=$MVN_REPO_LOGIN_USR ' +
15+
'-PpreferredPassword=$MVN_REPO_LOGIN_PSW '
16+
// Note: add quotes around URL parameter to avoid line breaks due to semicolon in URL.
17+
def uploadRepoArgsBintray = '\"-PpreferredRepo=$BINTRAY_URL\" ' +
18+
'-PpreferredUsername=$BINTRAY_LOGIN_USR ' +
19+
'-PpreferredPassword=$BINTRAY_LOGIN_PSW'
20+
921
// https://jenkins.io/doc/book/pipeline/syntax/
1022
pipeline {
1123
agent { label 'java' }
1224

1325
environment {
14-
GITLAB_URL = credentials('gitlab_url')
1526
MVN_REPO_LOGIN = credentials('objectbox_internal_mvn_user')
1627
MVN_REPO_URL = credentials('objectbox_internal_mvn_repo_http')
17-
MVN_REPO_ARGS = "-PinternalObjectBoxRepo=$MVN_REPO_URL " +
18-
"-PinternalObjectBoxRepoUser=$MVN_REPO_LOGIN_USR " +
19-
"-PinternalObjectBoxRepoPassword=$MVN_REPO_LOGIN_PSW"
2028
MVN_REPO_UPLOAD_URL = credentials('objectbox_internal_mvn_repo')
21-
MVN_REPO_UPLOAD_ARGS = "-PpreferredRepo=$MVN_REPO_UPLOAD_URL " +
22-
"-PpreferredUsername=$MVN_REPO_LOGIN_USR " +
23-
"-PpreferredPassword=$MVN_REPO_LOGIN_PSW " +
24-
"-PversionPostFix=$versionPostfix"
2529
// Note: for key use Jenkins secret file with PGP key as text in ASCII-armored format.
2630
ORG_GRADLE_PROJECT_signingKeyFile = credentials('objectbox_signing_key')
2731
ORG_GRADLE_PROJECT_signingKeyId = credentials('objectbox_signing_key_id')
@@ -31,7 +35,7 @@ pipeline {
3135
options {
3236
buildDiscarder(logRotator(numToKeepStr: buildsToKeep, artifactNumToKeepStr: buildsToKeep))
3337
timeout(time: 1, unit: 'HOURS') // If build hangs (regular build should be much quicker)
34-
gitLabConnection("${env.GITLAB_URL}")
38+
gitLabConnection('objectbox-gitlab-connection')
3539
}
3640

3741
triggers {
@@ -54,7 +58,7 @@ pipeline {
5458

5559
stage('build-java') {
5660
steps {
57-
sh "./ci/test-with-asan.sh $gradleArgs $MVN_REPO_ARGS -Dextensive-tests=true clean test " +
61+
sh "./ci/test-with-asan.sh $gradleArgs $internalRepoArgs -Dextensive-tests=true clean test " +
5862
"--tests io.objectbox.FunctionalTestSuite " +
5963
"--tests io.objectbox.test.proguard.ObfuscatedEntityTest " +
6064
"--tests io.objectbox.rx.QueryObserverTest " +
@@ -65,7 +69,7 @@ pipeline {
6569

6670
stage('upload-to-internal') {
6771
steps {
68-
sh "./gradlew $gradleArgs $MVN_REPO_ARGS $MVN_REPO_UPLOAD_ARGS uploadArchives"
72+
sh "./gradlew $gradleArgs $internalRepoArgs $uploadRepoArgs -PversionPostFix=$versionPostfix uploadArchives"
6973
}
7074
}
7175

@@ -79,11 +83,8 @@ pipeline {
7983
googlechatnotification url: 'id:gchat_java',
8084
message: "*Publishing* ${currentBuild.fullDisplayName} to Bintray...\n${env.BUILD_URL}"
8185

82-
// Note: supply internal Maven repo as tests use native dependencies (can't publish those without the Java libraries).
83-
// Note: add quotes around URL parameter to avoid line breaks due to semicolon in URL.
84-
sh "./gradlew $gradleArgs $MVN_REPO_ARGS " +
85-
"\"-PpreferredRepo=${BINTRAY_URL}\" -PpreferredUsername=${BINTRAY_LOGIN_USR} -PpreferredPassword=${BINTRAY_LOGIN_PSW} " +
86-
"uploadArchives"
86+
// Note: supply internal repo as tests use native dependencies that might not be published, yet.
87+
sh "./gradlew $gradleArgs $internalRepoArgs $uploadRepoArgsBintray uploadArchives"
8788

8889
googlechatnotification url: 'id:gchat_java',
8990
message: "Published ${currentBuild.fullDisplayName} successfully to Bintray - check https://bintray.com/objectbox/objectbox\n${env.BUILD_URL}"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ObjectBox is a superfast object-oriented database with strong relation support.
77
ObjectBox is embedded into your Android, Linux, macOS, or Windows app.
88

9-
**Latest version: [2.8.1 (2020/11/10)](https://docs.objectbox.io/#objectbox-changelog)**
9+
**Latest version: [2.9.0 (2021/02/16)](https://docs.objectbox.io/#objectbox-changelog)**
1010

1111
Demo code using ObjectBox:
1212

@@ -33,7 +33,7 @@ Add this to your root build.gradle (project level):
3333

3434
```groovy
3535
buildscript {
36-
ext.objectboxVersion = '2.8.1'
36+
ext.objectboxVersion = '2.9.0'
3737
dependencies {
3838
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
3939
}

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript {
22
ext {
33
// Typically, only edit those two:
4-
def objectboxVersionNumber = '2.8.1' // without "-SNAPSHOT", e.g. '2.5.0' or '2.4.0-RC'
4+
def objectboxVersionNumber = '2.9.0' // without "-SNAPSHOT", e.g. '2.5.0' or '2.4.0-RC'
55
def objectboxVersionRelease = true // set to true for releasing to ignore versionPostFix to avoid e.g. "-dev" versions
66

77
// version post fix: '-<value>' or '' if not defined; e.g. used by CI to pass in branch name
@@ -22,8 +22,8 @@ buildscript {
2222
essentials_version = '3.1.0'
2323
junit_version = '4.13.1'
2424
mockito_version = '3.3.3'
25-
kotlin_version = '1.4.10'
26-
dokka_version = '0.10.1'
25+
kotlin_version = '1.4.21'
26+
dokka_version = '1.4.20'
2727

2828
println "version=$ob_version"
2929
println "objectboxNativeDependency=$ob_native_dep"

ci/Jenkinsfile-Windows

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1+
#!/usr/bin/env groovy
2+
13
String buildsToKeep = '500'
24

35
String gradleArgs = '-Dorg.gradle.daemon=false --stacktrace'
6+
boolean isPublish = BRANCH_NAME == 'publish'
7+
8+
// Note: using single quotes to avoid Groovy String interpolation leaking secrets.
9+
def internalRepoArgsBat = '-PinternalObjectBoxRepo=%MVN_REPO_URL% ' +
10+
'-PinternalObjectBoxRepoUser=%MVN_REPO_LOGIN_USR% ' +
11+
'-PinternalObjectBoxRepoPassword=%MVN_REPO_LOGIN_PSW%'
412

513
// https://jenkins.io/doc/book/pipeline/syntax/
614
pipeline {
715
agent { label 'windows' }
816

917
environment {
10-
GITLAB_URL = credentials('gitlab_url')
1118
MVN_REPO_URL = credentials('objectbox_internal_mvn_repo_http')
1219
MVN_REPO_LOGIN = credentials('objectbox_internal_mvn_user')
13-
MVN_REPO_ARGS = "-PinternalObjectBoxRepo=$MVN_REPO_URL " +
14-
"-PinternalObjectBoxRepoUser=$MVN_REPO_LOGIN_USR " +
15-
"-PinternalObjectBoxRepoPassword=$MVN_REPO_LOGIN_PSW"
1620
}
1721

1822
options {
1923
buildDiscarder(logRotator(numToKeepStr: buildsToKeep, artifactNumToKeepStr: buildsToKeep))
20-
gitLabConnection("${env.GITLAB_URL}")
24+
gitLabConnection('objectbox-gitlab-connection')
2125
}
2226

2327
triggers {
@@ -29,27 +33,58 @@ pipeline {
2933
stage('init') {
3034
steps {
3135
bat 'gradlew -version'
36+
}
37+
}
38+
39+
stage('build-java-x64') {
40+
steps {
41+
// Remove files to avoid archiving them again.
42+
bat 'del /q /s hs_err_pid*.log'
43+
44+
bat "gradlew $gradleArgs $internalRepoArgsBat cleanTest build test"
45+
}
46+
post {
47+
always {
48+
junit '**/build/test-results/**/TEST-*.xml'
49+
archiveArtifacts artifacts: '**/hs_err_pid*.log', allowEmptyArchive: true
50+
}
51+
}
52+
}
53+
54+
stage('build-java-x86') {
55+
steps {
56+
// Remove files to avoid archiving them again.
57+
bat 'del /q /s hs_err_pid*.log'
3258

33-
// "cmd /c" for an OK exit code if no file is found
34-
bat 'cmd /c del tests\\objectbox-java-test\\hs_err_pid*.log'
59+
// TEST_WITH_JAVA_X86 makes objectbox-java-test use 32-bit java executable and therefore
60+
// 32-bit ObjectBox to run tests (see build.gradle file).
61+
// Note: assumes JAVA_HOME_X86 is set to 32-bit JDK path.
62+
// Note: no space before && or value has space as well.
63+
bat "set TEST_WITH_JAVA_X86=true&& gradlew $gradleArgs $internalRepoArgsBat cleanTest build test"
64+
}
65+
post {
66+
always {
67+
junit '**/build/test-results/**/TEST-*.xml'
68+
archiveArtifacts artifacts: '**/hs_err_pid*.log', allowEmptyArchive: true
69+
}
3570
}
3671
}
3772

38-
stage('build-java') {
73+
stage('package-javadoc-for-web') {
74+
when { expression { return isPublish } }
3975
steps {
40-
bat "gradlew $gradleArgs $MVN_REPO_ARGS cleanTest build test"
76+
bat "gradlew $gradleArgs $internalRepoArgsBat :objectbox-java:packageJavadocForWeb"
77+
}
78+
post {
79+
always {
80+
archiveArtifacts artifacts: 'objectbox-java/build/dist/objectbox-java-web-api-docs.zip'
81+
}
4182
}
4283
}
4384
}
4485

4586
// For global vars see /jenkins/pipeline-syntax/globals
4687
post {
47-
always {
48-
junit '**/build/test-results/**/TEST-*.xml'
49-
archiveArtifacts artifacts: 'tests/*/hs_err_pid*.log', allowEmptyArchive: true // Only on JVM crash.
50-
// currently unused: archiveArtifacts '**/build/reports/findbugs/*'
51-
}
52-
5388
failure {
5489
updateGitlabCommitStatus name: 'build-windows', state: 'failed'
5590
}

objectbox-java-api/src/main/java/io/objectbox/annotation/Sync.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,18 @@
1414
@Retention(RetentionPolicy.CLASS)
1515
@Target(ElementType.TYPE)
1616
public @interface Sync {
17+
18+
/**
19+
* Set to {@code true} to enable shared global IDs for a {@link Sync}-enabled {@link Entity} class.
20+
* <p>
21+
* By default each Sync client has its own local {@link Id ID} space for Objects.
22+
* IDs are mapped to global IDs when syncing behind the scenes. Turn this on
23+
* to treat Object IDs as global and turn of ID mapping. The ID of an Object will
24+
* then be the same on all clients.
25+
* <p>
26+
* When using this, it is recommended to use {@link Id#assignable() assignable IDs}
27+
* to turn off automatically assigned IDs. Without special care, two Sync clients are
28+
* likely to overwrite each others Objects if IDs are assigned automatically.
29+
*/
30+
boolean sharedGlobalIds() default false;
1731
}

objectbox-java/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ javadoc {
3838
}
3939

4040
// Note: use packageJavadocForWeb to get as ZIP.
41-
// Note: the style changes only work if using JDK 10+.
4241
task javadocForWeb(type: Javadoc) {
4342
group = 'documentation'
4443
description = 'Builds Javadoc incl. objectbox-java-api classes with web tweaks.'
4544

45+
javadocTool = javaToolchains.javadocToolFor {
46+
// Note: the style changes only work if using JDK 10+, 11 is latest LTS.
47+
languageVersion = JavaLanguageVersion.of(11)
48+
}
49+
4650
def srcApi = project(':objectbox-java-api').file('src/main/java/')
4751
if (!srcApi.directory) throw new GradleScriptException("Not a directory: ${srcApi}", null)
4852
// Hide internal API from javadoc artifact.

objectbox-java/src/main/java/io/objectbox/BoxStore.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public class BoxStore implements Closeable {
6868
@Nullable private static Object relinker;
6969

7070
/** Change so ReLinker will update native library when using workaround loading. */
71-
public static final String JNI_VERSION = "2.8.0";
71+
public static final String JNI_VERSION = "2.9.0";
7272

73-
private static final String VERSION = "2.8.0-2020-11-05";
73+
private static final String VERSION = "2.9.0-2021-02-16";
7474
private static BoxStore defaultStore;
7575

7676
/** Currently used DB dirs with values from {@link #getCanonicalPath(File)}. */
@@ -384,6 +384,41 @@ static boolean isFileOpenSync(String canonicalPath, boolean runFinalization) {
384384
}
385385
}
386386

387+
/**
388+
* Using an Android Context and an optional database name, as configured with {@link BoxStoreBuilder#name(String)},
389+
* checks if the associated database files are in use by a BoxStore instance.
390+
* <p>
391+
* Use this to check that database files are not open before copying or deleting them.
392+
*/
393+
public static boolean isDatabaseOpen(Object context, @Nullable String dbNameOrNull) throws IOException {
394+
File dbDir = BoxStoreBuilder.getAndroidDbDir(context, dbNameOrNull);
395+
return isFileOpen(dbDir.getCanonicalPath());
396+
}
397+
398+
/**
399+
* Using an optional base directory, as configured with {@link BoxStoreBuilder#baseDirectory(File)},
400+
* and an optional database name, as configured with {@link BoxStoreBuilder#name(String)},
401+
* checks if the associated database files are in use by a BoxStore instance.
402+
* <p>
403+
* Use this to check that database files are not open before copying or deleting them.
404+
*/
405+
public static boolean isDatabaseOpen(@Nullable File baseDirectoryOrNull,
406+
@Nullable String dbNameOrNull) throws IOException {
407+
408+
File dbDir = BoxStoreBuilder.getDbDir(baseDirectoryOrNull, dbNameOrNull);
409+
return isFileOpen(dbDir.getCanonicalPath());
410+
}
411+
412+
/**
413+
* Using a directory, as configured with {@link BoxStoreBuilder#directory(File)},
414+
* checks if the associated database files are in use by a BoxStore instance.
415+
* <p>
416+
* Use this to check that database files are not open before copying or deleting them.
417+
*/
418+
public static boolean isDatabaseOpen(File directory) throws IOException {
419+
return isFileOpen(directory.getCanonicalPath());
420+
}
421+
387422
/**
388423
* The size in bytes occupied by the data file on disk.
389424
*

0 commit comments

Comments
 (0)