objectbox / objectbox/objectbox-java

Gradle option to use model file instead of creating/modifying one

Open
#1,050 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
4.6k
Forks
311
PR merge metrics
No merged PRs in 30d

Description

Currently, every time someone builds a Gradle project, the plugin will look for the entities and recreate the model JSON file if needed.

My suggestion is to add an option to only read the model file without checking and changing it.

The reason for such an option is to allow sharing the same model file and database in multiple languages.

To be more specific, I have a Flutter app that uses objectbox-dart, that app also has Android widgets written in Kotlin, so the idea is that I want to load an objectbox database in read-only mode inside my widget to get information previously added using objectbox-dart in Flutter.

I'm able to do that if I add this to my build.gradle file:

        javaCompileOptions {
            annotationProcessorOptions {
                arguments.put("objectbox.modelPath", "$rootDir/../lib/objectbox-model.json".toString())
            }
        }

And that works, the issue is that from the Flutter side, I have multiple entities, but from the Kotlin side, I'm only interested in one, so if I build my grade project, my JSON model will be replaced with only the entity shared between both languages, to make the Flutter app work again, I need to always forcefully regenerate the model so it overrides what the gradle plugin changed. Hence why I want to prevent gradle build from changing that file.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Gradle plugin's handling of the objectbox.modelPath annotation processor option and the build.gradle configuration shown in the issue. Trace where the model JSON is checked and rewritten, then define an option that reads the existing shared model without modifying it; done means Kotlin can build against the Flutter model while preserving all Flutter entities.

Written by the indexing model from the issue text.

Assessment

Tech stack
flutter, java, kotlin
Domain
build-system, databases, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.