### Verify Gradle and JDK Setup Source: https://github.com/objectbox/objectbox-java/blob/main/AGENTS.md Check the installed Gradle version and its configuration. This command helps ensure the development environment is correctly set up. ```bash ./gradlew -version ``` -------------------------------- ### Gradle TOML Version Catalog Setup Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Define ObjectBox and other plugin versions in your `libs.versions.toml` file. This is for projects using TOML version catalogs and the plugins DSL. ```toml # gradle/libs.versions.toml [versions] # For an Android project agp = "AGP_VERSION" # If using Kotlin kotlin = "KOTLIN_VERSION" # Define a variable for the version of the ObjectBox plugin objectbox = "5.4.2" [plugins] # For an Android project, using Android Gradle Plugin 9.0 or newer android-application = { id = "com.android.application", version.ref = "agp" } kotlin-kapt = { id = "com.android.legacy-kapt", version.ref = "agp" } # For an Android project, using Android Gradle Plugin 8.13 or older android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } # For a JVM project, if using Kotlin kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } # Add an alias for the ObjectBox plugin objectbox = { id = "io.objectbox", version.ref = "objectbox" } ``` -------------------------------- ### ObjectBox Buildscript Setup (build.gradle) Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Configure the ObjectBox plugin using the buildscript syntax in build.gradle (Groovy). Define the plugin version using ext and add mavenCentral() to repositories for both plugin and dependency resolution. ```groovy // build.gradle buildscript { // Define a variable for the ObjectBox plugin version ext.objectboxVersion = "5.4.2" repositories { // Add Maven Central to the plugin repositories mavenCentral() } dependencies { // Add the ObjectBox plugin classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion") } } allprojects { repositories { // Add Maven Central to the dependency repositories mavenCentral() } } ``` -------------------------------- ### ObjectBox Plugin ID Setup (build.gradle.kts) Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Use this syntax in your root build.gradle.kts to declare the ObjectBox plugin with its version, setting apply to false for later application in subprojects. ```kotlin // build.gradle.kts plugins { // Add the ObjectBox plugin id("io.objectbox") version "5.4.2" apply false } ``` -------------------------------- ### ObjectBox Buildscript Setup (build.gradle.kts) Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Configure the ObjectBox plugin using the buildscript syntax in build.gradle.kts. Define the plugin version and add mavenCentral() to repositories for both plugin and dependency resolution. ```kotlin // build.gradle.kts buildscript { // Define a variable for the ObjectBox plugin version val objectboxVersion by extra("5.4.2") repositories { // Add Maven Central to the plugin repositories mavenCentral() } dependencies { // Add the ObjectBox plugin classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion") } } allprojects { repositories { // Add Maven Central to the dependency repositories mavenCentral() } } ``` -------------------------------- ### Get Query Results and Subscribe to Updates (Java) Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-rxjava/README.md Use `RxQuery.observable` to get query results and automatically subscribe to future updates when ObjectBox data changes. Ensure you have a `Query` object built. ```java Query query = box.query().build(); RxQuery.observable(query).subscribe(this); ``` -------------------------------- ### Apply ObjectBox Plugin in Subproject (app/build.gradle.kts) Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Apply the ObjectBox plugin in your subproject's build.gradle.kts file. This example shows applying common Android and JVM plugins before applying the ObjectBox plugin. ```kotlin // app/build.gradle.kts plugins { // For an Android project, using Android Gradle Plugin 9.0 or newer id("com.android.application") // or id("com.android.library") id("com.android.legacy-kapt") // For an Android project, using Android Gradle Plugin 8.13 or older id("com.android.application") // or id("com.android.library") id("org.jetbrains.kotlin.android") // or kotlin("android") id("org.jetbrains.kotlin.kapt") // or kotlin("kapt") // For a JVM project id("application") // or id("java-library") // Optional, if using Kotlin id("org.jetbrains.kotlin.jvm") // or kotlin("jvm") id("org.jetbrains.kotlin.kapt") // or kotlin("kapt") // Finally, apply the ObjectBox plugin id("io.objectbox") } ``` -------------------------------- ### CI-Style Build with ASAN Source: https://github.com/objectbox/objectbox-java/blob/main/AGENTS.md Perform a build with AddressSanitizer (ASAN) enabled, mimicking the CI environment. This requires native dependencies and is useful for detecting memory errors. ```bash ./scripts/test-with-asan.sh --stacktrace clean build ``` -------------------------------- ### Root build.gradle.kts Plugin Configuration Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Apply necessary plugins in your root `build.gradle.kts` file. Use `apply false` for plugins defined in the version catalog. ```kotlin // build.gradle.kts plugins { // For an Android project, using Android Gradle Plugin 9.0 or newer alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.kapt) apply false // For an Android project, using Android Gradle Plugin 8.13 or older alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.kotlin.kapt) apply false // For a JVM project, if using Kotlin alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.kotlin.kapt) apply false // Add the ObjectBox plugin alias(libs.plugins.objectbox) apply false } ``` -------------------------------- ### Clean and Build All Modules Source: https://github.com/objectbox/objectbox-java/blob/main/AGENTS.md Run a full build across all modules in the repository. This command cleans previous build artifacts and compiles the entire project. ```bash ./gradlew clean build ``` -------------------------------- ### Run Main Test Suite Source: https://github.com/objectbox/objectbox-java/blob/main/AGENTS.md Execute the primary test suite for the objectbox-java module. This command is useful for verifying core functionality. ```bash ./gradlew :tests:objectbox-java-test:test ``` -------------------------------- ### Subproject build.gradle.kts Plugin Application Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Apply the required plugins, including ObjectBox, in your subproject's `build.gradle.kts` file. This activates ObjectBox for the specific module. ```kotlin // app/build.gradle.kts plugins { // For an Android project, using Android Gradle Plugin 9.0 or newer alias(libs.plugins.android.application) alias(libs.plugins.kotlin.kapt) // For an Android project, using Android Gradle Plugin 8.13 or older alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.kapt) // For a JVM project id("application") // or id("java-library") // Optional, if using Kotlin alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.kapt) // Finally, apply the ObjectBox plugin alias(libs.plugins.objectbox) } ``` -------------------------------- ### Build a Single Module Source: https://github.com/objectbox/objectbox-java/blob/main/AGENTS.md Build a specific module within the multi-module Gradle project. Replace ':objectbox-java' with the desired module path. ```bash ./gradlew :objectbox-java:build ``` -------------------------------- ### Include Composite Build in Gradle Source: https://github.com/objectbox/objectbox-java/blob/main/build-logic/README.md Include the build-logic project as a composite build in your root settings file. This makes its plugins available for use in your project. ```kotlin pluginManagement { includeBuild("build-logic") } ``` -------------------------------- ### settings.gradle.kts Repository Configuration Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Configure repositories in `settings.gradle.kts` to include Maven Central for plugin and dependency resolution. This ensures Gradle can find necessary artifacts. ```kotlin // settings.gradle.kts pluginManagement { repositories { // Add Maven Central to the plugin repositories mavenCentral() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { // Add Maven Central to the dependency repositories mavenCentral() } } ``` -------------------------------- ### ObjectBox Java License Source: https://github.com/objectbox/objectbox-java/blob/main/README.md This is the Apache License, Version 2.0, which applies to the code in this repository. Ensure compliance with its terms for usage and distribution. ```text Copyright 2017-2025 ObjectBox Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### ObjectBoxDataSource Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-android/README.md A reference implementation of a data source for the AndroidX paging library, facilitating efficient loading of large datasets. ```APIDOC ## ObjectBoxDataSource ### Description This is a reference implementation of a data source designed to work with the AndroidX paging library. ### Usage Integrate this class to efficiently load and display large datasets using the AndroidX paging library with ObjectBox. ``` -------------------------------- ### Add ObjectBox RxJava Dependency (Gradle) Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-rxjava/README.md Include the ObjectBox RxJava library in your project by adding the following dependency to your Gradle build file. Replace `$objectboxVersion` with your desired ObjectBox version. ```gradle implementation "io.objectbox:objectbox-rxjava:$objectboxVersion" ``` -------------------------------- ### Add RxJava 3 Dependency via Gradle Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-rxjava3/README.md Include the objectbox-rxjava3 library in your project using Gradle. Ensure you replace '$objectboxVersion' with your specific ObjectBox version. ```gradle implementation "io.objectbox:objectbox-rxjava3:$objectboxVersion" ``` -------------------------------- ### ObjectBox Java CRUD Operations Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Demonstrates basic Create, Read, Update, and Delete operations using ObjectBox in a Java environment. Ensure the 'Person' class is annotated with @Entity and has an @Id field. ```java // Annotate a class to create a Box @Entity public class Person { private @Id long id; private String firstName; private String lastName; // Constructor, getters and setters left out for simplicity } BoxStore store = MyObjectBox.builder() .name("person-db") .build(); Box box = store.boxFor(Person.class); Person person = new Person("Joe", "Green"); long id = box.put(person); // Create person = box.get(id); // Read person.setLastName("Black"); box.put(person); // Update box.remove(person); // Delete ``` -------------------------------- ### ObjectBoxLiveData Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-android/README.md A reference implementation of an AndroidX LiveData, allowing ObjectBox data to be observed reactively within Android applications. ```APIDOC ## ObjectBoxLiveData ### Description A reference implementation of an AndroidX LiveData that integrates with ObjectBox. ### Usage Use this class to observe ObjectBox data changes reactively in your Android application components, leveraging the benefits of LiveData. ``` -------------------------------- ### AndroidScheduler Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-android/README.md Enables observing query results on the Android main thread, crucial for UI updates. ```APIDOC ## AndroidScheduler ### Description A scheduler that can be used to observe query results on the Android main thread. ### Usage See [Thread Scheduling](https://docs.objectbox.io/data-observers-and-rx#thread-scheduling) for examples on how to use AndroidScheduler. ``` -------------------------------- ### Admin API Source: https://github.com/objectbox/objectbox-java/blob/main/objectbox-android/README.md API to use the Admin web app on Android. This allows for data inspection and management directly on Android devices. ```APIDOC ## Admin API ### Description Provides access to the ObjectBox Admin web app functionality on Android devices. ### Usage Refer to the [Admin web app on Android](https://docs.objectbox.io/data-browser#admin-for-android) documentation for detailed usage instructions. ``` -------------------------------- ### ObjectBox Kotlin CRUD Operations for Android Source: https://github.com/objectbox/objectbox-java/blob/main/README.md Illustrates basic Create, Read, Update, and Delete operations using ObjectBox in a Kotlin environment, specifically for Android applications. The 'Person' data class should be annotated with @Entity and have an @Id property. ```kotlin // Annotate a class to create a Box @Entity data class Person( @Id var id: Long = 0, var firstName: String? = null, var lastName: String? = null ) val store = MyObjectBox.builder() .androidContext(context) .build() val box = store.boxFor(Person::class) var person = Person(firstName = "Joe", lastName = "Green") val id = box.put() // Create person = box.get(id) // Read person.lastName = "Black" box.put(person) // Update box.remove(person) // Delete ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.