Skip to content

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

Open
@sezaru

Description

@sezaru

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions