Skip to content

Commit 3e6ecd0

Browse files
Merge branch '218-android-api' into dev
2 parents faa37aa + 1d59245 commit 3e6ecd0

55 files changed

Lines changed: 1948 additions & 238 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 52 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# https://docs.gitlab.com/ci/yaml/
22

3-
# Default Docker image (currently only supporting Docker Linux containers)
4-
# This should match the image used to build the JVM database libraries (so Address Sanitizer library matches).
5-
# When updating, check if the test-jdk jobs need changing.
6-
image: objectboxio/buildenv-core:2025-07-03 # With JDK 21
7-
83
# Assumes these environment variables are configured in GitLab CI/CD Settings:
94
# - OBX_READ_PACKAGES_TOKEN
105
# - SONATYPE_USER
@@ -36,7 +31,7 @@ variables:
3631
GITLAB_PUBLISH_ARGS: "-PgitlabPublishTokenName=Job-Token -PgitlabPublishToken=$CI_JOB_TOKEN"
3732
CENTRAL_PUBLISH_ARGS: "-PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PWD"
3833
# CI_COMMIT_REF_SLUG is the branch or tag name, but web-safe (only 0-9, a-z)
39-
VERSION_ARGS: "-PversionPostFix=$CI_COMMIT_REF_SLUG"
34+
VERSION_ARGS: "-PversionSuffix=$CI_COMMIT_REF_SLUG"
4035

4136
# Using multiple test stages to avoid running some things in parallel (see job notes).
4237
stages:
@@ -65,28 +60,47 @@ workflow:
6560
# In all other cases, create a pipeline
6661
- when: always
6762

68-
test:
69-
stage: test
63+
.docker_linux_x64_android: &docker_linux_x64_android
7064
tags:
7165
- docker
7266
- linux
7367
- x64
68+
image: objectboxio/buildenv-android:2024-12-09 # With JDK 21, Android build-tools;35.0.0 and platforms;android-35 pre-installed
7469
variables:
7570
# Image defaults to POSIX (ASCII), set a compatible locale so UTF-8 tests that interact with the file system work.
7671
# Check with 'locale -a' for available locales.
7772
LC_ALL: "C.UTF-8"
73+
74+
.test_base:
7875
before_script:
7976
# Print Gradle and JVM version info
8077
- ./gradlew -version
8178
# Remove any previous JVM (Hotspot) crash log.
8279
# "|| true" for an OK exit code if no file is found
8380
- rm **/hs_err_pid*.log || true
81+
# By default, don't compile and test the Android APIs (only do in test job), there is currently no benefit to test
82+
# them using multiple platforms or JDKs.
83+
script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build -PexcludeAndroid=true
84+
artifacts:
85+
when: always
86+
paths:
87+
- "**/hs_err_pid*.log" # Only on JVM (Hotspot) crash
88+
reports:
89+
junit: "**/build/test-results/**/TEST-*.xml"
90+
91+
test:
92+
<<: *docker_linux_x64_android
93+
extends: .test_base
94+
stage: test
95+
# Overwrite script key to run through ASAN script, compile and test Android APIs and test build of Web API docs.
96+
# Note: Address sanitizer is only available on Linux runners (see script).
8497
script:
8598
# build to assemble, run tests and spotbugs
8699
# javadocForWeb to catch API docs errors before releasing
87100
# Temporarily disable testing with Address Sanitizer until buildenv images are modernized, see #273
88101
# - ./scripts/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean build javadocForWeb
89102
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build javadocForWeb
103+
# Overwrite artifacts key to archive spotbugs reports
90104
artifacts:
91105
when: always
92106
paths:
@@ -95,88 +109,59 @@ test:
95109
reports:
96110
junit: "**/build/test-results/**/TEST-*.xml"
97111

98-
.test-template:
99-
before_script:
100-
# Print Gradle and JVM version info
101-
- ./gradlew -version
102-
# Remove any previous JVM (Hotspot) crash log.
103-
# "|| true" for an OK exit code if no file is found
104-
- rm **/hs_err_pid*.log || true
105-
artifacts:
106-
when: always
107-
paths:
108-
- "**/hs_err_pid*.log" # Only on JVM (Hotspot) crash.
109-
reports:
110-
junit: "**/build/test-results/**/TEST-*.xml"
111-
112-
test-windows:
113-
extends: .test-template
114-
needs: ["test"]
115-
tags:
116-
- windows-jdk
117-
- x64
118-
script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
119-
120-
test-macos:
121-
extends: .test-template
122-
needs: ["test"]
123-
tags:
124-
- jdk
125-
- mac
126-
script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
127-
128-
# Address sanitizer is only available on Linux runners (see script).
129-
.test-asan-template:
130-
extends: .test-template
131-
tags:
132-
- docker
133-
- linux
134-
- x64
135-
variables:
136-
# Image defaults to POSIX (ASCII), set a compatible locale so UTF-8 tests that interact with the file system work.
137-
# Check with 'locale -a' for available locales.
138-
LC_ALL: "C.UTF-8"
112+
.test_jdks:
113+
<<: *docker_linux_x64_android
114+
extends: .test_base
115+
# Overwrite script key to run through ASAN script and to run test task directly to avoid
116+
# running SpotBugs (build runs check runs SpotBugs tasks).
117+
# Note: Address sanitizer is only available on Linux runners (see script).
139118
script:
140-
# Note: do not run check task as it includes SpotBugs.
141119
# Temporarily disable testing with Address Sanitizer until buildenv images are modernized, see #273
142120
# - ./scripts/test-with-asan.sh $GITLAB_REPO_ARGS $VERSION_ARGS clean :tests:objectbox-java-test:test
143121
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean :tests:objectbox-java-test:test
144122

145123
# Test oldest supported and a recent JDK.
146124
# Note: can not run these in parallel using a matrix configuration as Gradle would step over itself.
147125
test-jdk-8:
148-
extends: .test-asan-template
126+
extends: .test_jdks
149127
needs: ["test"]
150128
variables:
151129
TEST_JDK: 8
152130

153131
# JDK 21 is the default of the current build image, so test the latest LTS JDK 25
154132
test-jdk-25:
155-
extends: .test-asan-template
133+
extends: .test_jdks
156134
needs: ["test-jdk-8"]
157135
variables:
158136
TEST_JDK: 25
159137

160-
test-jdk-x86:
161-
extends: .test-template
162-
needs: ["test-windows"]
138+
test-macos:
139+
extends: .test_base
140+
tags:
141+
- jdk
142+
- mac
143+
144+
test-windows:
145+
extends: .test_base
163146
tags:
164147
- windows-jdk
165148
- x64
149+
150+
test-windows-jdk-x86:
151+
extends: .test_base
152+
needs: ["test-windows"]
153+
tags:
154+
- windows-jdk-x86
166155
variables:
167156
# TEST_WITH_JAVA_X86 makes objectbox-java-test use 32-bit java executable and therefore
168157
# 32-bit ObjectBox to run tests (see build.gradle file).
169158
# Note: assumes JAVA_HOME_X86 is set to 32-bit JDK path.
170159
TEST_WITH_JAVA_X86: "true"
171-
script: ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS clean build
172160

173161
# Publish Maven artifacts to internal Maven repo
174162
publish-maven-internal:
163+
<<: *docker_linux_x64_android
175164
stage: publish-maven-internal
176-
tags:
177-
- docker
178-
- linux
179-
- x64
180165
rules:
181166
# Not when using release versions and not publishing a release to avoid duplicate artifacts
182167
# (GitLab would allow to upload duplicates for a release version)
@@ -191,36 +176,30 @@ publish-maven-internal:
191176
# Otherwise, only if no previous stages failed
192177
- when: on_success
193178
script:
194-
- ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishMavenJavaPublicationToGitLabRepository
179+
- ./gradlew $GITLAB_REPO_ARGS $GITLAB_PUBLISH_ARGS $VERSION_ARGS publishAllPublicationsToGitLabRepository
195180

196181
# Publish Maven artifacts to public Maven Central repo
197182
publish-maven-central:
183+
<<: *docker_linux_x64_android
198184
stage: publish-maven-central
199-
tags:
200-
- docker
201-
- linux
202-
- x64
203185
rules:
204186
# Only if publishing a release, only if no previous stages failed
205187
- if: $OBX_PUBLISH_RELEASE == "true"
206188
when: on_success
207189
before_script:
208-
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* job $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..."
190+
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java libraries to Maven Central:* job $CI_JOB_NAME from branch $CI_COMMIT_BRANCH ($CI_COMMIT_SHORT_SHA)..."
209191
script:
210-
# Note: supply internal repo as tests use native dependencies that might not be published, yet.
211-
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS $CENTRAL_PUBLISH_ARGS publishMavenJavaPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
192+
# Note: supply internal repo as tests use native dependencies that might not be available publicly, yet.
193+
- ./gradlew $GITLAB_REPO_ARGS $VERSION_ARGS $CENTRAL_PUBLISH_ARGS publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository
212194
after_script:
213195
# Also runs on failure, so show CI_JOB_STATUS.
214-
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java library:* *$CI_JOB_STATUS* for $CI_JOB_NAME"
196+
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "*Releasing Java libraries to Maven Central:* *$CI_JOB_STATUS* for $CI_JOB_NAME"
215197
- ci/send-to-gchat.sh "$GOOGLE_CHAT_WEBHOOK_JAVA_CI" --thread $CI_COMMIT_SHA "Check https://repo1.maven.org/maven2/io/objectbox/ in a few minutes."
216198

217199
# Create Java API docs archive
218200
package-api-docs:
201+
<<: *docker_linux_x64_android
219202
stage: package-api-docs
220-
tags:
221-
- docker
222-
- linux
223-
- x64
224203
rules:
225204
# Only if publishing a release, only if no previous stages failed
226205
- if: $OBX_PUBLISH_RELEASE == "true"

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ For more insights into what changed in the database libraries, [check the Object
66

77
## Next release
88

9+
- Update Android and JVM libraries to database version `5.3.1-next-2026-04-24`
10+
911
## 5.4.1 - 2026-03-26
1012

1113
- Update Android and JVM libraries to database version `5.3.1-2026-03-26`

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ String buildsToKeep = '500'
66

77
String gradleArgs = '--stacktrace'
88
boolean isPublish = BRANCH_NAME == 'publish'
9-
String versionPostfix = isPublish ? '' : BRANCH_NAME // Build script detects empty string as not set.
9+
String versionSuffix = isPublish ? '' : BRANCH_NAME // Build script detects empty string as not set.
1010

1111
// Note: using single quotes to avoid Groovy String interpolation leaking secrets.
1212
def signingArgs = '-PsigningKeyFile=$SIGNING_FILE -PsigningKeyId=$SIGNING_ID -PsigningPassword=$SIGNING_PWD'
@@ -107,7 +107,7 @@ pipeline {
107107

108108
stage('upload-to-internal') {
109109
steps {
110-
sh "./gradlew $gradleArgs $signingArgs $gitlabRepoArgs -PversionPostFix=$versionPostfix publishMavenJavaPublicationToGitLabRepository"
110+
sh "./gradlew $gradleArgs $signingArgs $gitlabRepoArgs -PversionSuffix=$versionSuffix publishMavenJavaPublicationToGitLabRepository"
111111
}
112112
}
113113

build-logic/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build logic project
2+
3+
This project provides common build logic and is included as a composite build in the root settings file (as it provides
4+
a plugin, in the `pluginManagement` block instead of before the usual include statements):
5+
6+
```kotlin
7+
pluginManagement {
8+
includeBuild("build-logic")
9+
}
10+
```
11+
12+
## Convention Plugins
13+
14+
- [objectbox.publishing-conventions](src/main/kotlin/objectbox.publishing-conventions.gradle.kts): adds GitLab repo,
15+
configures common Maven POM values, configures signing of artifacts
16+
17+
## Related Gradle documentation
18+
19+
- https://docs.gradle.org/current/userguide/composite_builds.html#included_plugin_builds
20+
- https://docs.gradle.org/current/userguide/best_practices_structuring_builds.html#use_convention_plugins
21+
- https://github.com/gradle/gradle/tree/master/platforms/documentation/docs/src/snippets/best-practices/useConventionPlugins-do

build-logic/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "build-logic"

buildSrc/src/main/kotlin/objectbox-publish.gradle.kts renamed to build-logic/src/main/kotlin/objectbox.publishing-conventions.gradle.kts

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This script requires some Gradle project properties to be set
1+
// This convention plugin expects some Gradle project properties to be set
22
// (to set as environment variable prefix with ORG_GRADLE_PROJECT_):
33
// https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties
44
//
@@ -12,39 +12,49 @@
1212
// - signingKeyId
1313
// - signingPassword
1414

15+
// Gradle properties
16+
val gitlabUrl = providers.gradleProperty("gitlabUrl")
17+
val gitlabPublishToken = providers.gradleProperty("gitlabPublishToken")
18+
val gitlabPublishTokenName = providers.gradleProperty("gitlabPublishTokenName")
19+
// The following properties are used for signing in CI using a key file
20+
val signingKeyFile = providers.gradleProperty("signingKeyFile")
21+
val signingKeyId = providers.gradleProperty("signingKeyId")
22+
val signingPassword = providers.gradleProperty("signingPassword")
23+
1524
plugins {
1625
id("maven-publish")
1726
id("signing")
1827
}
1928

2029
publishing {
2130
repositories {
31+
// If the applied to project has the required properties, configures the "GitLab" repository for publishing
32+
// (Note: always adding it, even without credentials, so it's possible to see the tasks created for it.)
2233
maven {
2334
name = "GitLab"
24-
if (project.hasProperty("gitlabUrl") && project.hasProperty("gitlabPublishToken")) {
35+
if (gitlabUrl.isPresent && gitlabPublishToken.isPresent) {
2536
// "https://gitlab.example.com/api/v4/projects/<PROJECT_ID>/packages/maven"
26-
val gitlabUrl = project.property("gitlabUrl")
27-
url = uri("$gitlabUrl/api/v4/projects/14/packages/maven")
37+
url = uri("${gitlabUrl.get()}/api/v4/projects/14/packages/maven")
2838
credentials(HttpHeaderCredentials::class) {
29-
name = project.findProperty("gitlabPublishTokenName")?.toString() ?: "Private-Token"
30-
value = project.property("gitlabPublishToken").toString()
39+
name = gitlabPublishTokenName.orNull ?: "Private-Token"
40+
value = gitlabPublishToken.get()
3141
}
3242
authentication {
3343
create<HttpHeaderAuthentication>("header")
3444
}
3545
println("Publishing: configured GitLab repository $url")
3646
} else {
37-
println("Publishing: GitLab repository not configured")
47+
println("Publishing: GitLab repository NOT configured, see publishing-conventions plugin for required project properties")
3848
}
3949
}
4050
// Note: Sonatype repo created by publish-plugin, see root build.gradle.kts.
4151
}
4252

4353
publications {
44-
create<MavenPublication>("mavenJava") {
54+
// Common settings for all Maven publications
55+
withType<MavenPublication> {
4556
// Note: Projects set additional specific properties.
4657
pom {
47-
packaging = "jar"
4858
url.set("https://objectbox.io")
4959
licenses {
5060
license {
@@ -78,24 +88,15 @@ publishing {
7888
}
7989

8090
signing {
81-
if (hasSigningProperties()) {
91+
if (signingKeyFile.isPresent && signingKeyId.isPresent && signingPassword.isPresent) {
8292
// Sign using an ASCII-armored key read from a file
8393
// https://docs.gradle.org/current/userguide/signing_plugin.html#using_in_memory_ascii_armored_openpgp_subkeys
84-
val signingKey = File(project.property("signingKeyFile").toString()).readText()
85-
useInMemoryPgpKeys(
86-
project.property("signingKeyId").toString(),
87-
signingKey,
88-
project.property("signingPassword").toString()
89-
)
90-
sign(publishing.publications["mavenJava"])
91-
println("Publishing: configured signing with key file")
94+
val keyFilePath = signingKeyFile.get()
95+
val signingKey = File(keyFilePath).readText()
96+
useInMemoryPgpKeys(signingKeyId.get(), signingKey, signingPassword.get())
97+
println("Publishing: signing configured with key file $keyFilePath")
9298
} else {
93-
println("Publishing: signing not configured")
99+
isRequired = false // Don't run sign tasks
100+
println("Publishing: signing NOT configured, see publishing-conventions plugin for required project properties")
94101
}
95102
}
96-
97-
fun hasSigningProperties(): Boolean {
98-
return (project.hasProperty("signingKeyId")
99-
&& project.hasProperty("signingKeyFile")
100-
&& project.hasProperty("signingPassword"))
101-
}

0 commit comments

Comments
 (0)