objectbox / objectbox/objectbox-dart

Generator output conflicts with retrofit builder

Open
#342 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

🚨 First, please check:

  1. create a model current_user.dart inside lib folder:
import 'package:objectbox/objectbox.dart';

@Entity()
class CurrentUser {
  @Id(assignable: true)
  int? localId;
  @Unique()
  String? id;
  @Property(type: PropertyType.date)
  DateTime createdAt;
  @Property(type: PropertyType.date)
  DateTime? updatedAt;

  CurrentUser({
    this.localId,
    this.id,
    required this.createdAt,
    this.updatedAt,
  });
}
  1. run flutter pub run build_runner build --delete-conflicting-outputs
  2. get error:
[INFO] Initializing inputs
[INFO] Building new asset graph...
[SEVERE] Conflicting outputs
Both objectbox_generator:generator and source_gen:combining_builder may output lib/objectbox.g.dart. Potential outputs must be unique across all builders. See https://github.com/dart-lang/build/blob/master/docs/faq.md#why-do-builders-need-unique-outputs
[INFO] Terminating. No further builds will be scheduled
Basic info (please complete the following information):
  • ObjectBox version: [1.3.0]
  • Flutter/Dart SDK: [2.5.3 / 2.14.4]
  • Null-safety enabled: [yes]
  • Reproducibility: [always]
  • OS: [ macOs BigSur]
  • Device/Emulator: [iPhone 13]

Additionally, you can choose to provide more details, e.g. the output of:

  • pub deps --no-dev
Dart SDK 2.14.4
Flutter SDK 2.5.3
admin 1.0.0+1
|-- animations 2.0.2
|   '-- flutter...
|-- auto_route 3.1.3
|   |-- collection 1.15.0
|   |-- flutter...
|   |-- path...
|   '-- universal_html 2.0.8
|       |-- async 2.8.1
|       |   |-- collection...
|       |   '-- meta...
|       |-- charcode 1.3.1
|       |-- collection...
|       |-- csslib 0.17.1
|       |   '-- source_span...
|       |-- html 0.15.0
|       |   |-- csslib...
|       |   '-- source_span...
|       |-- meta...
|       |-- source_span 1.8.1
|       |   |-- collection...
|       |   |-- path...
|       |   '-- term_glyph 1.2.0
|       |-- typed_data...
|       '-- universal_io 2.0.4
|           |-- collection...
|           |-- crypto...
|           |-- meta...
|           '-- typed_data...
|-- cupertino_icons 1.0.4
|-- dartz 0.10.0
|-- dio 4.0.3
|   |-- http_parser 4.0.0
|   |   |-- charcode...
|   |   |-- collection...
|   |   |-- source_span...
|   |   |-- string_scanner 1.1.0
|   |   |   |-- charcode...
|   |   |   '-- source_span...
|   |   '-- typed_data...
|   '-- path...
|-- enum_to_string 2.0.1
|-- flare_flutter 3.0.2
|   |-- collection...
|   |-- flutter...
|   '-- meta 1.7.0
|-- flex_color_scheme 4.0.0
|   '-- flutter...
|-- flutter 0.0.0
|   |-- characters 1.1.0
|   |-- collection...
|   |-- meta...
|   |-- sky_engine 0.0.99
|   |-- typed_data 1.3.0
|   |   '-- collection...
|   '-- vector_math 2.1.0
|-- flutter_breadcrumb 1.0.1
|   |-- flutter...
|   '-- pedantic 1.11.1
|-- flutter_hooks 0.18.1
|   '-- flutter...
|-- flutter_secure_storage 5.0.2
|   |-- flutter...
|   |-- flutter_secure_storage_linux 1.1.0
|   |   |-- flutter...
|   |   '-- flutter_secure_storage_platform_interface...
|   |-- flutter_secure_storage_macos 1.1.0
|   |   |-- flutter...
|   |   '-- flutter_secure_storage_platform_interface...
|   |-- flutter_secure_storage_platform_interface 1.0.0
|   |   |-- flutter...
|   |   '-- plugin_platform_interface 2.0.2
|   |       '-- meta...
|   |-- flutter_secure_storage_web 1.0.2
|   |   |-- flutter...
|   |   |-- flutter_secure_storage_platform_interface...
|   |   |-- flutter_web_plugins 0.0.0
|   |   |   |-- characters...
|   |   |   |-- collection...
|   |   |   |-- flutter...
|   |   |   |-- js...
|   |   |   |-- meta...
|   |   |   |-- typed_data...
|   |   |   '-- vector_math...
|   |   '-- js 0.6.3
|   |-- flutter_secure_storage_windows 1.1.2
|   |   |-- flutter...
|   |   '-- flutter_secure_storage_platform_interface...
|   '-- meta...
|-- freezed_annotation 1.0.0
|   |-- collection...
|   |-- json_annotation...
|   '-- meta...
|-- graphql 5.0.0
|   |-- collection...
|   |-- gql 0.13.1-alpha+1635885531641
|   |   |-- collection...
|   |   |-- meta...
|   |   '-- source_span...
|   |-- gql_dedupe_link 2.0.0
|   |   |-- async...
|   |   |-- gql_exec...
|   |   |-- gql_link...
|   |   '-- meta...
|   |-- gql_error_link 0.2.0
|   |   |-- async...
|   |   |-- gql_exec...
|   |   |-- gql_link...
|   |   '-- meta...
|   |-- gql_exec 0.3.0
|   |   |-- collection...
|   |   |-- gql...
|   |   '-- meta...
|   |-- gql_http_link 0.4.0
|   |   |-- gql...
|   |   |-- gql_exec...
|   |   |-- gql_link...
|   |   |-- http...
|   |   |-- http_parser...
|   |   '-- meta...
|   |-- gql_link 0.4.0
|   |   |-- gql...
|   |   |-- gql_exec...
|   |   '-- meta...
|   |-- gql_transform_link 0.2.0
|   |   |-- gql_exec...
|   |   '-- gql_link...
|   |-- hive 2.0.4
|   |   |-- crypto 3.0.1
|   |   |   |-- collection...
|   |   |   '-- typed_data...
|   |   '-- meta...
|   |-- http 0.13.4
|   |   |-- async...
|   |   |-- http_parser...
|   |   |-- meta...
|   |   '-- path...
|   |-- meta...
|   |-- normalize 0.5.5
|   |   |-- collection...
|   |   '-- gql...
|   |-- path...
|   |-- rxdart 0.26.0
|   |-- stream_channel 2.1.0
|   |   '-- async...
|   |-- uuid 3.0.5
|   |   '-- crypto...
|   '-- web_socket_channel 2.1.0
|       |-- async...
|       |-- crypto...
|       '-- stream_channel...
|-- hooks_riverpod 1.0.0
|   |-- collection...
|   |-- flutter...
|   |-- flutter_hooks...
|   |-- flutter_riverpod 1.0.0
|   |   |-- collection...
|   |   |-- flutter...
|   |   |-- meta...
|   |   |-- riverpod...
|   |   '-- state_notifier...
|   |-- riverpod 1.0.0
|   |   |-- collection...
|   |   |-- meta...
|   |   '-- state_notifier...
|   '-- state_notifier 0.7.1
|       '-- meta...
|-- json_annotation 4.3.0
|   '-- meta...
|-- logger 1.1.0
|-- objectbox 1.3.0
|   |-- collection...
|   |-- ffi 1.1.2
|   |-- meta...
|   '-- path...
|-- objectbox_flutter_libs 1.3.0
|   |-- objectbox...
|   '-- path_provider...
|-- path 1.8.0
|-- path_provider 2.0.7
|   |-- flutter...
|   |-- path_provider_android 2.0.7
|   |   |-- flutter...
|   |   '-- path_provider_platform_interface...
|   |-- path_provider_ios 2.0.7
|   |   |-- flutter...
|   |   '-- path_provider_platform_interface...
|   |-- path_provider_linux 2.1.2
|   |   |-- flutter...
|   |   |-- path...
|   |   |-- path_provider_platform_interface...
|   |   '-- xdg_directories 0.2.0
|   |       |-- meta...
|   |       |-- path...
|   |       '-- process 4.2.4
|   |           |-- file 6.1.2
|   |           |   |-- meta...
|   |           |   '-- path...
|   |           |-- path...
|   |           '-- platform...
|   |-- path_provider_macos 2.0.3
|   |   '-- flutter...
|   |-- path_provider_platform_interface 2.0.1
|   |   |-- flutter...
|   |   |-- meta...
|   |   |-- platform 3.0.2
|   |   '-- plugin_platform_interface...
|   '-- path_provider_windows 2.0.4
|       |-- ffi...
|       |-- flutter...
|       |-- meta...
|       |-- path...
|       |-- path_provider_platform_interface...
|       '-- win32 2.3.0
|           '-- ffi...
|-- retrofit 3.0.0
|   |-- dio...
|   '-- meta...
|-- snapping_sheet 3.1.0
|   '-- flutter...
|-- sqlite3_flutter_libs 0.5.1
|   '-- flutter...
'-- ua_client_hints 1.1.0
    '-- flutter...
  • flutter doctor -v
Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale en-DE)
    • Flutter version 2.5.3 at /usr/local/Caskroom/flutter/2.2.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (7 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/jiewang/Library/Android/sdk
    • Platform android-30, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.62.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.55

• No issues found!
Steps to reproduce
  1. create a model model.dart;
  2. run flutter pub run build_runner build --delete-conflicting-outputs
  3. See error
Expected behavior

Should have no errors and generate objectbox.g.dart and objectbox-model.json files.

Code

See above

  • Include your pubspec.yaml.
name: admin
description: Admin

publish_to: 'none'

version: 1.0.0+1

environment:
    sdk: '>=2.12.0 <3.0.0'

dependencies:
    animations: ^2.0.2
    auto_route: ^3.1.3
    cupertino_icons: ^1.0.2
    dartz: ^0.10.0
    dio: ^4.0.3
    enum_to_string: ^2.0.1
    flare_flutter: ^3.0.2
    flex_color_scheme: ^4.0.0
    flutter:
        sdk: flutter
    flutter_breadcrumb: ^1.0.1
    flutter_hooks: ^0.18.1
    flutter_secure_storage: ^5.0.2
    freezed_annotation: ^1.0.0
    graphql: ^5.0.0
    hooks_riverpod: ^1.0.0
    json_annotation: ^4.3.0
    logger: ^1.1.0
    objectbox: ^1.3.0
    objectbox_flutter_libs: ^1.3.0
    path: ^1.8.0
    path_provider: ^2.0.7
    retrofit: ^3.0.0
    snapping_sheet: ^3.1.0
    sqlite3_flutter_libs: ^0.5.1
    ua_client_hints: ^1.1.0

dev_dependencies:
    auto_route_generator: ^3.1.0
    build_runner: ^2.1.5
    flutter_lints: ^1.0.0
    flutter_test:
        sdk: flutter
    freezed: ^1.0.0
    json_serializable: ^6.0.1
    objectbox_generator: ^1.3.0
    retrofit_generator: ^3.0.0+1

flutter:
    # The following line ensures that the Material Icons font is
    # included with your application, so that you can use the icons in
    # the material Icons class.
    uses-material-design: true
    # To add assets to your application, add an assets section, like this:
    assets:
        - assets/Teddy.flr
        #- assets/fonts
        #- assets/images
    #   - images/a_dot_ham.jpeg
    # An image asset can refer to one or more resolution-specific "variants", see
    # https://flutter.dev/assets-and-images/#resolution-aware.
    # For details regarding adding assets from package dependencies, see
    # https://flutter.dev/assets-and-images/#from-packages
    # To add custom fonts to your application, add a fonts section here,
    # in this "flutter" section. Each entry in this list should have a
    # "family" key with the font family name, and a "fonts" key with a
    # list giving the asset and other descriptors for the font. For
    # example:
    # fonts:
    #   - family: Schyler
    #     fonts:
    #       - asset: fonts/Schyler-Regular.ttf
    #       - asset: fonts/Schyler-Italic.ttf
    #         style: italic
    #   - family: Trajan Pro
    #     fonts:
    #       - asset: fonts/TrajanPro.ttf
    #       - asset: fonts/TrajanPro_Bold.ttf
    #         weight: 700
    #
    # For details regarding fonts from package dependencies,
    # see https://flutter.dev/custom-fonts/#from-packages

  • Include affected entity classes.

current_user.dart:

import 'package:objectbox/objectbox.dart';

@Entity()
class CurrentUser {
  @Id(assignable: true)
  int? localId;
  @Unique()
  String? id;
  @Property(type: PropertyType.date)
  DateTime createdAt;
  @Property(type: PropertyType.date)
  DateTime? updatedAt;

  CurrentUser({
    this.localId,
    this.id,
    required this.createdAt,
    this.updatedAt,
  });
}

login_remote_data_source.dart, generated by retrofit, all other classes are generated by freezed without @Entity() annotation.

part 'login_remote_data_source.g.dart';

final loginRemoteDataSourceProvider = Provider<LoginRemoteDataSource>((ref) {
  return LoginRemoteDataSource(ref.read);
});

@RestApi()
abstract class LoginRemoteDataSource {
  factory LoginRemoteDataSource(Reader reader) =>
      _LoginRemoteDataSource(reader(dioProvider));

  @POST('auth/login')
  Future<CurrentUser> login(@Body() LoginInputData loginInputData);
}
  • Please remove any unnecessary or confidential parts.
  • At best, link to or attach a project with a failing test.
Logs, stack traces
[WARNING] Bootstrap:
Invalidated precompiled build script due to missing asset graph.
[INFO] Bootstrap:Precompiling build script......
[INFO] Bootstrap:Precompiling build script... completed, took 1.1s

[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Building new asset graph...
[SEVERE] BuildDefinition:
Conflicting outputs
Both objectbox_generator:generator and source_gen:combining_builder may output lib/objectbox.g.dart. Potential outputs must be unique across all builders. See https://github.com/dart-lang/build/blob/master/docs/faq.md#why-do-builders-need-unique-outputs
package:build_runner_core/src/asset_graph/graph.dart 507:11          AssetGraph._addGeneratedOutputs
package:build_runner_core/src/asset_graph/graph.dart 452:21          AssetGraph._addInBuildPhaseOutputs
package:build_runner_core/src/asset_graph/graph.dart 411:26          AssetGraph._addOutputsForSources
package:build_runner_core/src/asset_graph/graph.dart 71:9            AssetGraph.build
package:build_runner_core/src/generate/build_definition.dart 253:41  _Loader.prepareWorkspace.<fn>
package:build_runner_core/src/generate/build_definition.dart 251:64  _Loader.prepareWorkspace.<fn>
package:build_runner_core/src/logging/logging.dart 25:30             logTimedAsync
package:build_runner_core/src/generate/build_definition.dart 251:13  _Loader.prepareWorkspace
package:build_runner_core/src/generate/build_impl.dart 114:27        BuildImpl.create
package:build_runner_core/src/generate/build_runner.dart 34:26       BuildRunner.create
package:build_runner/src/generate/build.dart 109:17                  build
package:build_runner/src/entrypoint/build.dart 35:18                 BuildCommand._run
package:args/command_runner.dart 209:13                              CommandRunner.runCommand
package:build_runner/src/entrypoint/run.dart 26:18                   run
.dart_tool/build/entrypoint/build.dart 39:16                         main

[+6787 ms] "flutter run" took 6,969ms.
[   +7 ms] pub finished with exit code 78
[   +1 ms]
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:391:7)
           <asynchronous suspension>
           #2      PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:247:5)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1125:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:92:3)
           <asynchronous suspension>


[  +95 ms] ensureAnalyticsSent: 93ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 78

Additional context

Add any other context about the problem here.

  • Is there anything special about your app?
  • May transactions or multi-threading play a role?
  • Did you find any workarounds to prevent the issue?

Contributor guide

Open the contributing guide

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 pubspec.yaml dependencies and the model.dart or current_user.dart reproduction, then run flutter pub run build_runner build --delete-conflicting-outputs. Investigate the builders producing lib/objectbox.g.dart, and consider the expected result: a successful build producing objectbox.g.dart and objectbox-model.json without conflicting-output errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
build-system, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.