我正在尝试使用 IntelliJ IDEA 设置 ObjectBox(在 macOS 上)。从文档中我设置了 build.gradle 代码,但我找不到文档所写的 app/build.gradle。我尝试设置
apply plugin: "io.objectbox" // Apply last.
在项目 build.gradle 但它不起作用。我该如何解决?我使用 Kotlin 作为 JVM 这里是文档 https://docs.objectbox.io/getting-started 这是项目构建,gradle
buildscript {
ext.objectboxVersion = "4.0.3" // For Groovy build scripts
// val objectboxVersion by extra("4.0.3") // For KTS build scripts
repositories {
mavenCentral()
}
dependencies {
classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
}
// Apply plugin after dependencies block so they are not overwritten.
// apply plugin: 'io.objectbox'
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
// id("io.objectbox") // Apply last.
}
group 'org.example'
version '1.0-SNAPSHOT'
// ext.objectboxVersion = "3.4.0"
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
感谢您的宝贵时间。
看来我解决了我的问题,我的设置错误。 我使用文档的examples和这个构建
buildscript {
ext.objectboxVersion = "4.0.3" // For Groovy build scripts
// val objectboxVersion by extra("4.0.3") // For KTS build scripts
repositories {
mavenCentral()
}
dependencies {
classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
}
// Apply plugin after dependencies block so they are not overwritten.
//apply plugin: 'io.objectbox'
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
// id("io.objectbox") // Apply last.
// id("objectbox-publish")
}
group 'org.example'
version '1.0-SNAPSHOT'
// ext.objectboxVersion = "3.4.0"
repositories {
mavenCentral()
}
dependencies {
implementation("io.objectbox:objectbox-java:4.0.3")
// Optional: include all native libraries for distribution
// (only the one for the current platform is added by the plugin).
implementation("io.objectbox:objectbox-linux:4.0.3")
implementation("io.objectbox:objectbox-macos:4.0.3")
implementation("io.objectbox:objectbox-windows:4.0.3")
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
// Apply the plugin after the dependencies block so it detects added
// ObjectBox dependencies and does not replace them.
apply plugin: 'kotlin-kapt'
apply plugin: 'io.objectbox'