我有很多SQLite表,由于多个DAO类,现在在应用程序端变得很难管理。我正在使用Bazel作为构建系统,但是我不知道如何将Room DB与Bazel构建系统一起使用。
答案 0 :(得分:0)
如果使用rules_jvm_external之类的Maven工件解析器,它将看起来像这样。
在您的WORKSPACE
文件中,添加对Room编译器的依赖关系:
maven_install(
name = "maven",
artifacts = [
"androidx.room:room-runtime:2.1.0-alpha04",
"androidx.room:room-compiler:2.1.0-alpha04",
# .. other artifacts
],
repositories = [
"https://maven.google.com",
"https://jcenter.bintray.com",
],
)
在BUILD
文件(例如<project root>/BUILD
)中,创建java_plugin
目标,以显示Room的注释处理器:
java_plugin(
name = "androidx_room_room_compiler_plugin",
processor_class = "androidx.room.RoomProcessor",
deps = ["@maven//:androidx_room_room_compiler"],
)
java_library(
name = "androidx_room_room_compiler_library",
exports = [
"@maven//:androidx_room_room_compiler",
],
exported_plugins = [
":androidx_room_room_compiler_plugin"
],
)
最后,在您应用的BUILD
文件中,取决于Room编译器和运行时:
android_library(
name = "lib_prod",
# ...
deps = [
"@maven//:androidx_room_room_runtime",
"//:androidx_room_room_compiler_library",
],
)